Here is the problem:
In the main thread (io - boost::asio::io_service):
io.post(functor1, callback1)
....
io.post(functorN, callbackN)
io.join() <--- waiting while all the task to be processed and continue to execute the program
The code is executed in a loop. boost::thread_group
would perfectly match, but it creates new threads all the times, while I want to create working threads only once and dispatch tasks to them, exactly as asio does. All pool threads I've seen are just wrapers around vector of threads + io_service, it can't be used in the way I've shown above.
So, how can I make "join" for boost::asio?