[cpp-threads] Asynchronous Function Proposal

k-oli at gmx.de k-oli at gmx.de
Mon Jun 1 07:43:46 BST 2009


Am Montag 01 Juni 2009 00:59:07 schrieb Lawrence Crowl:
> Please take a look at the attacked draft proposal for the async
> function.  Comments are encouraged.

"Related Work
 Oliver Kowalke is implementing boost.task (formerly known as 
boost.threadpool). In this library, launch_in_thread() reuses existing 
threads. The function returns a returns handle object for both thread and 
return value. This library also allows task interruption."

I did a little re-work based upon the posts of this mailing list.

the function async takes an asynchronous executor and an task as arguments 
(task will be executed by ae) und retursn a handle (manages task -> 
interruption and result transfer),

examples:

boost::task::handle< long > h(
    boost::task::async(
        boost::task::default_pool(),	// execute in the default thread-pool
            boost::task::make_task(
                parallel_fib, 10, 5) ) );
long result = h.get();

or to execute the task in a new thread (handle does joining the thread)

boost::task::handle< long > h(
    boost::task::async(
        boost::task::new_thread(),	// execute in a new thread
            boost::task::make_task(
                parallel_fib, 10, 5) ) );
long result = h.get();

other async. executers are: own_thread, as_sub_task, a custom threadpool.
The user could also apply its own async. executor.

regards,
Oliver



More information about the cpp-threads mailing list