I don't understand how it works :(. we have few io_service object which are run() in separated threads. but only one is maintained by async_accept chain trick. the rest run() should immediately return.
Please, read that example carefully, there's an explanation inside. You've got special "work" object that prevents io_service::run from stopping.
hymm, it is really hard to understand what work object is doing because in my opinion explanations " Give all the io_services
work to do so that their run() functions will not exit until they are
explicitly stopped." are not equal with doc's "The work class is used
to inform the io_service when work starts and finishes. This ensures that the io_service's
run() function will not exit while work is underway, and that it does
exit when there is no unfinished work remaining. "
because of it I did not caught meaning of work's work ;)
ok, I know now how it works.
thanks Igor,
But I have another question, about "http server 3" example where we have one io_service and pool of threads for it. I have written simple example where 3 computation tasks are scheduled in one io_service
than pool of three thread is run for it. tasks are performed in parallel
mode - each one in separate thread. I understand it.
but I don't know for what there is pool of threads in "http server 3" example. there is only one scheduled task - async_accept. So, in my opinion only one thread will be doing whole job.