$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r54565 - in sandbox/task: . boost/task libs/task/doc libs/task/examples libs/task/src libs/task/test
From: oliver.kowalke_at_[hidden]
Date: 2009-07-01 14:53:43
Author: olli
Date: 2009-07-01 14:53:41 EDT (Wed, 01 Jul 2009)
New Revision: 54565
URL: http://svn.boost.org/trac/boost/changeset/54565
Log:
* tests for as_sub_task() added
* make_task() re-introduced
* refernce in docu for as_sub_task() added
* examples modified
* some optimizations (lock_guard instead unique_lock etc.)
Added:
   sandbox/task/libs/task/doc/ref_asy_sub_task.qbk   (contents, props changed)
   sandbox/task/libs/task/test/test_as_sub_task.cpp   (contents, props changed)
Text files modified: 
   sandbox/task/boost/task/as_sub_task.hpp                |     2                                         
   sandbox/task/boost/task/bounded_channel.hpp            |    28 ++++++++++----------                    
   sandbox/task/boost/task/handle.hpp                     |    51 ++++++------------------------------    
   sandbox/task/boost/task/static_pool.hpp                |    24 +++++++----------                       
   sandbox/task/boost/task/task.hpp                       |    55 ++++++++++++++++++++++++++------------- 
   sandbox/task/boost/task/unbounded_channel.hpp          |    16 +++++-----                              
   sandbox/task/change.log                                |     5 +++                                     
   sandbox/task/libs/task/doc/boost_task.qbk              |     1                                         
   sandbox/task/libs/task/doc/ref_async.qbk               |    12 ++++----                                
   sandbox/task/libs/task/doc/ref_new_thread.qbk          |     6 ++--                                    
   sandbox/task/libs/task/doc/ref_own_thread.qbk          |     6 ++--                                    
   sandbox/task/libs/task/doc/ref_static_pool.qbk         |     8 ++--                                    
   sandbox/task/libs/task/doc/ref_task.qbk                |    24 +++++++++++++++++                       
   sandbox/task/libs/task/doc/reference.qbk               |     1                                         
   sandbox/task/libs/task/doc/task.qbk                    |    31 +++++++++++++++++++++                   
   sandbox/task/libs/task/examples/bind_to_processors.cpp |    33 +++++++++++------------                 
   sandbox/task/libs/task/examples/delay.cpp              |    31 ++++++++++-----------                   
   sandbox/task/libs/task/examples/interrupt.cpp          |     6 +--                                     
   sandbox/task/libs/task/examples/pending.cpp            |     6 +--                                     
   sandbox/task/libs/task/examples/reschedule_until.cpp   |    31 ++++++++++------------                  
   sandbox/task/libs/task/src/interrupter.cpp             |     8 ++--                                    
   sandbox/task/libs/task/src/wsq.cpp                     |     4 +-                                      
   sandbox/task/libs/task/test/Jamfile.v2                 |     1                                         
   sandbox/task/libs/task/test/test_task.cpp              |    21 +++++++++++++--                         
   24 files changed, 230 insertions(+), 181 deletions(-)
Modified: sandbox/task/boost/task/as_sub_task.hpp
==============================================================================
--- sandbox/task/boost/task/as_sub_task.hpp	(original)
+++ sandbox/task/boost/task/as_sub_task.hpp	2009-07-01 14:53:41 EDT (Wed, 01 Jul 2009)
@@ -46,7 +46,7 @@
                         return handle< R >( fut, intr);
                 }
                 else
-			return new_thread()( t);
+			return new_thread()( boost::move( t) );
         }
 };
 } }
Modified: sandbox/task/boost/task/bounded_channel.hpp
==============================================================================
--- sandbox/task/boost/task/bounded_channel.hpp	(original)
+++ sandbox/task/boost/task/bounded_channel.hpp	2009-07-01 14:53:41 EDT (Wed, 01 Jul 2009)
@@ -273,19 +273,19 @@
 
         bool active()
         {
-		shared_lock< shared_mutex > lk( mtx_);
+		lock_guard< shared_mutex > lk( mtx_);
                 return active_();
         }
 
         void activate()
         {
-		unique_lock< shared_mutex > lk( mtx_);
+		lock_guard< shared_mutex > lk( mtx_);
                 activate_();
         }
 
         void clear()
         {
-		unique_lock< shared_mutex > lk( mtx_);
+		lock_guard< shared_mutex > lk( mtx_);
                 clear_();
         }
 
@@ -294,61 +294,61 @@
 
         void deactivate()
         {
-		unique_lock< shared_mutex > lk( mtx_);
+		lock_guard< shared_mutex > lk( mtx_);
                 deactivate_();
         }
 
         void deactivate_now()
         {
-		unique_lock< shared_mutex > lk( mtx_);
+		lock_guard< shared_mutex > lk( mtx_);
                 deactivate_now_();
         }
 
         const std::vector< detail::callable > drain()
         {
-		unique_lock< shared_mutex > lk( mtx_);
+		lock_guard< shared_mutex > lk( mtx_);
                 return drain_();
         }
 
         bool empty()
         { 
-		shared_lock< shared_mutex > lk( mtx_);
+		lock_guard< shared_mutex > lk( mtx_);
                 return empty_();
         }
 
         bool full()
         {
-		shared_lock< shared_mutex > lk( mtx_);
+		lock_guard< shared_mutex > lk( mtx_);
                 return full_();
         }
 
         std::size_t upper_bound()
         {
-		shared_lock< shared_mutex > lk( mtx_);
+		lock_guard< shared_mutex > lk( mtx_);
                 return hwm_;
         }
 
         void upper_bound( std::size_t hwm)
         {
-		unique_lock< shared_mutex > lk( mtx_);
+		lock_guard< shared_mutex > lk( mtx_);
                 upper_bound_( hwm);
         }
 
         std::size_t lower_bound()
         {
-		shared_lock< shared_mutex > lk( mtx_);
+		lock_guard< shared_mutex > lk( mtx_);
                 return lwm_;
         }
 
         void lower_bound( std::size_t lwm)
         {
-		unique_lock< shared_mutex > lk( mtx_);
+		lock_guard< shared_mutex > lk( mtx_);
                 lower_bound_( lwm);
         }
 
         std::size_t size()
         { 
-		shared_lock< shared_mutex > lk( mtx_);
+		lock_guard< shared_mutex > lk( mtx_);
                 return size_();
         }
 
