Exemplo n.º 1
0
void ThreadIoServiceRun(io_service_ptr io_service){
  while (1){
    try{
      io_service->run();
    }
    catch (std::exception& e) {
      std::cerr << e.what() << std::endl;
    }
  }
}
Exemplo n.º 2
0
  /// Run an io_service.
  void run_service(io_service_ptr io_service)
  {
    // Run the io_service and check executed handler number.
    if (io_service->run() != 0)
    {
      // Lock for synchronize access to data.
      scoped_lock_t lock(mutex_);

      // Some handlers has been executed, set to false.
      idle_ = false;
    }
  }
Exemplo n.º 3
0
  /// Start an io_service.
  void start_one(io_service_ptr io_service)
  {
    // Reset the io_service in preparation for a subsequent run() invocation.
    io_service->reset();

    // Give the io_service work to do so that its run() functions will not
    //   exit until work was explicitly destroyed.
    work_.push_back(work_ptr(new boost::asio::io_service::work(*io_service)));

    // Create a thread to run the io_service.
    threads_.push_back(thread_ptr(new boost::thread(boost::bind(&io_service_pool::run_service,
                                                                this,
                                                                io_service))));
  }