Changes between Version 17 and Version 18 of LibrariesUnderConstruction


Ignore:
Timestamp:
Jan 3, 2009, 10:02:52 PM (14 years ago)
Author:
viboes
Comment:

Adding AsynchronousExecutors

Legend:

Unmodified
Added
Removed
Modified
  • LibrariesUnderConstruction

    v17 v18  
    377377
    378378---------------------------------------------------------------------------------------------------
     379== !AsynchronousExecutors ==
     380 * '''Suggested by:''' Vicente J. Botet Escriba 
     381 * '''Description:''' Asynchronous Executors (AE) and Asynchronous Completion Tokens (ACT) in a generic way (or at least this was my intention). The library can be considered as a front-end for several Asynchronous Execution models making it possible to share common algorithms and making easier to switch from an Asynchronous Executors to another.
     382
     383Next follows the motivation for the library and how the library can manage with this concepts.
     384
     385In N1833 - Preliminary Threading Library Proposal for TR2 Kevlin Henney introduce the concept of threader and a function thread that evaluate a function asynchronously and returns a joiner handle.
     386In N2185 - Proposed Text for Parallel Task Execution Peter Dimov introduce a fork function able to evaluate a function asynchronously and returns a future handle.
     387In N2276 - Thread Pools and Futures Anthony William introduce launch_in_thread and launch_in_pool function templates which evaluate a function asynchronously either in a specific thread or a thread pool and returns a unique_future handle.
     388In Boost.ThreadPool Oliver Kowalke propose a complete implementation of a thread pool with a submit function which evaluate a function asynchronously and returns a task handle.
     389
     390Behind all these proposal there is a concept of asynchronous executor, fork-launch-like function and the asynchronous completion token handle.
     391
     392|| Name             || executor    || fork-like          || ACT ||
     393|| Boost.Thread     || ??          || thread constructor || thread  ||
     394|| Boost.!ThreadPool || tp::pool    || submit             || tp::task  ||
     395|| N2276            || thread      || launch_in_thread   || unique_future<T>  ||
     396|| N2276            || thread_pool || launch_in_pool     || unique_future<T>  ||
     397|| N2185            || ??          || fork               || future<T>  ||
     398|| N1833            || threader    || thread             || joiner<T>  ||
     399
     400The asynchronous completion token models can follows two interfaces, the thread interface and the unique_future interface.
     401Some asynchronous completion token handles allows to recover the result of the evaluation of the function (futures), other allows to manage the underlying thread of execution (thread) and some both (joiner and tp::task).
     402
     403It seems natural to make a generic fork function that will evaluate a function asynchronously with respect to the calling thread and returns an ACT handle. The following meta-function associated an ACT handle to a asynchronous executor.
     404
     405{{{
     406#!cpp
     407template <typename AE, typename T>
     408struct asynchronous_completion_token {
     409    typedef typename AE::template handle<T>::type type;
     410};   
     411}}}
     412
     413The result of forking a nullary function by an asynchronous executor is given by the following meta-function:
     414
     415{{{
     416#!cpp
     417namespace result_of {
     418    template <typename AE,typename F>
     419    struct fork {
     420        typedef typename asynchronous_completion_token<AE, typename result_of<F()>::type>::type type;
     421    };   
     422}
     423}}}
     424
     425The default implementation of fork delegates on fork asynchronous executor function.
     426
     427{{{
     428#!cpp
     429template< typename AE, typename F >
     430result_of::fork<AE, F>::type fork( AE& ae, F fn ) {
     431    return ae.fork(fn);
     432}
     433}}}
     434
     435Forking n-ary functions relies on the nullary version and bind.
     436
     437{{{
     438#!cpp
     439template< typename AE, typename F, typename A1, ..., typename An >
     440asynchronous_completion_token<AE, typename result_of<F(A1,..., An)>::type >::type
     441fork( AE& ae, F fn, A1 a1, ..., An an ) {
     442    return ae.fork( bind( fn, a1, ..., an ) );
     443}
     444}}}
     445
     446---------------------------------------------------------------------------------------------------
    379447== !ContraintsProgramming ==
    380448 * '''Suggested by:''' Vicente J. Botet Escriba 
     
    600668 * '''Suggested by:''' Vicente J. Botet Escriba 
    601669 * '''Description:''' Threader/Joiner as proposed by Kevlin Henney `[http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1883.pdf Preliminary Threading Library Proposal for TR2]
    602 
     670This library works well with [#Boost.AsynchronousExecutors AsynchronousExecutors].
    603671
    604672---------------------------------------------------------------------------------------------------
     
    647715---------------------------------------------------------------------------------------------------
    648716== Concurrent Programming ==
     717 * [#Boost.AsynchronousExecutors AsynchronousExecutors]
    649718 * [#Boost.Coroutines Coroutines]
    650719 * [#Boost.Fiber Fiber]