本文整理汇总了C++中Dispatcher::start方法的典型用法代码示例。如果您正苦于以下问题:C++ Dispatcher::start方法的具体用法?C++ Dispatcher::start怎么用?C++ Dispatcher::start使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dispatcher
的用法示例。
在下文中一共展示了Dispatcher::start方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char* argv[])
{
// Setup bad allocation handler
std::set_new_handler(badAllocationHandler);
#ifndef _WIN32
// ignore sigpipe...
struct sigaction sigh;
sigh.sa_handler = SIG_IGN;
sigh.sa_flags = 0;
sigemptyset(&sigh.sa_mask);
sigaction(SIGPIPE, &sigh, nullptr);
#endif
ServiceManager servicer;
g_dispatcher.start();
g_scheduler.start();
g_dispatcher.addTask(createTask(std::bind(mainLoader, argc, argv, &servicer)));
g_loaderSignal.wait(g_loaderUniqueLock);
if (servicer.is_running()) {
std::cout << ">> " << g_config.getString(ConfigManager::SERVER_NAME) << " Server Online!" << std::endl << std::endl;
#ifdef _WIN32
SetConsoleCtrlHandler([](DWORD) -> BOOL {
g_dispatcher.addTask(createTask([]() {
g_dispatcher.addTask(createTask(
std::bind(&Game::shutdown, &g_game)
));
g_scheduler.stop();
g_databaseTasks.stop();
g_dispatcher.stop();
}));
ExitThread(0);
}, 1);
#endif
servicer.run();
g_scheduler.join();
g_databaseTasks.join();
g_dispatcher.join();
} else {
std::cout << ">> No services running. The server is NOT online." << std::endl;
g_dispatcher.addTask(createTask([]() {
g_dispatcher.addTask(createTask([]() {
g_scheduler.shutdown();
g_databaseTasks.shutdown();
g_dispatcher.shutdown();
}));
g_scheduler.stop();
g_databaseTasks.stop();
g_dispatcher.stop();
}));
g_scheduler.join();
g_databaseTasks.join();
g_dispatcher.join();
}
return 0;
}
示例2: eventLoop
void CartesianApp::eventLoop() {
assert(screen);
ScreenInfo* screen_info = screen->getInfo();
Rasterizer* ras = new Rasterizer(screen_info, screen->getWindowWidth(),
screen->getWindowHeight());
PipelineXCBCartesian* pipeline = new PipelineXCBCartesian(ras, screen);
FactoryManager fm;
Dispatcher* dispatcher = fm.getDispatcherFactory()->create(pipeline, screen);
dispatcher->start();
}
示例3: main
int main(int argc, char *argv[])
{
int ret = 0;
if (argc != 2)
{
ret = -1;
return ret;
}
if (0 == strcmp(argv[1], "-hello"))
{
hello();
fprintf(stdout, "\n");
help();
return ret;
}
welcome();
// 1.load cmd, generate addres and output packet
char *path = argv[1];
ClientApp app;
Dispatcher dispatcher;
Net_Session *session = app.get_session();
dispatcher.set_session(session);
ret = load_cfg(path, dispatcher);
LOG(INFO)("load config file done. ret=%d", ret);
if (0 != ret)
{
fprintf(stderr, "error!!!\n");
return 0;
}
// 2.open server session
app.open();
LOG(INFO)("init and open mobi server done.");
// 3.start send packet thread
dispatcher.start();
LOG(INFO)("start send packet thread.");
// 4.loop event
LOG(INFO)("enter loop, begin...");
app.run_service();
LOG(INFO)("done.");
//app.send_packet(outpkg);
goodbye();
return ret;
}
示例4: main
int main(int argc, char* argv[])
{
// Setup bad allocation handler
std::set_new_handler(badAllocationHandler);
#ifndef WIN32
// ignore sigpipe...
struct sigaction sigh;
sigh.sa_handler = SIG_IGN;
sigh.sa_flags = 0;
sigemptyset(&sigh.sa_mask);
sigaction(SIGPIPE, &sigh, NULL);
#endif
ServiceManager servicer;
g_dispatcher.start();
g_scheduler.start();
g_dispatcher.addTask(createTask(boost::bind(mainLoader, argc, argv, &servicer)));
g_loaderSignal.wait(g_loaderUniqueLock);
if (servicer.is_running()) {
std::cout << ">> " << g_config.getString(ConfigManager::SERVER_NAME) << " Server Online!" << std::endl << std::endl;
servicer.run();
g_scheduler.join();
g_dispatcher.join();
} else {
std::cout << ">> No services running. The server is NOT online." << std::endl;
g_scheduler.stop();
g_dispatcher.stop();
g_dispatcher.addTask(createTask(boost::bind(shutdown)));
g_scheduler.join();
g_dispatcher.join();
}
return 0;
}
示例5: luaDispatcherStart
// Dispatcher
int LuaBinder::luaDispatcherStart(lua_State*)
{
g_dispatcher.start();
return 1;
}