Boost logo

Boost Users :

From: Andrej van der Zee (mavdzee_at_[hidden])
Date: 2007-06-21 22:09:08


Hi,

I have some (beginners) question about the example
server3-porgram that ships with the library. It uses
multiple threads with a single io_service. In the
method server::run() this happens:

std::vector<boost::shared_ptr<boost::thread> >
threads;
for (std::size_t i = 0; i < thread_pool_size_; ++i)
{
  boost::shared_ptr<boost::thread> thread(new
boost::thread(boost::bind(&boost::asio::io_service::run,
&io_service_)));
  threads.push_back(thread);
}

for (std::size_t i = 0; i < threads.size(); ++i)
  threads[i]->join();

But when are the threads actually scheduled? Does this
happen by the shared io_service? Are the registered
callback methods for async_read, async_accept, etc
executed in the threads?

Also, are there any tradeoffs that I should know off
for using the single io_service vs
io_service-per-thread approach?

Thank you,
Andrej

      ___________________________________________________________
Yahoo! Mail is the world's favourite email. Don't settle for less, sign up for
your free account today http://uk.rd.yahoo.com/evt=44106/*http://uk.docs.yahoo.com/mail/winter07.html


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net