@@ -384,7 +384,7 @@
 
         bool try_take( detail::callable & ca)
         {
-		unique_lock< shared_mutex > lk( mtx_);
+		lock_guard< shared_mutex > lk( mtx_);
                 return try_take_( ca);
         }
 };
Modified: sandbox/task/boost/task/handle.hpp
==============================================================================
--- sandbox/task/boost/task/handle.hpp	(original)
+++ sandbox/task/boost/task/handle.hpp	2009-07-01 14:53:41 EDT (Wed, 01 Jul 2009)
@@ -19,46 +19,18 @@
 namespace boost { namespace task
 {
 
-template< typename Channel >
-class static_pool;
-
-struct own_thread;
-struct new_thread;
-struct as_sub_task;
-
 template< typename R >
 class handle
 {
 private:
-	template< typename Channel >
-	friend class static_pool;
-	friend struct own_thread;
-	friend struct new_thread;
-	friend struct as_sub_task;
-	template< typename Iterator >
-	friend void waitfor_all( Iterator begin, Iterator end);
-	template< typename T1, typename T2 >
-	friend void waitfor_all( T1 & t1, T2 & t2);
-	template< typename T1, typename T2, typename T3 >
-	friend void waitfor_all( handle< T1 > & t1, handle< T2 > & t2, handle< T3 > & t3);
-	template< typename T1, typename T2, typename T3, typename T4 >
-	friend void waitfor_all( handle< T1 > & t1, handle< T2 > & t2, handle< T3 > & t3, handle< T4 > & t4);
-	template< typename T1, typename T2, typename T3, typename T4, typename T5 >
-	friend void waitfor_all( handle< T1 > & t1, handle< T2 > & t2, handle< T3 > & t3, handle< T4 > & t4, handle< T5 > & t5);
-	template< typename Iterator >
-	friend Iterator waitfor_any( Iterator begin, Iterator end);
-	template< typename T1, typename T2 >
-	friend unsigned int waitfor_any( handle< T1 > & t1, handle< T2 > & t2);
-	template< typename T1, typename T2, typename T3 >
-	friend unsigned int waitfor_any( handle< T1 > & t1, handle< T2 > & t2, handle< T3 > & t3);
-	template< typename T1, typename T2, typename T3, typename T4 >
-	friend unsigned int waitfor_any( handle< T1 > & t1, handle< T2 > & t2, handle< T3 > & t3, handle< T4 > & t4);
-	template< typename T1, typename T2, typename T3, typename T4, typename T5 >
-	friend unsigned int waitfor_any( handle< T1 > & t1, handle< T2 > & t2, handle< T3 > & t3, handle< T4 > & t4, handle< T5 > & t5);
-
         shared_future< R >		fut_;
         detail::interrupter		intr_;
 
+public:
+	handle()
+	: fut_(), intr_()
+	{}
+
         handle( shared_future< R > fut)
         :
         fut_( fut),
@@ -73,11 +45,6 @@
         intr_( intr)
         {}
 
-public:
-	handle()
-	: fut_(), intr_()
-	{}
-
         void interrupt()
         { intr_.interrupt(); }
 
@@ -237,7 +204,7 @@
 unsigned int waitfor_any( handle< T1 > & t1, handle< T2 > & t2)
 {
         try
-	{ return wait_for_any( t1.fut_, t2.fut_); }
+	{ return wait_for_any( t1.get_future(), t2.get_future() ); }
         catch ( thread_interrupted const&)
         { throw task_interrupted(); }
 }
@@ -246,7 +213,7 @@
 unsigned int waitfor_any( handle< T1 > & t1, handle< T2 > & t2, handle< T3 > & t3)
 {
         try
-	{ return wait_for_any( t1.fut_, t2.fut_, t3.fut_); }
+	{ return wait_for_any( t1.get_future(), t2.get_future(), t3.get_future() ); }
         catch ( thread_interrupted const&)
         { throw task_interrupted(); }
 }
@@ -255,7 +222,7 @@
 unsigned int waitfor_any( handle< T1 > & t1, handle< T2 > & t2, handle< T3 > & t3, handle< T4 > & t4)
 {
         try
-	{ return wait_for_any( t1.fut_, t2.fut_, t3.fut_, t4.fut_); }
+	{ return wait_for_any( t1.get_future(), t2.get_future(), t3.get_future(), t4.get_future() ); }
         catch ( thread_interrupted const&)
         { throw task_interrupted(); }
 }
@@ -264,7 +231,7 @@
 unsigned int waitfor_any( handle< T1 > & t1, handle< T2 > & t2, handle< T3 > & t3, handle< T4 > & t4, handle< T5 > & t5)
 {
         try
-	{ return wait_for_any( t1.fut_, t2.fut_, t3.fut_, t4.fut_, t5.fut_); }
+	{ return wait_for_any( t1.get_future(), t2.get_future(), t3.get_future(), t4.get_future(), t5.get_future() ); }
         catch ( thread_interrupted const&)
         { throw task_interrupted(); }
 }
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-01 14:53:41 EDT (Wed, 01 Jul 2009)
@@ -53,7 +53,7 @@
 
         friend class detail::worker;
 
-# if defined(BOOST_MSVC) && (BOOST_MSVC < 1500) // < MSVC 9.0
+# if defined(BOOST_MSVC) && (BOOST_MSVC <= 1300) // <= MSVC 7.1
         template< typename Pool >
         friend class detail::worker::impl_pool;
 # endif
@@ -69,7 +69,7 @@
         private:
                 friend class detail::worker;
 
-# if defined(BOOST_MSVC) && (BOOST_MSVC < 1500) // < MSVC 9.0
+# if defined(BOOST_MSVC) && (BOOST_MSVC <= 1300) // <= MSVC 7.1
                 template< typename Pool >
                 friend class detail::worker::impl_pool;
 # endif
@@ -146,8 +146,8 @@
                 bool closed_() const
                 { return state_ > 0; }
 
-		unsigned int close_()
-		{ return detail::atomic_fetch_add( & state_, 1); }
+		bool close_()
+		{ return detail::atomic_fetch_add( & state_, 1) > 1; }
 
         public:
                 explicit pool_base(
@@ -165,10 +165,9 @@
                         if ( asleep.is_special() || asleep.is_negative() )
                                 throw invalid_timeduration();
                         channel_.activate();
-			unique_lock< shared_mutex > lk( mtx_wg_);
+			lock_guard< shared_mutex > lk( mtx_wg_);
                         for ( std::size_t i( 0); i < psize; ++i)
                                 create_worker_( psize, asleep, max_scns);
-			lk.unlock();
                 }
 
                 explicit pool_base(
@@ -190,10 +189,9 @@
                         if ( asleep.is_special() || asleep.is_negative() )
                                 throw invalid_timeduration();
                         channel_.activate();
-			unique_lock< shared_mutex > lk( mtx_wg_);
+			lock_guard< shared_mutex > lk( mtx_wg_);
                         for ( std::size_t i( 0); i < psize; ++i)
                                 create_worker_( psize, asleep, max_scns);
-			lk.unlock();
                 }
 
 # if defined(BOOST_HAS_PROCESSOR_BINDINGS)
@@ -213,10 +211,9 @@
                         poolsize psize( thread::hardware_concurrency() );
                         BOOST_ASSERT( psize > 0);
                         channel_.activate();
-			unique_lock< shared_mutex > lk( mtx_wg_);
+			lock_guard< shared_mutex > lk( mtx_wg_);
                         for ( std::size_t i( 0); i < psize; ++i)
                                 create_worker_( psize, asleep, max_scns, i);
-			lk.unlock();
                 }
 
                 explicit pool_base(
@@ -239,10 +236,9 @@
                         poolsize psize( thread::hardware_concurrency() );
                         BOOST_ASSERT( psize > 0);
                         channel_.activate();
-			unique_lock< shared_mutex > lk( mtx_wg_);
+			lock_guard< shared_mutex > lk( mtx_wg_);
                         for ( std::size_t i( 0); i < psize; ++i)
                                 create_worker_( psize, asleep, max_scns, i);
-			lk.unlock();
                 }
 # endif
 
@@ -271,7 +267,7 @@
 
                 void shutdown()
                 {
-			if ( closed_() || close_() > 1) return;
+			if ( closed_() || close_() ) return;
 
                         channel_.deactivate();
                         shared_lock< shared_mutex > lk( mtx_wg_);
@@ -281,7 +277,7 @@
 
                 const void shutdown_now()
                 {
-			if ( closed_() || close_() > 1) return;
+			if ( closed_() || close_() ) return;
 
                         channel_.deactivate_now();
                         shared_lock< shared_mutex > lk( mtx_wg_);
Modified: sandbox/task/boost/task/task.hpp
==============================================================================
--- sandbox/task/boost/task/task.hpp	(original)
+++ sandbox/task/boost/task/task.hpp	2009-07-01 14:53:41 EDT (Wed, 01 Jul 2009)
@@ -255,31 +255,28 @@
         }
 # endif
 
-# ifndef BOOST_TASK_MAKE_TASK_MAX_ARITY
-#   define BOOST_TASK_MAKE_TASK_MAX_ARITY 10
+# ifndef BOOST_TASK_MAX_ARITY
+#   define BOOST_TASK_MAX_ARITY 10
 # endif
 
-# define BOOST_TASK_MAKE_TASK_FUNC_ARG(z, n, unused) \
+# define BOOST_TASK_ARG(z, n, unused) \
    BOOST_PP_CAT(A, n) BOOST_PP_CAT(a, n)
-# define BOOST_ENUM_TASK_MAKE_TASK_FUNC_ARGS(n) BOOST_PP_ENUM(n, BOOST_TASK_MAKE_TASK_FUNC_ARG, ~)
+# define BOOST_ENUM_TASK_ARGS(n) BOOST_PP_ENUM(n, BOOST_TASK_ARG, ~)
 
-# define BOOST_TASK_MAKE_TASK_FUNCTION(z, n, unused)	\
-template<												\
-	typename Fn,										\
-	BOOST_PP_ENUM_PARAMS(n, typename A)					\
->														\
-explicit task( Fn fn, BOOST_ENUM_TASK_MAKE_TASK_FUNC_ARGS(n))	\
-	: task_( new detail::task_wrapper<							\
-			typename result_of< Fn( BOOST_PP_ENUM_PARAMS(n, A)) >::type,	\
-			function< typename result_of< Fn( BOOST_PP_ENUM_PARAMS(n, A)) >::type() >	\
-		>( bind( fn, BOOST_PP_ENUM_PARAMS(n, a)) ) )	\
+# define BOOST_TASK_CTOR(z, n, unused)	\
+template<								\
+	typename Fn,						\
+	BOOST_PP_ENUM_PARAMS(n, typename A)	\
+>										\
+explicit task( Fn fn, BOOST_ENUM_TASK_ARGS(n))	\
+	: task_(									\
+			new detail::task_wrapper< R, function< R() > >(	\
+				bind( fn, BOOST_PP_ENUM_PARAMS(n, a)) ) )	\
         {}
 
-BOOST_PP_REPEAT_FROM_TO( 1, BOOST_TASK_MAKE_TASK_MAX_ARITY, BOOST_TASK_MAKE_TASK_FUNCTION, ~)
+BOOST_PP_REPEAT_FROM_TO( 1, BOOST_TASK_MAX_ARITY, BOOST_TASK_CTOR, ~)
 
-# undef BOOST_TASK_MAKE_TASK_FUNCTION
-# undef BOOST_TASK_MAKE_TASK_FUNC_ARG
-# undef BOOST_ENUM_TASK_MAKE_TASK_FUNC_ARGS
+# undef BOOST_TASK_CTOR
 
         unique_future< R > get_future()
         {
@@ -314,6 +311,27 @@
         void swap( task & other) // throw()
         { task_.swap( other.task_); }
 };
+
+template< typename Fn >
+task< typename result_of< Fn() >::type > make_task( Fn fn)
+{ return task< typename boost::result_of< Fn() >::type >( fn); }
+
+# define BOOST_TASK_MAKE_TASK_FUNCTION(z, n, unused)	\
+template<												\
+	typename Fn,										\
+	BOOST_PP_ENUM_PARAMS(n, typename A)					\
+>														\
+task< typename result_of< Fn( BOOST_PP_ENUM_PARAMS(n, A)) >::type >		\
+make_task( Fn fn, BOOST_ENUM_TASK_ARGS(n))				\
+{ return task< typename result_of< Fn( BOOST_PP_ENUM_PARAMS(n, A)) >::type >( fn, BOOST_PP_ENUM_PARAMS(n, a)); }
+
+BOOST_PP_REPEAT_FROM_TO( 1, BOOST_TASK_MAX_ARITY, BOOST_TASK_MAKE_TASK_FUNCTION, ~)
+
+# undef BOOST_TASK_MAKE_TASK_FUNCTION
+# undef BOOST_ENUM_TASK_ARGS
+# undef BOOST_TASK_ARG
+# undef BOOST_TASK_MAX_ARITY
+
 }
 
 template< typename R >
@@ -329,6 +347,7 @@
 task::task< R > move( boost::detail::thread_move_t< task::task< R > > t)
 { return task::task< R >( t); }
 # endif
+
 }
 
 #include <boost/config/abi_suffix.hpp>
Modified: sandbox/task/boost/task/unbounded_channel.hpp
==============================================================================
--- sandbox/task/boost/task/unbounded_channel.hpp	(original)
+++ sandbox/task/boost/task/unbounded_channel.hpp	2009-07-01 14:53:41 EDT (Wed, 01 Jul 2009)
@@ -192,13 +192,13 @@
 
         void activate()
         {
-		unique_lock< shared_mutex > lk( mtx_);
+		lock_guard< shared_mutex > lk( mtx_);
                 activate_();
         }
 
         void clear()
         {
-		unique_lock< shared_mutex > lk( mtx_);
+		lock_guard< shared_mutex > lk( mtx_);
                 clear_();
         }
 
@@ -207,25 +207,25 @@
 
         void deactivate()
         {
-		unique_lock< shared_mutex > lk( mtx_);
+		lock_guard< shared_mutex > lk( mtx_);
                 deactivate_();
         }
 
         void deactivate_now()
         {
-		unique_lock< shared_mutex > lk( mtx_);
+		lock_guard< shared_mutex > lk( mtx_);
                 deactivate_now_();
         }
 
         const std::vector< detail::callable > drain()
         {
-		unique_lock< shared_mutex > lk( mtx_);
+		lock_guard< shared_mutex > lk( mtx_);
                 return drain_();
         }
 
         bool empty()
         { 
-		shared_lock< shared_mutex > lk( mtx_);
+		lock_guard< shared_mutex > lk( mtx_);
                 return empty_();
         }
 
@@ -234,7 +234,7 @@
 
         std::size_t size()
         { 
-		shared_lock< shared_mutex > lk( mtx_);
+		lock_guard< shared_mutex > lk( mtx_);
                 return size_();
         }
 
@@ -270,7 +270,7 @@
 
         bool try_take( detail::callable & ca)
         {
-		unique_lock< shared_mutex > lk( mtx_);
+		lock_guard< shared_mutex > lk( mtx_);
                 return try_take_( ca);
         }
 };
