c++ work queues with blocking
Well. That’s really quite simple; You’re rejecting the tasks posted! template< typename Task > void run_task(task task){ boost::unique_lock<boost::mutex> lock( mutex_ ); if(0 < available_) { –available_; io_service_.post(boost::bind(&tpool::wrap_task, this, boost::function< void() > ( task ))); } } Note that the lock “waits” until the mutex is not owned by a thread. This might already be the … Read more