Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r54774 - in sandbox/task: boost/task boost/task/detail libs/task/doc
From: oliver.kowalke_at_[hidden]
Date: 2009-07-07 13:31:07


Author: olli
Date: 2009-07-07 13:31:05 EDT (Tue, 07 Jul 2009)
New Revision: 54774
URL: http://svn.boost.org/trac/boost/changeset/54774

Log:
* docu update

Added:
   sandbox/task/libs/task/doc/ref_callable.qbk (contents, props changed)
   sandbox/task/libs/task/doc/ref_context.qbk (contents, props changed)
   sandbox/task/libs/task/doc/ref_context_guard.qbk (contents, props changed)
   sandbox/task/libs/task/doc/user_defined_executor.qbk (contents, props changed)
Text files modified:
   sandbox/task/boost/task/callable.hpp | 28 ++++++++++----------
   sandbox/task/boost/task/detail/worker.hpp | 37 +++++++++++++++++----------
   sandbox/task/boost/task/new_thread.hpp | 16 +++--------
   sandbox/task/boost/task/static_pool.hpp | 12 +++------
   sandbox/task/libs/task/doc/as_sub_task.qbk | 4 --
   sandbox/task/libs/task/doc/async.qbk | 16 ++++++++---
   sandbox/task/libs/task/doc/boost_task.qbk | 9 +++---
   sandbox/task/libs/task/doc/execution_policy.qbk | 1
   sandbox/task/libs/task/doc/fork_join.qbk | 24 +++++++++--------
   sandbox/task/libs/task/doc/introduction.qbk | 53 +++++++++++++++------------------------
   sandbox/task/libs/task/doc/reference.qbk | 3 ++
   sandbox/task/libs/task/doc/task.qbk | 16 ++++++++++-
   sandbox/task/libs/task/doc/todo.qbk | 3 +
   13 files changed, 115 insertions(+), 107 deletions(-)

Modified: sandbox/task/boost/task/callable.hpp
==============================================================================
--- sandbox/task/boost/task/callable.hpp (original)
+++ sandbox/task/boost/task/callable.hpp 2009-07-07 13:31:05 EDT (Tue, 07 Jul 2009)
@@ -74,20 +74,6 @@
         {}
 
 public:
- class context_guard : private noncopyable
- {
- private:
- callable & ca_;
-
- public:
- context_guard( callable & ca, shared_ptr< thread > const& thrd)
- : ca_( ca)
- { ca_.reset( thrd); }
-
- ~context_guard()
- { ca_.reset(); }
- };
-
         callable();
 
         void operator()();
@@ -101,6 +87,20 @@
         void reset( shared_ptr< thread > const&);
 };
 
+class context_guard : private noncopyable
+{
+private:
+ callable & ca_;
+
+public:
+ context_guard( callable & ca, shared_ptr< thread > const& thrd)
+ : ca_( ca)
+ { ca_.reset( thrd); }
+
+ ~context_guard()
+ { ca_.reset(); }
+};
+
 }}
 
 # if defined(BOOST_MSVC)