Modified: sandbox/task/change.log
==============================================================================
--- sandbox/task/change.log	(original)
+++ sandbox/task/change.log	2009-07-01 14:53:41 EDT (Wed, 01 Jul 2009)
@@ -5,6 +5,11 @@
   allowing correct move-semantics
 - worker_group removes all worker-threads in join_all()
   static_pool< R > does contain zero worker-threads after shutdown() or shutdown_now()
+- reintroduction of make_task()
+- internal refactoring/rework
+- documentation updated
+- tests updated
+- examples updated
 
 
 * boost.task-0.2.1:
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-01 14:53:41 EDT (Wed, 01 Jul 2009)
@@ -59,6 +59,7 @@
 [def __task_interrupted__ `boost::task::task_interrupted`]
 [def __unbounded_channel__ `boost::task::unbounded_channel`]
 
+[def __make_task__ `boost::task::make_task()`]
 [def __waitfor_all__ `boost::task::waitfor_all()`]
 [def __waitfor_any__ `boost::task::waitfor_any()`]
 
Added: sandbox/task/libs/task/doc/ref_asy_sub_task.qbk
==============================================================================
--- (empty file)
+++ sandbox/task/libs/task/doc/ref_asy_sub_task.qbk	2009-07-01 14:53:41 EDT (Wed, 01 Jul 2009)
@@ -0,0 +1,32 @@
+[/
+          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:as_sub_task Class `as_sub_task`]
+
+``
+	#include <boost/task/as_sub_task.hpp>
+
+	struct as_sub_task
+	{
+		template< typename R >
+		handle< R > operator()( task< R >);
+	};
+``
+
+[heading Member function `operator()( task< R >)`]
+
+	template< typename R >
+	handle< R > operator()( task< R > t)
+
+[variablelist
+[[Effects:] [moves task in a new thread or thread-pool and returns an handle associated with the task]]
+[[Throws:] [`boost::thread_resource_error`]]
+]
+
+
+[endsect]
\ No newline at end of file
Modified: sandbox/task/libs/task/doc/ref_async.qbk
==============================================================================
--- sandbox/task/libs/task/doc/ref_async.qbk	(original)
+++ sandbox/task/libs/task/doc/ref_async.qbk	2009-07-01 14:53:41 EDT (Wed, 01 Jul 2009)
@@ -6,13 +6,13 @@
 ]
 
 
