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


C++ io_service::run方法代码示例

本文整理汇总了C++中asio::io_service::run方法的典型用法代码示例。如果您正苦于以下问题:C++ io_service::run方法的具体用法?C++ io_service::run怎么用?C++ io_service::run使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在asio::io_service的用法示例。


在下文中一共展示了io_service::run方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: system_timer_custom_allocation_test

void system_timer_custom_allocation_test()
{
  static asio::io_service io_service;
  struct timer
  {
    asio::system_timer t;
    timer() : t(io_service) {}
  } timers[100];

  int allocation_count = 0;

  for (int i = 0; i < 50; ++i)
  {
    timers[i].t.expires_at((asio::system_timer::time_point::max)());
    timers[i].t.async_wait(custom_allocation_timer_handler(&allocation_count));
  }

  for (int i = 50; i < 100; ++i)
  {
    timers[i].t.expires_at((asio::system_timer::time_point::min)());
    timers[i].t.async_wait(custom_allocation_timer_handler(&allocation_count));
  }

  for (int i = 0; i < 50; ++i)
    timers[i].t.cancel();

  io_service.run();

  ASIO_CHECK(allocation_count == 0);
}
开发者ID:breese,项目名称:asio,代码行数:30,代码来源:system_timer.cpp

示例2: ex_flickr

void ex_flickr()
{
    printf ("Tags (default 'kitten'): ");
    std::string tags = util::readLine();

    std::vector<std::string> splitTags;
    boost::split(splitTags, tags, boost::is_space());
    splitTags.resize(
        std::remove(splitTags.begin(), splitTags.end(), "") - splitTags.begin());

    if (splitTags.empty())
        splitTags.push_back("kitten");

    ut::Task<void> task = asyncFlickrDownload(splitTags, 25, 10);

    sIo.run();

    assert(task.isReady());
    try {
        task.get();
    } catch (std::exception& e) {
        printf ("Flickr download failed: %s - %s\n", typeid(e).name(), e.what());
    } catch (...) {
        printf ("Flickr download failed: unknown exception\n");
    }
}
开发者ID:vmilea,项目名称:CppAsync,代码行数:26,代码来源:ex_flickr.cpp

示例3: process_service_work

void scheduler::process_service_work(asio::io_service& service) {
    while (running) {
        try {
            service.run();
        } catch (std::exception& e) {
            (void) e;
            STATICLIB_PION_LOG_ERROR(log, e.what());
        } catch (...) {
            STATICLIB_PION_LOG_ERROR(log, "caught unrecognized exception");
        }
    }   
}
开发者ID:staticlibs,项目名称:staticlib_httpserver,代码行数:12,代码来源:scheduler.cpp

示例4: IOServiceRunThread

DWORD CALLBACK IOServiceRunThread(void *state)
{
	io_service.run();
	::SetEvent(io_sync_mutex);
	return 0;
}
开发者ID:tilutza,项目名称:out_streamer,代码行数:6,代码来源:out_streamer+-+Copy.cpp

示例5: io_service_thread

	void io_service_thread() {
		io_svc.run();
		if(log_level) std::cerr << "io_svc stopped" << std::endl;
		serial.close(); //serial port should be closed from the same thread as io service
	}
开发者ID:stdk,项目名称:u2,代码行数:5,代码来源:asio_mt_impl.cpp

示例6: run

 void run(size_t n, ThreadGroup& tg) {
     tg.run([this]{
         asio::io_service::work work(io_service);
         io_service.run();
     }, n);
 }
开发者ID:urykhy,项目名称:rpc,代码行数:6,代码来源:WorkQ.hpp

示例7: run_ios

void run_ios( ba::io_service &ios )
{
    while( 1 ) {
        ios.run( );
    }
}
开发者ID:newenclave,项目名称:vtrc,代码行数:6,代码来源:main.cpp


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