Modified: sandbox/task/boost/task/detail/worker.hpp
==============================================================================
--- sandbox/task/boost/task/detail/worker.hpp (original)
+++ sandbox/task/boost/task/detail/worker.hpp 2009-07-07 13:31:05 EDT (Tue, 07 Jul 2009)
@@ -35,16 +35,24 @@
 
 namespace boost { namespace task
 {
+
+template< typename Channel >
+class static_pool;
+
 namespace detail
 {
+
 class BOOST_TASK_DECL worker
 {
 private:
+ template< typename Channel >
+ friend class static_pool;
+
         static thread_specific_ptr< worker > tss_;
 
- struct impl
+ struct worker_base
         {
- virtual ~impl() {}
+ virtual ~worker_base() {}
 
                 virtual const thread::id get_id() const = 0;
 
@@ -68,8 +76,8 @@
         };
 
         template< typename Pool >
- class impl_pool : public impl,
- private noncopyable
+ class worker_object : public worker_base,
+ private noncopyable
         {
         private:
                 class random_idx
@@ -78,7 +86,7 @@
                         rand48 rng_;
                         uniform_int<> six_;
                         variate_generator< rand48 &, uniform_int<> > die_;
-
+
                 public:
                         random_idx( std::size_t size)
                         :
@@ -86,7 +94,7 @@
                         six_( 0, size - 1),
                         die_( rng_, six_)
                         {}
-
+
                         std::size_t operator()()
                         { return die_(); }
                 };
@@ -107,13 +115,13 @@
                         BOOST_ASSERT( ! ca.empty() );
                         guard grd( get_pool().active_worker_);
                         {
- callable::context_guard lk( ca, thrd_);
+ context_guard lk( ca, thrd_);
                                 ca();
                         }
                         ca.clear();
                         BOOST_ASSERT( ca.empty() );
                 }
-
+
                 void next_callable_( callable & ca)
                 {
                         if ( ! try_take( ca) )
@@ -128,7 +136,7 @@
                                                 if ( ++idx >= get_pool().wg_.size() ) idx = 0;
                                                 if ( other.try_steal( ca) ) break;
                                         }
-
+
                                         if ( ca.empty() )
                                         {
                                                 guard grd( get_pool().idle_worker_);
@@ -148,7 +156,7 @@
                                 }
                         }
                 }
-
+
                 void next_local_callable_( callable & ca)
                 {
                         if ( ! try_take( ca) )
@@ -186,7 +194,7 @@
                 { return shtdwn_now_sem_.try_wait(); }
 
         public:
- impl_pool(
+ worker_object(
                         Pool & pool,
                         poolsize const& psize,
                         posix_time::time_duration const& asleep,
@@ -279,7 +287,7 @@
                 }
         };
 
- shared_ptr< impl > impl_;
+ shared_ptr< worker_base > impl_;
 
 public:
         template< typename Pool >
@@ -291,7 +299,7 @@
                 function< void() > const& fn)
         :
         impl_(
- new impl_pool< Pool >(
+ new worker_object< Pool >(
                         pool,
                         psize,
                         asleep,
@@ -315,7 +323,7 @@
         template< typename Pool >
         Pool & get_pool() const
         {
- impl_pool< Pool > * p( dynamic_cast< impl_pool< Pool > * >( impl_.get() ) );
+ worker_object< Pool > * p( dynamic_cast< worker_object< Pool > * >( impl_.get() ) );
                 BOOST_ASSERT( p);
                 return p->get_pool();
         }
@@ -324,6 +332,7 @@
 
         static worker * tss_get();
 };
+
 }}}
 
 # if defined(BOOST_MSVC)

Modified: sandbox/task/boost/task/new_thread.hpp
==============================================================================
--- sandbox/task/boost/task/new_thread.hpp (original)
+++ sandbox/task/boost/task/new_thread.hpp 2009-07-07 13:31:05 EDT (Tue, 07 Jul 2009)
@@ -24,21 +24,13 @@
 {
 namespace detail
 {
-class joiner
-{
-private:
- callable ca_;
-
-public:
- joiner( callable const& ca)
- : ca_( ca)
- {}
 
+struct joiner
+{
         void operator()( thread * thrd)
         {
                 try
                 {
- ca_.reset();
                         BOOST_ASSERT( thrd);
                         BOOST_ASSERT( thrd->joinable() );
                         thrd->join();
@@ -48,6 +40,7 @@
                 delete thrd;
         }
 };
+
 }
 
 struct new_thread
@@ -61,12 +54,13 @@
                 callable ca( ctx.get_callable( boost::move( t) ) );
                 shared_ptr< thread > thrd(
                         new thread( ca),
- detail::joiner( ca) );
+ detail::joiner() );
                 ca.reset( thrd);
 
                 return h;
         }
 };
+
 }}
 
 #include <boost/config/abi_suffix.hpp>

Modified: sandbox/task/boost/task/static_pool.hpp
==============================================================================
--- sandbox/task/boost/task/static_pool.hpp (original)
+++ sandbox/task/boost/task/static_pool.hpp 2009-07-07 13:31:05 EDT (Tue, 07 Jul 2009)
@@ -53,10 +53,8 @@
 
         friend class detail::worker;
 
-# if defined(BOOST_MSVC) && (BOOST_MSVC <= 1300) // <= MSVC 7.1
- template< typename Pool >
- friend class detail::worker::impl_pool;
-# endif
+ template< typename Channel >
+ friend class detail::worker::worker_object< static_pool< Channel > >;
 
         typedef typename channel::item channel_item;
         
@@ -69,10 +67,8 @@
         private:
                 friend class detail::worker;
 