-[section:async Non-member function `async( task< R > &&, EP)`]
+[section:async Non-member function `async( task< R >, EP)`]
 
 ``
         #include <boost/task/async.hpp>
 
         template< typename R, typename EP >
-	handle< R > async( task< R > && t, EP ep);
+	handle< R > async( task< R > t, EP ep);
 ``
 
 [variablelist
@@ -23,13 +23,13 @@
 [endsect]
 
 
-[section:async1 Non-member function `async( task< R > &&, pool< Channel > &)`]
+[section:async1 Non-member function `async( task< R >, pool< Channel > &)`]
 
 ``
         #include <boost/task/async.hpp>
 
         template< typename R, typename Channel >
-	handle< R > async( task< R > && t, pool< Channel > & ep);
+	handle< R > async( task< R > t, pool< Channel > & ep);
 ``
 
 [variablelist
@@ -40,13 +40,13 @@
 [endsect]
 
 
-[section:async2 Non-member function `async( task< R > &&, Attr, pool< Channel > &)`]
+[section:async2 Non-member function `async( task< R >, Attr, pool< Channel > &)`]
 
 ``
         #include <boost/task/async.hpp>
 
         template< typename R, typename Channel, typename Attr >
-	handle< R > async( task< R > && t, Attr attr, pool< Channel > & ep);
+	handle< R > async( task< R > t, Attr attr, pool< Channel > & ep);
 ``
 
 [variablelist
Modified: sandbox/task/libs/task/doc/ref_new_thread.qbk
==============================================================================
--- sandbox/task/libs/task/doc/ref_new_thread.qbk	(original)
+++ sandbox/task/libs/task/doc/ref_new_thread.qbk	2009-07-01 14:53:41 EDT (Wed, 01 Jul 2009)
@@ -14,14 +14,14 @@
         struct new_thread
         {
                 template< typename R >
-		handle< R > operator()( task< R > &&);
+		handle< R > operator()( task< R >);
         };
 ``
 
-[heading Member function `operator()( task< R > &&)`]
+[heading Member function `operator()( task< R >)`]
 
         template< typename R >
-	handle< R > operator()( task< R > && t)
+	handle< R > operator()( task< R > t)
 
 [variablelist
 [[Effects:] [moves task in a new thread an returns an handle associated with the task]]
Modified: sandbox/task/libs/task/doc/ref_own_thread.qbk
==============================================================================
--- sandbox/task/libs/task/doc/ref_own_thread.qbk	(original)
+++ sandbox/task/libs/task/doc/ref_own_thread.qbk	2009-07-01 14:53:41 EDT (Wed, 01 Jul 2009)
@@ -14,14 +14,14 @@
         struct own_thread
         {
                 template< typename R >
-		handle< R > operator()( task< R > && t);
+		handle< R > operator()( task< R > t);
         };
 ``
 
-[heading Member function `operator()( task< R > &&)`]
+[heading Member function `operator()( task< R >)`]
 
         template< typename R >
-	handle< R > operator()( task< R > && t)
+	handle< R > operator()( task< R > t)
 
 [variablelist
 [[Effects:] [moves task in the current thread an returns an handle associated with the task]]
Modified: sandbox/task/libs/task/doc/ref_static_pool.qbk
==============================================================================
--- sandbox/task/libs/task/doc/ref_static_pool.qbk	(original)
+++ sandbox/task/libs/task/doc/ref_static_pool.qbk	2009-07-01 14:53:41 EDT (Wed, 01 Jul 2009)
@@ -348,10 +348,10 @@
 ]
 
 
-[heading Member function `submit( task< R > &&)`]
+[heading Member function `submit( task< R >)`]
 
         template< typename R >
-	handle< R > submit( task< R > && t)
+	handle< R > submit( task< R > t)
 
 [variablelist
 [[Preconditions:] [has_attribute< pool >::value == false && ! closed()]]
@@ -360,10 +360,10 @@
 ]
 
 
-[heading Member function `submit( task< R > &&, Attr const& attr)`]
+[heading Member function `submit( task< R >, Attr const& attr)`]
 
         template< typename R, typename Attr >
-	handle< R > submit( task< R > && t, Attr const& attr)
+	handle< R > submit( task< R > t, Attr const& attr)
 
 [variablelist
 [[Preconditions:] [has_attribute< pool >::value == true && ! closed()]]
Modified: sandbox/task/libs/task/doc/ref_task.qbk
==============================================================================
--- sandbox/task/libs/task/doc/ref_task.qbk	(original)
+++ sandbox/task/libs/task/doc/ref_task.qbk	2009-07-01 14:53:41 EDT (Wed, 01 Jul 2009)
@@ -43,6 +43,14 @@
                 operator unspecified_bool_type() const;
                 bool operator!() const;
         };
+
+	template< typename Fn >
+	task< R > make_task( Fn fn);
+	template< typename Fn, typename A0 >
+	task< R > make_task( Fn fn, A0 a0);
+	template< typename Fn, typename A0, typename A1 >
+	task< R > make_task( Fn fn, A0 a0, A1 a1);
+	...
 ``
 
 [heading Default constructor]
@@ -181,4 +189,20 @@
 ]
 
 
+[heading Non-member function `make_task()`]
+
+	template< typename Fn >
+	task< R > make_task( Fn fn);
+	template< typename Fn, typename A0 >
+	task< R > make_task( Fn fn, A0 a0);
+	template< typename Fn, typename A0, typename A1 >
+	task< R > make_task( Fn fn, A0 a0, A1 a1);
+	...
+
+[variablelist
+[[Effects:] [constructs a `boost::task::task< R >` from a function object and its arguments]]
+[[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-01 14:53:41 EDT (Wed, 01 Jul 2009)
@@ -14,6 +14,7 @@
 [include ref_own_thread.qbk]
 [include ref_new_thread.qbk]
 [include ref_static_pool.qbk]
+[include ref_as_sub_task.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-01 14:53:41 EDT (Wed, 01 Jul 2009)
@@ -12,7 +12,36 @@
 
 __task__ represents a __callable__ (provides __fn_operator__) object containing the unit of code to be execute by a __ep__.
 Function __fn_get_future__ returns a __act__ allowing to wait for the completion of the computation of the task, for
-getting the result of a computation or for transfering exceptions. __task__ supports move semantics (moving ownership).
+getting the result of a computation or for transfering exceptions.
+
+__task__ supports move semantics (moving ownership).
+
+``
+	boost::task::task< int > t1( parallel_fib, 10);
+	boost::task::task< int > t2;
+	t2 = boost::move( t1);
+``
+
+__boost_task__ provides the helper function __make_task__ in order to create __task__.
+
+``
+	void echo( std::string const& msg)
+	{ fprintf( stderr, "%s\n", msg.c_str() ); }
+
+	void main()
+	{
+		// execute task asynchron
+		// move task ownership to executor
+		boost::task::handle< void > h(
+			boost::task::async(
+				boost::task::make_task( echo, "hello world"),
+				boost::task::new_thread() ) );
+
+		// wait for task completion
+		std::cout << h.wait() << std::endl;
+	}
+
+``
 
 [/
 [heading Creation]
Modified: sandbox/task/libs/task/examples/bind_to_processors.cpp
==============================================================================
--- sandbox/task/libs/task/examples/bind_to_processors.cpp	(original)
+++ sandbox/task/libs/task/examples/bind_to_processors.cpp	2009-07-01 14:53:41 EDT (Wed, 01 Jul 2009)
@@ -37,18 +37,20 @@
         else
         {
                 BOOST_ASSERT( boost::this_task::runs_in_pool() );
-		tsk::task< int > t1(
-			parallel_fib,
-			n - 1,
-			cutof);
-		tsk::task< int > t2(
-			parallel_fib,
-			n - 2,
-			cutof);
                 tsk::handle< int > h1(
-			tsk::async( boost::move( t1), tsk::as_sub_task() ) );
+			tsk::async(
+				tsk::make_task(
+					parallel_fib,
+					n - 1,
+					cutof),
+				tsk::as_sub_task() ) );
                 tsk::handle< int > h2(
-			tsk::async( boost::move( t2), tsk::as_sub_task() ) );
+			tsk::async(
+				tsk::make_task(
+					parallel_fib,
+					n - 2,
+					cutof),
+				tsk::as_sub_task() ) );
                 return h1.get() + h2.get();
         }
 }
@@ -64,16 +66,13 @@
                 results.reserve( 10);
 
                 for ( int i = 0; i < 10; ++i)
-		{
-			tsk::task< int > t(
-				parallel_fib,
-				i,
-				5);
                         results.push_back(
                                 tsk::async(
-					boost::move( t),
+					tsk::make_task(
+						parallel_fib,
+						i,
+						5),
                                         pool) );
-		}
 
                 tsk::waitfor_all( results.begin(), results.end() );
 
Modified: sandbox/task/libs/task/examples/delay.cpp
==============================================================================
--- sandbox/task/libs/task/examples/delay.cpp	(original)
+++ sandbox/task/libs/task/examples/delay.cpp	2009-07-01 14:53:41 EDT (Wed, 01 Jul 2009)
@@ -38,18 +38,20 @@
         else
         {
                 BOOST_ASSERT( boost::this_task::runs_in_pool() );
-		tsk::task< int > t1(
-			parallel_fib_,
-			n - 1,
-			cutof);
-		tsk::task< int > t2(
-			parallel_fib_,
-			n - 2,
-			cutof);
                 tsk::handle< int > h1(
-			tsk::async( boost::move( t1), tsk::as_sub_task() ) );
+			tsk::async(
+				tsk::make_task(
+					parallel_fib_,
+					n - 1,
+					cutof),
+				tsk::as_sub_task() ) );
                 tsk::handle< int > h2(
-			tsk::async( boost::move( t2), tsk::as_sub_task() ) );
+			tsk::async(
+				tsk::make_task(
+					parallel_fib_,
+					n - 2,
+					cutof),
+				tsk::as_sub_task() ) );
                 return h1.get() + h2.get();
         }
 }
@@ -67,14 +69,11 @@
                 pool_type pool( tsk::poolsize( 5) );
                 
                 for ( int i = 0; i < 10; ++i)
-		{
-			tsk::task< void > t(
-				& parallel_fib,
-				i);
                         tsk::async(
-				boost::move( t),
+				tsk::make_task(
+					parallel_fib,
+					i),
                                 pool);
-		}
 
                 return EXIT_SUCCESS;
         }
Modified: sandbox/task/libs/task/examples/interrupt.cpp
==============================================================================
--- sandbox/task/libs/task/examples/interrupt.cpp	(original)
+++ sandbox/task/libs/task/examples/interrupt.cpp	2009-07-01 14:53:41 EDT (Wed, 01 Jul 2009)
@@ -46,17 +46,15 @@
         {
                 pool_type pool( tsk::poolsize( 5) );
                 
-		tsk::task< void > t1( long_running_fn);
-		tsk::task< int > t2( fibonacci_fn, 10);
                 tsk::async(
-			boost::move( t1),
+			tsk::make_task( long_running_fn),
                         pool);
                 std::cout << "poolsize == " << pool.size() << std::endl;
                 std::cout << "idle threads == " << pool.idle() << std::endl;
                 std::cout << "active threads == " << pool.active() << std::endl;
                 tsk::handle< int > h(
                         tsk::async(
-				boost::move( t2),
+				tsk::make_task( fibonacci_fn, 10),
                                 pool) );
                 h.interrupt();
                 std::cout << h.get() << std::endl;
Modified: sandbox/task/libs/task/examples/pending.cpp
==============================================================================
--- sandbox/task/libs/task/examples/pending.cpp	(original)
+++ sandbox/task/libs/task/examples/pending.cpp	2009-07-01 14:53:41 EDT (Wed, 01 Jul 2009)
@@ -47,14 +47,12 @@
         {
                 pool_type pool( tsk::poolsize( 5) );
 
-		tsk::task< void > t1( long_running_fn);
                 tsk::async(
-			boost::move( t1),
+			tsk::make_task( long_running_fn),
                         pool);
-		tsk::task< int > t2( fibonacci_fn, 10);
                 tsk::handle< int > h(
                         tsk::async(
-				boost::move( t2),
+				tsk::make_task( fibonacci_fn, 10),
                                 pool) );
                 std::cout << "pending tasks == " << pool.pending() << std::endl;
                 std::cout << h.get() << std::endl;
Modified: sandbox/task/libs/task/examples/reschedule_until.cpp
==============================================================================
--- sandbox/task/libs/task/examples/reschedule_until.cpp	(original)
+++ sandbox/task/libs/task/examples/reschedule_until.cpp	2009-07-01 14:53:41 EDT (Wed, 01 Jul 2009)
@@ -57,18 +57,20 @@
         else
         {
                 BOOST_ASSERT( boost::this_task::runs_in_pool() );
-		tsk::task< int > t1(
-			parallel_fib_,
-			n - 1,
-			cutof);
-		tsk::task< int > t2(
-			parallel_fib_,
-			n - 2,
-			cutof);
                 tsk::handle< int > h1(
-			tsk::async( boost::move( t1), tsk::as_sub_task() ) );
+			tsk::async(
+				tsk::make_task(
+					parallel_fib_,
+					n - 1,
+					cutof),
+				tsk::as_sub_task() ) );
                 tsk::handle< int > h2(
-			tsk::async( boost::move( t2), tsk::as_sub_task() ) );
+			tsk::async(
+				tsk::make_task(
+					parallel_fib_,
+					n - 2,
+					cutof),
+				tsk::as_sub_task() ) );
                 return h1.get() + h2.get();
         }
 }
