当前位置: 首页>>代码示例>>C++>>正文


C++ Dispatcher::start方法代码示例

本文整理汇总了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;
}
开发者ID:Testerus,项目名称:forgottenserver,代码行数:60,代码来源:otserv.cpp

示例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();
 }
开发者ID:psyllo,项目名称:x3d,代码行数:10,代码来源:CartesianApp.cpp

示例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;
}
开发者ID:binbin6363,项目名称:myproject,代码行数:48,代码来源:send_cmd.cpp

示例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;
}
开发者ID:nclx,项目名称:forgottenserver,代码行数:38,代码来源:otserv.cpp

示例5: luaDispatcherStart

// Dispatcher
int LuaBinder::luaDispatcherStart(lua_State*)
{
	g_dispatcher.start();
	return 1;
}
开发者ID:slavidodo,项目名称:coppem-server,代码行数:6,代码来源:luaenv.cpp


注:本文中的Dispatcher::start方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。