
I have implemented a parallel_sort that is a bit slower than tbb with threadpool (see below for the code).
* shutdown() renders the thread pool unusable (marks it terminated). This is not what I was looking for. Ideally, a wait() method that just waits for the pool to have no tasks left to process would be better. I would find it cumbersome to manually wait for the result of each task. My 2c.
Am Sunday 08 March 2009 19:48:11 schrieb Edouard A.: threadpool uses a signle-lock global queue - if a thread enters the queue for enqueing/dequeing a task it aquires the lock so no other thread can enter the queue. with a lock-free implementation it should work faster. pool::shutdown() is not correct - use boost::wait_for_all() or boost::wait_for_any() from the future lib from Anthony WIlliams (I've added the lib to threadpool archive). task< int > tsk1 = pool.submit(...); task< string > tsk2 = pool.submit(...); task< int > tsk3 = pool.submit(...); wait_for_all( tsk1.result(), tsk2.result(), tsk3.result()); // here all tasks are finsihed
* Instrumentation seems to show that the _entry method of the pool is extremely slow. I have not investigated further.
the pool::entry_ method is entered by boost::thread only on startup and will only left if the worker-thread terminates Oliver