@@ -149,22 +151,17 @@
                 int fd[2];
                 create_sockets( fd);
 
-		tsk::task< void > t1( do_read, fd[0]);
-
                 tsk::async(
-			boost::move( t1),
+			tsk::make_task( do_read, fd[0]),
                         pool);
 
                 do_write( fd[1], "Hello ");
                 boost::this_thread::sleep( pt::seconds( 1) );
 
                 for ( int i = 0; i < 10; ++i)
-		{
-			tsk::task< void > t( parallel_fib, i);
                         tsk::async(
-				boost::move( t),
+				tsk::make_task( parallel_fib, i),
                                 pool);
-		}
 
                 do_write( fd[1], "World!");
 
Modified: sandbox/task/libs/task/src/interrupter.cpp
==============================================================================
--- sandbox/task/libs/task/src/interrupter.cpp	(original)
+++ sandbox/task/libs/task/src/interrupter.cpp	2009-07-01 14:53:41 EDT (Wed, 01 Jul 2009)
@@ -52,28 +52,28 @@
 void
 interrupter::impl::set( shared_ptr< thread > const& thrd)
 {
-	unique_lock< mutex > lk( mtx_);
+	lock_guard< mutex > lk( mtx_);
         set_( thrd);
 }
 
 void
 interrupter::impl::reset()
 {
-	unique_lock< mutex > lk( mtx_);
+	lock_guard< mutex > lk( mtx_);
         reset_();
 }
 
 void
 interrupter::impl::interrupt()
 {
-	unique_lock< mutex > lk( mtx_);
+	lock_guard< mutex > lk( mtx_);
         interrupt_();
 }
 
 bool
 interrupter::impl::interruption_requested()
 {
-	unique_lock< mutex > lk( mtx_);
+	lock_guard< mutex > lk( mtx_);
         return interruption_requested_;
 }
 
