void Processor::Start() { Print(NOW "Start processor...\n", now); InitThreadPool(); CreateThread(ThreadPoolManger, this); RunAfter(1); }
/** * \brief This is the function where CG beings * * \param argc number of arguments * \param argv pointer to char arrays where * where the passed arguments are stored * in the process * \return This always returns 0. If * some errors appear, take a look * at the Logfile. * */ int main(int argc, char *argv[]) { #if SDL_VERSION_ATLEAST(2, 0, 0) #ifdef ANDROID SDL_SetMainReady( ); #endif #endif // Check if CG should look into a given directory if(argc >= 1) { binary_dir = argv[0]; size_t slashpos = findLastPathSep(binary_dir); if(slashpos != std::string::npos) { binary_dir.erase(slashpos); binary_dir = SystemNativeToUtf8(binary_dir); } else { binary_dir = "."; } } else { warnings << "Binary-argument not given, assuming current dir" << endl; binary_dir = "."; } binary_dir = GetAbsolutePath(binary_dir); InitThreadPool(); InitSearchPaths(); g_pLogFile->CreateLogfile("CGLog.html"); // The Game Class instance is the main class managing whole // interpreter instance. TODO: It should be a singleton CGame Game; //////////////////////////// // Initialize Game Engine // //////////////////////////// if( Game.init( argc, argv ) ) { /////////////////////// // Start Game Engine // /////////////////////// Game.run(); } std::cout << "Thank you very much for playing this game!" << std::endl; UnInitThreadPool(); return 0; }
void EasyIocp::InitIocp() { //创建完成端口 hCompPort_ = CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, 0, 0); if(!hCompPort_) { ErrorSysMessage("EasyIocp::Construct: CreateIoCompletionPort failed."); } assert(hCompPort_ != NULL); print("EasyIocp::InitIocp: init IOCP successfully."); //设置服务器ip地址 memset(&bindAddr_, 0, sizeof(bindAddr_)); GetDefaultAddr(&bindAddr_); bindAddr_.sin_port = htons(EASYIOCP_DEFAULT_PORT); InitThreadPool(); }
/** * \brief This is the function where CG beings * * \param argc number of arguments * \param argv pointer to char arrays where * where the passed arguments are stored * in the process * \return This always returns 0. If * some errors appear, take a look * at the Logfile. * */ int main(int argc, char *argv[]) { #if SDL_VERSION_ATLEAST(2, 0, 0) #ifdef ANDROID SDL_SetMainReady( ); #endif #endif // Check if CG should look into a given directory std::string binary_dir; if(argc >= 1) { binary_dir = argv[0]; size_t slashpos = findLastPathSep(binary_dir); if(slashpos != std::string::npos) { binary_dir.erase(slashpos); binary_dir = SystemNativeToUtf8(binary_dir); } else { binary_dir = "."; } } else { warnings << "Binary-argument not given, assuming current dir" << endl; binary_dir = "."; } SetBinaryDir( GetAbsolutePath(binary_dir) ); InitThreadPool(); InitSearchPaths(g_pSettings->getConfigFileName()); gLogging.CreateLogfile("CGLog.html", APP_NAME, CGVERSION); // Check if there are settings on the PC, otherwise use defaults. if(!g_pSettings->loadDrvCfg()) { //m_firsttime = true; gLogging.textOut(RED,"First time message: CG didn't find the driver config file. "); gLogging.textOut(RED,"However, it generated some default values and will save them now.\n"); g_pSettings->saveDrvCfg(); } gLogging.textOut(GREEN,"Loading game options...\n"); if(!g_pSettings->loadGameOptions()) { gLogging.textOut(RED,"Cannot do loading defaults...\n"); g_pSettings->loadDefaultGameCfg(); } // Init the Game sound g_pSound->init(); //////////////////////////////////////////////////// // Initialize CG and run the main cycle if worthy // //////////////////////////////////////////////////// if( gApp.init( argc, argv ) ) { //////////////////////////////// // Set GameLauncher as Engine // //////////////////////////////// gApp.setEngine(new CGameLauncher(false)); ////////////////////////////// // Run the Commander Genius // ////////////////////////////// gApp.runMainCycle(); } g_pSettings->saveDispCfg(); UnInitThreadPool(); return 0; }
int InitCoAManager () { int iRetVal = 0; do { std::vector<std::string> vectConfParam; std::string strConfParam; iRetVal = g_coConf.GetParamValue ("log_file_mask", strConfParam); if (iRetVal) { UTL_LOG_F(g_coLog, "Log file mask not defined"); break; } /* инициализация логгера */ iRetVal = g_coLog.Init (strConfParam.c_str()); if (iRetVal) { UTL_LOG_F(g_coLog, "can not initialize log writer: code: '%d'", iRetVal); break; } /* изменение пользователя и группы владельца демона */ ChangeOSUser (); std::string strDBPoolSize; int iDBPoolSize; int iFnRes; const char *pcszConfParam = "db_pool_size"; iFnRes = g_coConf.GetParamValue( pcszConfParam, strDBPoolSize ); if( iFnRes || 0 == strDBPoolSize.length() ) { UTL_LOG_F( g_coLog, "dbpool: configuration parameter '%s' not defined", pcszConfParam ); } else { iDBPoolSize = atoi( strDBPoolSize.c_str() ); } std::string strDBUser, strDBPswd, strDBDescr; pcszConfParam = "db_user"; iFnRes = g_coConf.GetParamValue( pcszConfParam, strDBUser ); if( iFnRes || 0 == strDBUser.length() ) { UTL_LOG_F( g_coLog, "dbpool: configuration parameter '%s' not defined", pcszConfParam ); } /* запрашиваем пароль пользователя БД из конфигурации */ pcszConfParam = "db_pswd"; iFnRes = g_coConf.GetParamValue( pcszConfParam, strDBPswd ); if( iFnRes || 0 == strDBPswd.length() ) { UTL_LOG_F( g_coLog, "dbpool: configuration parameter '%s' not defined", pcszConfParam ); } /* запрашиваем дескриптор БД из конфигурации */ pcszConfParam = "db_descr"; iFnRes = g_coConf.GetParamValue( pcszConfParam, strDBDescr ); if( iFnRes || 0 == strDBDescr.length() ) { UTL_LOG_F( g_coLog, "dbpool: configuration parameter '%s' not defined", pcszConfParam ); } /* инициализация пула подклчений к БД */ iRetVal = db_pool_init(&g_coLog, strDBUser, strDBPswd, strDBDescr, iDBPoolSize ); if (iRetVal) { UTL_LOG_F(g_coLog, "can not initialize DB pool"); } /* создание списка NASов */ iRetVal = CreateNASList (&g_mapNASList); if (iRetVal) { break; } /* инициализация пула потоков */ iRetVal = InitThreadPool (); if (iRetVal) { break; } } while (0); return iRetVal; }