-# if defined(BOOST_MSVC) && (BOOST_MSVC <= 1300) // <= MSVC 7.1
- template< typename Pool >
- friend class detail::worker::impl_pool;
-# endif
+ template< typename Channel >
+ friend class detail::worker::worker_object< static_pool< Channel > >;
 
                 detail::worker_group wg_;
                 shared_mutex mtx_wg_;

Modified: sandbox/task/libs/task/doc/as_sub_task.qbk
==============================================================================
--- sandbox/task/libs/task/doc/as_sub_task.qbk (original)
+++ sandbox/task/libs/task/doc/as_sub_task.qbk 2009-07-07 13:31:05 EDT (Tue, 07 Jul 2009)
@@ -13,11 +13,9 @@
 
 
 ``
- boost::task::task< long > t( fibonacci, 10);
-
         boost::task::handle< long > h(
                 boost::task::async(
- boost::move( t),
+ boost::task::make_task( fibonacci, 10),
                         boost::task::as_sub_task() ) );
 ``
 

Modified: sandbox/task/libs/task/doc/async.qbk
==============================================================================
--- sandbox/task/libs/task/doc/async.qbk (original)
+++ sandbox/task/libs/task/doc/async.qbk 2009-07-07 13:31:05 EDT (Tue, 07 Jul 2009)
@@ -32,15 +32,21 @@
         void main()
         {
                 // task computing fibonacci(10)
- boost::task< long > t( fibonacci, 10);
+ // move the task to executor
+ boost::task::handle< long > h1(
+ boost::task::async(
+ boost::task::make_task( fibonacci, 10) ) );
 
+ // task computing fibonacci(5)
+ boost::task< long > t( fibonacci, 5);
                 // move the task to executor
- boost::task::handle< long > h(
+ boost::task::handle< long > h2(
                         boost::task::async(
- boost::move( t) );
+ boost::move( t) ) );
 
- // access the result
- std::cout << "fibonacci(10) == " << h.get() << std::endl;
+ // access the results
+ std::cout << "fibonacci(10) == " << h1.get() << std::endl;
+ std::cout << "fibonacci(5) == " << h2.get() << std::endl;
         }
 ``
 

Modified: sandbox/task/libs/task/doc/boost_task.qbk
==============================================================================
--- sandbox/task/libs/task/doc/boost_task.qbk (original)
+++ sandbox/task/libs/task/doc/boost_task.qbk 2009-07-07 13:31:05 EDT (Tue, 07 Jul 2009)
@@ -20,6 +20,7 @@
 ]
 
 [def __boost__ [*boost-1.39.0]]
