I\'m using boost::asio::io_service as a basic thread pool. Some threads get added to io_service, the main thread starts posting handlers, the worker threads start r
boost::asio::io_service
I'm using the semaphore to fix the handlers queue size. The following code illustrate this solution:
void Schedule(boost::function function) { semaphore.wait(); io_service.post(boost::bind(&TaskWrapper, function)); } void TaskWrapper(boost::function &function) { function(); semaphore.post(); }