[task] - boost.task (replacement for boost.threadpool)

Hi, boost vault (section 'Concurrent Programming' - http://www.boostpro.com/vault/) contains boost.task. It replaces boost.threadpool and provides a framework for parallel execution of tasks (launching task in the current thread, in a new thread, as sub-task or in a pool of threads). The code looks someting like this: std::string echo( std::string const& msg) { return msg; } void main() { boost::task::handle< std::string > h( boost::task::async( boost::task::new_thread(), boost::task::make_task( echo, "Hello World!") ) ); std::cout << h.get() << std::endl; } or long fibonacci_fn( long n) { if ( n == 0) return 0; if ( n == 1) return 1; long k1( 1), k2( 0); for ( int i( 2); i <= n; ++i) { long tmp( k1); k1 = k1 + k2; k2 = tmp; } return k1; } void main() { std::cout << "worker-threads running in default-pool == "; std::cout << boost::task::default_pool().size() << "\n"; boost::task::handle< long > h1( boost::task::async( boost::task::default_pool(), boost::task::make_task( fibonacci_fn, 10) ) ); boost::task::handle< long > h2( boost::task::async( boost::task::default_pool(), boost::task::make_task( fibonacci_fn, 5) ) ); std::cout << "fibonacci(10) == " << h1.get() << "\n"; std::cout << "fibonacci(5) == " << h2.get() << std::endl; } best regards, Oliver

k-oli@gmx.de wrote:
Hi, boost vault (section 'Concurrent Programming' - http://www.boostpro.com/vault/) contains boost.task.
It replaces boost.threadpool and provides a framework for parallel execution of tasks (launching task in the current thread, in a new thread, as sub-task or in a pool of threads).
Hi, colour me interested. What is the main benefit above the threadpool library? I presume the threadpool library you are talking about is http://threadpool.sf.net ? It seems the only real difference is a future/handle which the above library also has in an experimental capacity. Thanks in advance. -- Sohail Somani http://uint32t.blogspot.com

Am Montag 01 Juni 2009 21:11:17 schrieb Sohail Somani:
k-oli@gmx.de wrote:
Hi, boost vault (section 'Concurrent Programming' - http://www.boostpro.com/vault/) contains boost.task.
It replaces boost.threadpool and provides a framework for parallel execution of tasks (launching task in the current thread, in a new thread, as sub-task or in a pool of threads).
Hi, colour me interested.
What is the main benefit above the threadpool library? I presume the threadpool library you are talking about is http://threadpool.sf.net ?
No it is not the lib from http://threadpool.sf.net (I was refering to boost.threadpool in the boost vault - > now replaced)! The benefit above boost.threadpool is that boost.task implements the proposals currently discussed on the mailing list from the C++ standard committee's Library Working Group. Another point is that you can execute your task by different async. executors (which can be the default thread-pool, a customized thread-pool -> priority scheduling, in a new created thread, as a sub-task or in a completly different executor provided by yourself).
It seems the only real difference is a future/handle which the above library also has in an experimental capacity.
AFAIK - the implementation from http://threadpool.sf.net doesn't provide a working future implementation nor does is implement work-stealing (including sub-tasking) or task interruption. Boost.Task provides this functionality (it uses the future implementation from Anthony Williams which will be part of boost soon). Best regards, Oliver

k-oli@gmx.de wrote:
Am Montag 01 Juni 2009 21:11:17 schrieb Sohail Somani:
It seems the only real difference is a future/handle which the above library also has in an experimental capacity.
AFAIK - the implementation from http://threadpool.sf.net doesn't provide a working future implementation nor does is implement work-stealing (including sub-tasking) or task interruption. Boost.Task provides this functionality (it uses the future implementation from Anthony Williams which will be part of boost soon).
Ah, thanks for clarifying. I think your statements are correct. Is boost.task being used in production yet? -- Sohail Somani http://uint32t.blogspot.com
participants (2)
-
k-oli@gmx.de
-
Sohail Somani