Modified: sandbox/task/libs/task/src/wsq.cpp
==============================================================================
--- sandbox/task/libs/task/src/wsq.cpp	(original)
+++ sandbox/task/libs/task/src/wsq.cpp	2009-07-01 14:53:41 EDT (Wed, 01 Jul 2009)
@@ -44,7 +44,7 @@
         }
         else
         {
-		unique_lock< recursive_mutex > lk( mtx_);
+		lock_guard< recursive_mutex > lk( mtx_);
                 uint32_t head( head_idx_);
                 int count( size() );
 
@@ -79,7 +79,7 @@
         }
         else
         {
-		unique_lock< recursive_mutex > lk( mtx_);
+		lock_guard< recursive_mutex > lk( mtx_);
                 if ( head_idx_ <= tail)
                 {
                         ca = array_[tail & mask_];
Modified: sandbox/task/libs/task/test/Jamfile.v2
==============================================================================
--- sandbox/task/libs/task/test/Jamfile.v2	(original)
+++ sandbox/task/libs/task/test/Jamfile.v2	2009-07-01 14:53:41 EDT (Wed, 01 Jul 2009)
@@ -31,4 +31,5 @@
     [ task-test test_new_thread ]
     [ task-test test_unbounded_pool ]
     [ task-test test_bounded_pool ]
+    [ task-test test_as_sub_task ]
     ;
Added: sandbox/task/libs/task/test/test_as_sub_task.cpp
==============================================================================
--- (empty file)
+++ sandbox/task/libs/task/test/test_as_sub_task.cpp	2009-07-01 14:53:41 EDT (Wed, 01 Jul 2009)
@@ -0,0 +1,76 @@
+
+//          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)
+
+#include <cstdlib>
+#include <iostream>
+#include <map>
+#include <stdexcept>
+#include <vector>
+
+#include <boost/bind.hpp>
+#include <boost/date_time/posix_time/posix_time.hpp>
+#include <boost/function.hpp>
+#include <boost/ref.hpp>
+#include <boost/test/unit_test.hpp>
+#include <boost/thread.hpp>
+#include <boost/thread/barrier.hpp>
+#include <boost/utility.hpp>
+
+#include <boost/task.hpp>
+
+#include "test_functions.hpp"
+
+namespace pt = boost::posix_time;
+namespace tsk = boost::task;
+
+namespace
+{
+bool exec_sub_task()
+{
+	tsk::handle< bool > h(
+		tsk::async(
+			tsk::make_task( runs_in_pool_fn),
+			tsk::as_sub_task() ) );
+	return h.get();	
+}
+}
+
+class test_as_sub_task
+{
+public:
+	// check runs not in pool
+	void test_case_1()
+	{
+		tsk::task< bool > t( runs_in_pool_fn);
+		tsk::handle< bool > h(
+			tsk::async( boost::move( t), tsk::as_sub_task() ) );
+		BOOST_CHECK_EQUAL( h.get(), false);
+	}
+	
+	// check runs in pool
+	void test_case_2()
+	{
+		tsk::static_pool<
+			tsk::unbounded_channel< tsk::fifo >
+		> pool( tsk::poolsize( 1) );
+		tsk::handle< bool > h(
+			tsk::async(
+				tsk::make_task( exec_sub_task),
+				pool) );
+		BOOST_CHECK_EQUAL( h.get(), true);
+	}
+};
+
+boost::unit_test::test_suite * init_unit_test_suite( int, char* [])
+{
+	boost::unit_test::test_suite * test( BOOST_TEST_SUITE("Boost.Task: test suite") );
+
+	boost::shared_ptr< test_as_sub_task > instance( new test_as_sub_task() );
+	test->add( BOOST_CLASS_TEST_CASE( & test_as_sub_task::test_case_1, instance) );
+	test->add( BOOST_CLASS_TEST_CASE( & test_as_sub_task::test_case_2, instance) );
+
+	return test;
+}
Modified: sandbox/task/libs/task/test/test_task.cpp
==============================================================================
--- sandbox/task/libs/task/test/test_task.cpp	(original)
+++ sandbox/task/libs/task/test/test_task.cpp	2009-07-01 14:53:41 EDT (Wed, 01 Jul 2009)
@@ -26,6 +26,10 @@
 namespace pt = boost::posix_time;
 namespace tsk = boost::task;
 
+void zero_args_fn() {}
+int one_arg_fn( int i) { return i; }
+int two_args_fn( int i, std::string const& s) { return i; }
+
 class test_task
 {
 public:
@@ -38,9 +42,19 @@
                 BOOST_CHECK( ! t2);
         }
 
-	// check moved task
+	// check make_task
         void test_case_2()
         {
+		tsk::task< void > t1;
+		t1 = tsk::make_task( zero_args_fn);
+		tsk::task< int > t2 = tsk::make_task( one_arg_fn, 1);
+		tsk::task< int > t3;
+		t3 = tsk::make_task( two_args_fn, 1, "abc");
+	}
+
+	// check moved task
+	void test_case_3()
+	{
                 tsk::task< int > t1( fibonacci_fn, 10);
                 BOOST_CHECK( t1);
                 tsk::task< int > t2( boost::move( t1) );
@@ -50,7 +64,7 @@
         }
 
         // check execute twice
-	void test_case_3()
+	void test_case_4()
         {
                 tsk::task< int > t1( fibonacci_fn, 10);
                 BOOST_CHECK_NO_THROW( t1() );
@@ -58,7 +72,7 @@
         }
 
         // check swap
-	void test_case_4()
+	void test_case_5()
         {
                 tsk::task< int > t1( fibonacci_fn, 10);
                 tsk::task< int > t2;
@@ -79,6 +93,7 @@
         test->add( BOOST_CLASS_TEST_CASE( & test_task::test_case_2, instance) );
         test->add( BOOST_CLASS_TEST_CASE( & test_task::test_case_3, instance) );
         test->add( BOOST_CLASS_TEST_CASE( & test_task::test_case_4, instance) );
+	test->add( BOOST_CLASS_TEST_CASE( & test_task::test_case_5, instance) );
 
         return test;
 }