+[def __boost_fiber__ [*Boost.Fiber]]
 [def __boost_task__ [*Boost.Task]]
 [def __boost_thread__ [@http://www.boost.org/libs/thread [*Boost.Thread]]]
 [def __boost_future__ [@http://www.justsoftwaresolutions.co.uk/threading/updated-implementation-of-c++-futures-3.html [*Boost.Future]]]
@@ -74,6 +75,7 @@
 [def __fn_yield__ `boost::this_task::yield()`]
 
 [def __fn_async__ `boost::task::async()`]
+[def __fn_make_task__ `boost::task::make_task()`]
 
 [def __fn_active__ `active()`]
 [def __fn_bind_to_processors__ `bind_to_processors()`]
@@ -128,12 +130,9 @@
 [include overview.qbk]
 [include introduction.qbk]
 [include task.qbk]
-[include handle.qbk]
 [include async.qbk]
-[include own_thread.qbk]
-[include new_thread.qbk]
-[include pool.qbk]
-[include as_sub_task.qbk]
+[include async_completion_token.qbk]
+[include execution_policy.qbk]
 [include utilities.qbk]
 [include meta_functions.qbk]
 [include reference.qbk]

Modified: sandbox/task/libs/task/doc/execution_policy.qbk
==============================================================================
--- sandbox/task/libs/task/doc/execution_policy.qbk (original)
+++ sandbox/task/libs/task/doc/execution_policy.qbk 2009-07-07 13:31:05 EDT (Tue, 07 Jul 2009)
@@ -17,6 +17,7 @@
 [include new_thread.qbk]
 [include pool.qbk]
 [include as_sub_task.qbk]
+[include user_defined_executor.qbk]
 
 
 [endsect]

Modified: sandbox/task/libs/task/doc/fork_join.qbk
==============================================================================
--- sandbox/task/libs/task/doc/fork_join.qbk (original)
+++ sandbox/task/libs/task/doc/fork_join.qbk 2009-07-07 13:31:05 EDT (Tue, 07 Jul 2009)
@@ -26,21 +26,23 @@
                 if ( n < cutof) return serial_fib( n);
                 else
                 {
- // create a sub-task calculating fibonacci(n-1)
- boost::task::task< long > t1(
+ // fork sub-task by moving the task
+ // ownership to the thread-pool
+ // sub-task computes fibonacci(n-1)
+ h1 = boost::task::async(
+ boost::task::make_task(
                                 parallel_fib,
                                 n - 1,
- cutof);
- // create a sub-task calculating fibonacci(n-2)
- boost::task< long > t2(
- parallel_fib,
- n - 2,
- cutof);
+ cutof) );
 
- // fork both sub-tasks by moving the task
+ // fork sub-task by moving the task
                         // ownership to the thread-pool
- h1 = boost::task::async( boost::move( t1) );
- h2 = boost::task::async( boost::move( t2) );
+ // sub-task computes fibonacci(n-2)
+ h2 = boost::task::async(
+ boost::task::make_task(
+ parallel_fib,
+ n - 2,
+ cutof) );
 
                         // join the results of both sub-tasks
                         // if one of the both sub-tasks is not ready

Modified: sandbox/task/libs/task/doc/introduction.qbk
==============================================================================
--- sandbox/task/libs/task/doc/introduction.qbk (original)
+++ sandbox/task/libs/task/doc/introduction.qbk 2009-07-07 13:31:05 EDT (Tue, 07 Jul 2009)
@@ -32,13 +32,10 @@
 
         void main()
         {
- // task, to be executed asynchronously
- boost::task::task< void > t( print, "Hello World!");
-
                 // execute task in newly-created thread
                 // move task ownership to executor
                 boost::task::async(
- boost::move( t),
+ boost::task::make_task( print, "Hello World!"),
                         boost::task::new_thread() ) );
         }
 ``
@@ -52,14 +49,11 @@
 
         void main()
         {
- // task returning the submitted string
- boost::task::task< std::string > t( echo, "Hello World!");
-
                 // execute task in newly-created thread
                 // move task ownership to executor
                 boost::task::handle< std::string > h(
                         boost::task::async(
- boost::move( t),
+ boost::task::make_task( echo, "Hello World!"),
                                 boost::task::new_thread() ) );
 
                 // wait until task has finished and return the result
@@ -75,14 +69,13 @@
 
         void main()
         {
- // create a long runing task
- boost::task::task< void > t( long_running, boost::posix_time::millisec( 500) );
-
                 // execute task in newly-created thread
                 // move task ownership to executor
                 boost::task::handle< std::string > h(
                         boost::task::async(
- boost::move( t),
+ boost::task::make_task(
+ long_running,
+ boost::posix_time::millisec( 500) ),
                                 boost::task::new_thread() ) );
 
                 // requests interruption of task
@@ -110,25 +103,22 @@
                 if ( n < cutof) return serial_fib( n);
                 else
                 {
- // create a sub-task calculating fibonacci(n-1)
- boost::task::task< long > t1(
- parallel_fib,
- n - 1,
- cutof);
- // create a sub-task calculating fibonacci(n-2)
- boost::task::task< long > t2(
- parallel_fib,
- n - 2,
- cutof);
-
- // fork two sub-tasks
+ // fork sub-task calculating fibonacci(n-1)
                         boost::task::handle< long > h1(
                                 boost::task::async(
- boost::move( t1),
+ boost::task::make_task(
+ parallel_fib,
+ n - 1,
+ cutof),
                                         boost::this_task::get_pool() ) );
+
+ // fork sub-task calculating fibonacci(n-2)
                         boost::task::handle< long > h2(
                                 boost::task::async(
- boost::move( t2),
+ boost::task::make_task(
+ parallel_fib,
+ n - 2,
+ cutof),
                                         boost::this_task::get_pool() ) );
 
                         // join the results of both sub-tasks
@@ -145,17 +135,14 @@
>
> pool( boost::task::poolsize( 5) );
 
- // create task computing fibonacci-number for 10
- boost::task::task< long > t(
- parallel_fib,
- 10,
- 5);
-
                 // execute task in a thread-pool
                 // move task ownership to executor
                 boost::task::handle< long > h(
                         boost::task::async(
- boost::move( t),
+ boost::task::make_task(
+ parallel_fib,
+ 10,
+ 5),
                                 pool) );
 
                 // access the result

Added: sandbox/task/libs/task/doc/ref_callable.qbk
==============================================================================
--- (empty file)
+++ sandbox/task/libs/task/doc/ref_callable.qbk 2009-07-07 13:31:05 EDT (Tue, 07 Jul 2009)
@@ -0,0 +1,92 @@
+[/
+ Copyright Oliver Kowalke 2009.
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt
+]
+
+
+[section:callable Class `callable`]
+
+``
+ #include <boost/task/callable.hpp>
+
+ class callable
+ {
+ public:
+ callable();
+
+ void operator()();
+
+ bool empty() const;
+
+ void clear();
+
+ void reset();
+
+ void reset( shared_ptr< thread > const& thrd);
+ };
+``
+
+
+[heading Constructor `callable()`]
+
+ callable()
+
+[variablelist
+[[Effects:] [constructs an empty callable]]
+[[Throws:] [Nothing]]
+]
+
+
+[heading Member function `operator()()`]
+
+ void operator()()
+
+[variablelist
+[[Effects:] [executes the stored task< R >]]
+[[Throws:] [Nothing]]
+]
+
+
+[heading Member function `empty()`]
+
+ bool empty() const
+
+[variablelist
+[[Effects:] [tests if callable contains a task< R >]]
+[[Throws:] [Nothing]]
+]
+
+
+[heading Member function `clear()`]
+
+ void clear()
+
+[variablelist
+[[Effects:] [clears internal task< R >, callable becomes empty]]
+[[Throws:] [Nothing]]
+]
+
+
+[heading Member function `reset()`]
+
+ void reset()
+
+[variablelist
+[[Effects:] [clears internal thrread-context]]
+[[Throws:] [Nothing]]
+]
+
+
+[heading Member function `reset( shared_ptr< thread> const& thrd)`]
+
+ void reset( shared_ptr< thread > const& thrd)
+
+[variablelist
+[[Effects:] [sets internal thread-context]]
+[[Throws:] [Nothing]]
+]
+
+
+[endsect]

Added: sandbox/task/libs/task/doc/ref_context.qbk
==============================================================================
--- (empty file)
+++ sandbox/task/libs/task/doc/ref_context.qbk 2009-07-07 13:31:05 EDT (Tue, 07 Jul 2009)
@@ -0,0 +1,48 @@
+[/
+ Copyright Oliver Kowalke 2009.
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt
+]
+
+
+[section:context Class `context`]
+
+``
+ #include <boost/task/context.hpp>
+
+ class context
+ {
+ public:
+ template< typename R >
+ callable get_callable( task< R > t);
+
+ template< typename R >
+ handle< R > get_handle( shared_future< R > f);
+ };
+``
+
+
+[heading Templated member function `get_callable( task< R > t)`]
+
+ template< typename R >
+ callable get_callable( task< R > t);
+
+[variablelist
+[[Effects:] [returns a callable containing the moved task< R >]]
+[[Throws:] [Nothing]]
+]
+
+
+[heading Templated member function `get_handle( shared_future< R > f)`]
+
+ template< typename R >
+ handle< R > get_handle( shared_future< R > f);
+
+[variablelist
+[[Effects:] [returns a handle associated to the moved task< R >]]
+[[Throws:] [Nothing]]
+]
+
+
+[endsect]

Added: sandbox/task/libs/task/doc/ref_context_guard.qbk
==============================================================================
--- (empty file)
+++ sandbox/task/libs/task/doc/ref_context_guard.qbk 2009-07-07 13:31:05 EDT (Tue, 07 Jul 2009)
@@ -0,0 +1,44 @@
+[/
+ Copyright Oliver Kowalke 2009.
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt
+]
+
+
+[section:context_guard Class `context_guard`]
+
+``
+ #include <boost/task/callable.hpp>
+
+ class context_guard : private noncopyable
+ {
+ public:
+ context_guard( callable & ca, shared_ptr< thread > const& thrd);
+
+ ~context_guard();
+ };
+``
+
+
+[heading Constructor `context_guard()`]
+
+ context_guard( callable & ca, shared_ptr< thread > const& thrd)
+
+[variablelist
+[[Effects:] [sets the thread-context for callable]]
+[[Throws:] [Nothing]]
+]
+
+
+[heading Destructor `~context_guard()`]
+
+ ~context_guard()
+
+[variablelist
+[[Effects:] [removes thread-context for callable]]
+[[Throws:] [Nothing]]
+]
+
+
+[endsect]

Modified: sandbox/task/libs/task/doc/reference.qbk
==============================================================================
--- sandbox/task/libs/task/doc/reference.qbk (original)
+++ sandbox/task/libs/task/doc/reference.qbk 2009-07-07 13:31:05 EDT (Tue, 07 Jul 2009)
@@ -15,6 +15,9 @@
 [include ref_new_thread.qbk]
 [include ref_static_pool.qbk]
 [include ref_as_sub_task.qbk]
+[include ref_context.qbk]
+[include ref_context_guard.qbk]
+[include ref_callable.qbk]
 [include ref_utility.qbk]
 [include ref_meta.qbk]
 [include ref_poolsize.qbk]

Modified: sandbox/task/libs/task/doc/task.qbk
==============================================================================
--- sandbox/task/libs/task/doc/task.qbk (original)
+++ sandbox/task/libs/task/doc/task.qbk 2009-07-07 13:31:05 EDT (Tue, 07 Jul 2009)
@@ -43,7 +43,7 @@
 
 ``
 
-[/
+
 [heading Creation]
 
 __tasks__ are created by passing free-functions or member-functions of objects and its arguments to the task-constructor.
@@ -80,7 +80,19 @@
         Y y;
         boost::task::task< std::string > t( y);
 ``
-]
+
+__fn_make_task__ can be used too in order to create an __task__:
+
+``
+ // task computing fibonacci(10)
+ // move the task to executor
+ boost::task::handle< long > h(
+ boost::task::async(
+ boost::make_task( fibonacci, 10) ) );
+
+``
+
+
 
 [heading Cooperative task and interruption]
 

Modified: sandbox/task/libs/task/doc/todo.qbk
==============================================================================
--- sandbox/task/libs/task/doc/todo.qbk (original)
+++ sandbox/task/libs/task/doc/todo.qbk 2009-07-07 13:31:05 EDT (Tue, 07 Jul 2009)
@@ -39,7 +39,8 @@
 
 [heading Interdepended task]
 
-* With special support of concurrence and synchronisation abstractions interdepended tasks work in __thread_pools__ without deadlocking the pool.
+* With special support of __boost_fiber__ interdepended tasks (using communication and synchronisation abstractions above) work in
+__thread_pools__ without deadlocking the pool.
 
 
 [heading Optimizations]

Added: sandbox/task/libs/task/doc/user_defined_executor.qbk
==============================================================================
--- (empty file)
+++ sandbox/task/libs/task/doc/user_defined_executor.qbk 2009-07-07 13:31:05 EDT (Tue, 07 Jul 2009)
@@ -0,0 +1,78 @@
+[/
+ Copyright Oliver Kowalke 2009.
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt
+]
+
+
+[section:usr_def_executor User-defined execution policy]
+
+It is possible to apply user-defined execution plocies to __fn_async__.
+The policy class has to provide `handle< R > operator()( task< R > t)` which implements following steps:
+
+* get an shared_future< R > from the task< R > (transfer of value or exception)
+
+* create an context (link between handle and task)
+
+* create an handle< R > via context and shared_future< R >
+
+* create a callable via context an the moved task< R >
+
+* pass the callable to the executor
+
+* return the handle
+
+In the sample code below the task is executed in a fiber (__boost_fiber__).
+
+
+``
+ class new_fiber
+ {
+ private:
+ fiber::scheduler & sched_;
+
+ public:
+ new_fiber( fiber::scheduler & sched)
+ : sched_( sched)
+ {}
+
+ template< typename R >
+ handle< R > operator()( task< R > t)
+ {
+ // get shared_future< R > from task< R >
+ shared_future< R > f( t.get_future() );
+
+ // create an context
+ context ctx;
+
+ // create an handle< R > out of the context and the future
+ handle< R > h( ctx.get_handle( f) );
+
+ // create an callable containing the moved task< R >
+ callable ca( ctx.get_callable( boost::move( t) ) );
+
+ // apply the callable to the executor == fiber-scheduler
+ sched_.submit( fiber::fiber( ca) );
+
+ // return the handle
+ return h;
+ }
+ };
+
+
+ void main()
+ {
+ boost::fiber::scheduler sched;
+
+ boost::task::handle< long > h1(
+ boost::task::async(
+ boost::make_task( ... ),
+ sched);
+
+ sched.run();
+ }
+``
+
+[endsect]
+


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk