Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r54018 - in sandbox/task: . boost boost/task boost/task/detail libs/task/doc libs/task/examples libs/task/test
From: oliver.kowalke_at_[hidden]
Date: 2009-06-17 14:57:45


Author: olli
Date: 2009-06-17 14:57:41 EDT (Wed, 17 Jun 2009)
New Revision: 54018
URL: http://svn.boost.org/trac/boost/changeset/54018

Log:
* move semantic for task< R > and static_pool< Channel >

Added:
   sandbox/task/boost/task/detail/move.hpp (contents, props changed)
   sandbox/task/libs/task/examples/shutdown_now.cpp (contents, props changed)
   sandbox/task/libs/task/test/test_task.cpp (contents, props changed)
Removed:
   sandbox/task/boost/task/id.hpp
   sandbox/task/libs/task/examples/shutdonw_now.cpp
Text files modified:
   sandbox/task/boost/task.hpp | 1
   sandbox/task/boost/task/as_sub_task.hpp | 19
   sandbox/task/boost/task/async.hpp | 33 +
   sandbox/task/boost/task/detail/pool_callable.hpp | 24 +
   sandbox/task/boost/task/detail/thread_callable.hpp | 22 +
   sandbox/task/boost/task/exceptions.hpp | 16 +
   sandbox/task/boost/task/handle.hpp | 14
   sandbox/task/boost/task/new_thread.hpp | 22
   sandbox/task/boost/task/own_thread.hpp | 20
   sandbox/task/boost/task/static_pool.hpp | 602 +++++++++++++++++++++++++++------------
   sandbox/task/boost/task/task.hpp | 427 ++++++++++++++--------------
   sandbox/task/change.log | 5
   sandbox/task/libs/task/doc/overview.qbk | 2
   sandbox/task/libs/task/examples/Jamfile.v2 | 2
   sandbox/task/libs/task/examples/bind_to_processors.cpp | 90 ++---
   sandbox/task/libs/task/examples/delay.cpp | 48 +-
   sandbox/task/libs/task/examples/fork_join.cpp | 46 +-
   sandbox/task/libs/task/examples/interrupt.cpp | 11
   sandbox/task/libs/task/examples/pending.cpp | 11
   sandbox/task/libs/task/examples/priority.cpp | 29 +
   sandbox/task/libs/task/examples/reschedule_until.cpp | 83 ++--
   sandbox/task/libs/task/examples/smart.cpp | 29 +
   sandbox/task/libs/task/examples/submit.cpp | 42 +-
   sandbox/task/libs/task/examples/yield.cpp | 81 ++--
   sandbox/task/libs/task/test/Jamfile.v2 | 1
   sandbox/task/libs/task/test/test_bounded_pool.cpp | 423 +++++++++++++--------------
   sandbox/task/libs/task/test/test_default_pool.cpp | 135 +++----
   sandbox/task/libs/task/test/test_new_thread.cpp | 233 +++++++--------
   sandbox/task/libs/task/test/test_own_thread.cpp | 247 +++++++--------
   sandbox/task/libs/task/test/test_unbounded_pool.cpp | 401 ++++++++++++-------------
   30 files changed, 1693 insertions(+), 1426 deletions(-)

Modified: sandbox/task/boost/task.hpp
==============================================================================
--- sandbox/task/boost/task.hpp (original)
+++ sandbox/task/boost/task.hpp 2009-06-17 14:57:41 EDT (Wed, 17 Jun 2009)
@@ -15,7 +15,6 @@
 #include <boost/task/fifo.hpp>
 #include <boost/task/future.hpp>
 #include <boost/task/handle.hpp>
-#include <boost/task/id.hpp>
 #include <boost/task/meta.hpp>
 #include <boost/task/new_thread.hpp>
 #include <boost/task/own_thread.hpp>

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-06-17 14:57:41 EDT (Wed, 17 Jun 2009)
@@ -8,7 +8,9 @@
 #define BOOST_TASK_AS_SUB_TASK_H
 
 #include <boost/bind.hpp>
+#include <boost/config.hpp>
 #include <boost/function.hpp>
+#include <boost/thread/detail/move.hpp>
 
 #include <boost/task/detail/interrupter.hpp>
 #include <boost/task/detail/worker.hpp>
@@ -21,17 +23,21 @@
 
 namespace boost { namespace task
 {
-
 struct as_sub_task
 {
         template< typename R >
- handle< R > operator()( task< R > t)
+# if defined(BOOST_HAS_RVALUE_REFS)
+ handle< R > operator()( task< R > && t_)
+# else
+ handle< R > operator()( boost::detail::thread_move_t< task< R > > t_)
+# endif
         {
                 detail::worker * w( detail::worker::tss_get() );
                 if ( w)
                 {
- detail::interrupter intr;
+ task< R > t( t_);
                         shared_future< R > fut( t.get_future() );
+ detail::interrupter intr;
                         function< bool() > wcb(
                                 bind(
                                         & shared_future< R >::is_ready,
@@ -41,14 +47,13 @@
                                         ( void ( detail::worker::*)( function< bool() > const&) ) & detail::worker::reschedule_until,
                                         w,
                                         wcb) );
- w->put( detail::pool_callable( t, intr) );
- return handle< R >( t.get_id(), fut, intr);
+ w->put( detail::pool_callable( boost::move( t), intr) );
+ return handle< R >( fut, intr);
                 }
                 else
- return new_thread()( t);
+ return new_thread()( t_);
         }
 };
-
 } }
 
 #include <boost/config/abi_suffix.hpp>

Modified: sandbox/task/boost/task/async.hpp
==============================================================================
--- sandbox/task/boost/task/async.hpp (original)
+++ sandbox/task/boost/task/async.hpp 2009-06-17 14:57:41 EDT (Wed, 17 Jun 2009)
@@ -7,6 +7,9 @@
 #ifndef BOOST_TASK_ASYNC_H
 #define BOOST_TASK_ASYNC_H
 
+#include <boost/config.hpp>
+#include <boost/thread/detail/move.hpp>
+
 #include <boost/task/as_sub_task.hpp>
 #include <boost/task/handle.hpp>
 #include <boost/task/static_pool.hpp>
@@ -16,23 +19,39 @@
 
 namespace boost { namespace task
 {
-
+# if defined(BOOST_HAS_RVALUE_REFS)
 template< typename R >
-handle< R > async( task< R > t)
+handle< R > async( task< R > && t)
 { return as_sub_task()( t); }
 
-template< typename R, typename AE >
-handle< R > async( task< R > t, AE ae)
-{ return ae( t); }
+template< typename R, typename EP >
+handle< R > async( task< R > && t, EP ep)
+{ return ep( t); }
 
 template< typename R, typename Channel >
-handle< R > async( task< R > t, static_pool< Channel > & pool)
+handle< R > async( task< R > && t, static_pool< Channel > & pool)
 { return pool.submit( t); }
 
 template< typename R, typename Channel, typename Attr >
-handle< R > async( task< R > t, Attr attr, static_pool< Channel > & pool)
+handle< R > async( task< R > && t, Attr attr, static_pool< Channel > & pool)
 { return pool.submit( t, attr); }
+# else
+template< typename R >
+handle< R > async( boost::detail::thread_move_t< task< R > > t)
+{ return as_sub_task()( t); }
+
+template< typename R, typename EP >
+handle< R > async( boost::detail::thread_move_t< task< R > > t, EP ep)
+{ return ep( t); }
 
+template< typename R, typename Channel >
+handle< R > async( boost::detail::thread_move_t< task< R > > t, static_pool< Channel > & pool)
+{ return pool.submit( t); }
+
+template< typename R, typename Channel, typename Attr >
+handle< R > async( boost::detail::thread_move_t< task< R > > t, Attr attr, static_pool< Channel > & pool)
+{ return pool.submit( t, attr); }
+# endif
 } }
 
 #include <boost/config/abi_suffix.hpp>

Added: sandbox/task/boost/task/detail/move.hpp
==============================================================================
--- (empty file)
+++ sandbox/task/boost/task/detail/move.hpp 2009-06-17 14:57:41 EDT (Wed, 17 Jun 2009)
@@ -0,0 +1,52 @@
+// 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)
+// (C) Copyright 2007-8 Anthony Williams
+
+#ifndef BOOST_TASK_MOVE_HPP
+#define BOOST_TASK_MOVE_HPP
+
+#ifndef BOOST_NO_SFINAE
+#include <boost/utility/enable_if.hpp>
+#include <boost/type_traits/is_convertible.hpp>
+#endif
+
+#include <boost/config/abi_prefix.hpp>
+
+namespace boost
+{
+ namespace detail
+ {
+ template< typename T >
+ struct task_move_t
+ {
+ T & t;
+ explicit task_move_t( T & t_)
+ : t( t_)
+ {}
+
+ T & operator*() const
+ { return t; }
+
+ T* operator->() const
+ { return & t; }
+
+ private:
+ void operator=( task_move_t &);
+ };
+ }
+
+#ifndef BOOST_NO_SFINAE
+ template< typename T >
+ typename enable_if< boost::is_convertible< T &, detail::task_move_t< T > >, T >::type move( T & t)
+ { return T( detail::task_move_t< T >( t) ); }
+#endif
+
+ template< typename T >
+ detail::task_move_t< T > move( detail::task_move_t< T > t)
+ { return t; }
+}
+
+#include <boost/config/abi_suffix.hpp>
+
+#endif // BOOST_TASK_MOVE_HPP

Modified: sandbox/task/boost/task/detail/pool_callable.hpp
==============================================================================
--- sandbox/task/boost/task/detail/pool_callable.hpp (original)
+++ sandbox/task/boost/task/detail/pool_callable.hpp 2009-06-17 14:57:41 EDT (Wed, 17 Jun 2009)
@@ -7,6 +7,7 @@
 #ifndef BOOST_TASK_DETAIL_POOL_CALLABLE_H
 #define BOOST_TASK_DETAIL_POOL_CALLABLE_H
 
+#include <boost/config.hpp>
 #include <boost/shared_ptr.hpp>
 #include <boost/thread.hpp>
 #include <boost/utility.hpp>
@@ -43,15 +44,23 @@
         class impl_wrapper : public impl
         {
         private:
- task< R > t_;
+ task< R > t_;
                 detail::interrupter i_;
 
         public:
+# if defined(BOOST_HAS_RVALUE_REFS)
                 impl_wrapper(
- task< R > const& t,
+ task< R > && t,
                         detail::interrupter const& i)
                 : t_( t), i_( i)
                 {}
+# else
+ impl_wrapper(
+ boost::detail::thread_move_t< task< R > > t,
+ detail::interrupter const& i)
+ : t_( t), i_( i)
+ {}
+# endif
 
                 void run()
                 { t_(); }
@@ -79,12 +88,21 @@
 
         pool_callable();
 
+# if defined(BOOST_HAS_RVALUE_REFS)
         template< typename R >
         pool_callable(
- task< R > const& t,
+ task< R > && t,
                 detail::interrupter const& i)
         : impl_( new impl_wrapper< R >( t, i) )
         {}
+# else
+ template< typename R >
+ pool_callable(
+ boost::detail::thread_move_t< task< R > > t,
+ detail::interrupter const& i)
+ : impl_( new impl_wrapper< R >( t, i) )
+ {}
+# endif
 
         void operator()();
 

Modified: sandbox/task/boost/task/detail/thread_callable.hpp
==============================================================================
--- sandbox/task/boost/task/detail/thread_callable.hpp (original)
+++ sandbox/task/boost/task/detail/thread_callable.hpp 2009-06-17 14:57:41 EDT (Wed, 17 Jun 2009)
@@ -7,6 +7,7 @@
 #ifndef BOOST_TASK_DETAIL_THREAD_CALLABLE_H
 #define BOOST_TASK_DETAIL_THREAD_CALLABLE_H
 
+#include <boost/config.hpp>
 #include <boost/shared_ptr.hpp>
 #include <boost/thread.hpp>
 #include <boost/utility.hpp>
@@ -44,11 +45,19 @@
                 interrupter i_;
 
         public:
+# if defined(BOOST_HAS_RVALUE_REFS)
                 impl_wrapper(
- task< R > const& t,
+ task< R > && t,
                         interrupter const& i)
                 : t_( t), i_( i)
                 {}
+# else
+ impl_wrapper(
+ boost::detail::thread_move_t< task< R > > t,
+ interrupter const& i)
+ : t_( t), i_( i)
+ {}
+# endif
 
                 ~impl_wrapper()
                 { i_.reset(); }
@@ -60,12 +69,21 @@
         shared_ptr< impl > impl_;
 
 public:
+# if defined(BOOST_HAS_RVALUE_REFS)
         template< typename R >
         thread_callable(
- task< R > const& t,
+ task< R > && t,
                 interrupter const& i)
         : impl_( new impl_wrapper< R >( t, i) )
         {}
+# else
+ template< typename R >
+ thread_callable(
+ boost::detail::thread_move_t< task< R > > t,
+ interrupter const& i)
+ : impl_( new impl_wrapper< R >( t, i) )
+ {}
+# endif
 
         void operator()();
 };

Modified: sandbox/task/boost/task/exceptions.hpp
==============================================================================
--- sandbox/task/boost/task/exceptions.hpp (original)
+++ sandbox/task/boost/task/exceptions.hpp 2009-06-17 14:57:41 EDT (Wed, 17 Jun 2009)
@@ -62,6 +62,14 @@
         {}
 };
 
+class task_moved : public std::logic_error
+{
+public:
+ task_moved()
+ : std::logic_error("task moved")
+ {}
+};
+
 class broken_task : public std::logic_error
 {
 public:
@@ -80,6 +88,14 @@
         : std::runtime_error( msg)
         {}
 };
+
+class pool_moved : public std::logic_error
+{
+public:
+ pool_moved()
+ : std::logic_error("pool moved")
+ {}
+};
 } }
 
 #include <boost/config/abi_suffix.hpp>

Modified: sandbox/task/boost/task/handle.hpp
==============================================================================
--- sandbox/task/boost/task/handle.hpp (original)
+++ sandbox/task/boost/task/handle.hpp 2009-06-17 14:57:41 EDT (Wed, 17 Jun 2009)
@@ -13,7 +13,6 @@
 #include <boost/task/detail/interrupter.hpp>
 #include <boost/task/future.hpp>
 #include <boost/task/exceptions.hpp>
-#include <boost/task/id.hpp>
 
 #include <boost/config/abi_prefix.hpp>
 
@@ -59,26 +58,20 @@
 
         shared_future< R > fut_;
         detail::interrupter intr_;
- id id_;
 
         handle(
- id const& id__,
- shared_future< R > const& fut,
+ shared_future< R > fut,
                 detail::interrupter const& intr)
         :
         fut_( fut),
- intr_( intr),
- id_( id__)
+ intr_( intr)
         {}
 
 public:
         handle()
- : fut_(), intr_( detail::interrupter::dont_wait), id_()
+ : fut_(), intr_( detail::interrupter::dont_wait)
         {}
 
- const id get_id() const
- { return id_; }
-
         void interrupt()
         { intr_.interrupt(); }
 
@@ -160,7 +153,6 @@
         {
                 fut_.swap( other.fut_);
                 intr_.swap( other.intr_);
- id_.swap( other.id_);
         }
 };
 

Deleted: sandbox/task/boost/task/id.hpp
==============================================================================
--- sandbox/task/boost/task/id.hpp 2009-06-17 14:57:41 EDT (Wed, 17 Jun 2009)
+++ (empty file)
@@ -1,68 +0,0 @@
-
-// 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)
-
-#ifndef BOOST_TASK_ID_H
-#define BOOST_TASK_ID_H
-
-#include <iostream>
-#include <string>
-
-#include <boost/config/abi_prefix.hpp>
-
-namespace boost { namespace task
-{
-template< typename R >
-class task;
-
-class id
-{
-private:
- template< typename R >
- friend class task;
-
- std::string id_;
-
- id( std::string const& id__)
- : id_( id__)
- {}
-
-public:
- id()
- : id_("{not-any-task}")
- {}
-
- bool operator==( id const& other) const
- { return id_ == other.id_; }
-
- bool operator!=( id const& other) const
- { return id_ != other.id_; }
-
- bool operator<( id const& other) const
- { return id_ < other.id_; }
-
- bool operator>( id const& other) const
- { return id_ > other.id_; }
-
- bool operator<=( id const& other) const
- { return id_ <= other.id_; }
-
- bool operator>=( id const& other) const
- { return id_ >= other.id_; }
-
- template< typename charT, typename traitsT >
- friend std::basic_ostream< charT, traitsT > &
- operator<<( std::basic_ostream< charT, traitsT > & os, id const& r)
- { return os << r.id_; }
-
- void swap( id & other)
- { id_.swap( other.id_); }
-};
-} }
-
-#include <boost/config/abi_suffix.hpp>
-
-#endif // BOOST_TASK_ID_H
-

Modified: sandbox/task/boost/task/new_thread.hpp
==============================================================================
--- sandbox/task/boost/task/new_thread.hpp (original)
+++ sandbox/task/boost/task/new_thread.hpp 2009-06-17 14:57:41 EDT (Wed, 17 Jun 2009)
@@ -7,11 +7,14 @@
 #ifndef BOOST_TASK_NEW_THREAD_H
 #define BOOST_TASK_NEW_THREAD_H
 
+#include <boost/config.hpp>
 #include <boost/shared_ptr.hpp>
 #include <boost/thread.hpp>
+#include <boost/thread/detail/move.hpp>
 
 #include <boost/task/detail/interrupter.hpp>
 #include <boost/task/detail/thread_callable.hpp>
+#include <boost/task/future.hpp>
 #include <boost/task/handle.hpp>
 #include <boost/task/task.hpp>
 
@@ -19,10 +22,8 @@
 
 namespace boost { namespace task
 {
-
 namespace detail
 {
-
 struct joiner
 {
         void operator()( thread * thrd)
@@ -40,18 +41,23 @@
 struct new_thread
 {
         template< typename R >
- handle< R > operator()( task< R > t)
+# if defined(BOOST_HAS_RVALUE_REFS)
+ handle< R > operator()( task< R > && t_)
+# else
+ handle< R > operator()( boost::detail::thread_move_t< task< R > > t_)
+# endif
         {
+ task< R > t( t_);
+ shared_future< R > fut( t.get_future() );
                 detail::interrupter intr;
- detail::thread_callable ca( t, intr);
-
+ detail::thread_callable ca( boost::move( t), intr);
+
                 shared_ptr< thread > thrd( new thread( ca), detail::joiner() );
                 intr.set( thrd);
-
- return handle< R >( t.get_id(), t.get_future(), intr);
+
+ return handle< R >( fut, intr);
         }
 };
-
 } }
 
 #include <boost/config/abi_suffix.hpp>

Modified: sandbox/task/boost/task/own_thread.hpp
==============================================================================
--- sandbox/task/boost/task/own_thread.hpp (original)
+++ sandbox/task/boost/task/own_thread.hpp 2009-06-17 14:57:41 EDT (Wed, 17 Jun 2009)
@@ -7,6 +7,9 @@
 #ifndef BOOST_TASK_OWN_THREAD_H
 #define BOOST_TASK_OWN_THREAD_H
 
+#include <boost/config.hpp>
+#include <boost/thread/detail/move.hpp>
+
 #include <boost/task/detail/interrupter.hpp>
 #include <boost/task/handle.hpp>
 #include <boost/task/task.hpp>
@@ -15,22 +18,23 @@
 
 namespace boost { namespace task
 {
-
 struct own_thread
 {
         template< typename R >
- handle< R > operator()( task< R > t)
+# if defined(BOOST_HAS_RVALUE_REFS)
+ handle< R > operator()( task< R > && t_)
+# else
+ handle< R > operator()( boost::detail::thread_move_t< task< R > > t_)
+# endif
         {
- t();
+ task< R > t( t_);
+ shared_future< R > fut( t.get_future() );
                 detail::interrupter intr;
                 intr.reset();
- return handle< R >(
- t.get_id(),
- t.get_future(),
- intr);
+ t();
+ return handle< R >( fut, intr);
         }
 };
-
 } }
 
 #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-06-17 14:57:41 EDT (Wed, 17 Jun 2009)
@@ -13,10 +13,12 @@
 
 #include <boost/assert.hpp>
 #include <boost/bind.hpp>
+#include <boost/config.hpp>
 #include <boost/cstdint.hpp>
 #include <boost/date_time/posix_time/posix_time.hpp>
 #include <boost/function.hpp>
 #include <boost/thread.hpp>
+#include <boost/thread/detail/move.hpp>
 #include <boost/utility.hpp>
 
 #include <boost/task/detail/atomic.hpp>
@@ -53,103 +55,308 @@
         friend class detail::worker;
 
         typedef typename channel::item channel_item;
-
- detail::worker_group wg_;
- shared_mutex mtx_wg_;
- volatile uint32_t state_;
- channel channel_;
- volatile uint32_t active_worker_;
- volatile uint32_t idle_worker_;
-
- void worker_entry_()
- {
- shared_lock< shared_mutex > lk( mtx_wg_);
- typename detail::worker_group::iterator i( wg_.find( this_thread::get_id() ) );
- lk.unlock();
- BOOST_ASSERT( i != wg_.end() );
-
- detail::worker w( * i);
- w.run();
- }
         
- void create_worker_(
- poolsize const& psize,
- posix_time::time_duration const& asleep,
- scanns const& max_scns)
- {
- wg_.insert(
- detail::worker(
- * this,
- psize,
- asleep,
- max_scns,
- boost::bind(
- & static_pool::worker_entry_,
- this) ) );
- }
-
 # if defined(BOOST_HAS_PROCESSOR_BINDINGS)
- void worker_entry_( std::size_t n)
+ struct tag_bind_to_processors {};
+# endif
+
+ class pool_base
         {
- this_thread::bind_to_processor( n);
- worker_entry_();
- }
+ private:
+ friend class detail::worker;
+
+ detail::worker_group wg_;
+ shared_mutex mtx_wg_;
+ volatile uint32_t state_;
+ channel channel_;
+ volatile uint32_t active_worker_;
+ volatile uint32_t idle_worker_;
+
+ void worker_entry_()
+ {
+ shared_lock< shared_mutex > lk( mtx_wg_);
+ typename detail::worker_group::iterator i( wg_.find( this_thread::get_id() ) );
+ lk.unlock();
+ BOOST_ASSERT( i != wg_.end() );
+
+ detail::worker w( * i);
+ w.run();
+ }
+
+ void create_worker_(
+ poolsize const& psize,
+ posix_time::time_duration const& asleep,
+ scanns const& max_scns)
+ {
+ wg_.insert(
+ detail::worker(
+ * this,
+ psize,
+ asleep,
+ max_scns,
+ boost::bind(
+ & pool_base::worker_entry_,
+ this) ) );
+ }
 
- void create_worker_(
- poolsize const& psize,
- posix_time::time_duration const& asleep,
- scanns const& max_scns,
- std::size_t n)
- {
- wg_.insert(
- detail::worker(
- * this,
- psize,
- asleep,
- max_scns,
- boost::bind(
- & static_pool::worker_entry_,
- this,
- n) ) );
- }
+# if defined(BOOST_HAS_PROCESSOR_BINDINGS)
+ void worker_entry_( std::size_t n)
+ {
+ this_thread::bind_to_processor( n);
+ worker_entry_();
+ }
+
+ void create_worker_(
+ poolsize const& psize,
+ posix_time::time_duration const& asleep,
+ scanns const& max_scns,
+ std::size_t n)
+ {
+ wg_.insert(
+ detail::worker(
+ * this,
+ psize,
+ asleep,
+ max_scns,
+ boost::bind(
+ & pool_base::worker_entry_,
+ this,
+ n) ) );
+ }
 # endif
 
- std::size_t active_() const
- { return active_worker_; }
+ std::size_t active_() const
+ { return active_worker_; }
+
+ std::size_t idle_() const
+ { return size_() - active_(); }
 
- std::size_t idle_() const
- { return size_() - active_(); }
+ std::size_t size_() const
+ { return wg_.size(); }
 
- std::size_t size_() const
- { return wg_.size(); }
+ bool closed_() const
+ { return state_ > 0; }
+
+ unsigned int close_()
+ { return detail::atomic_fetch_add( & state_, 1); }
+
+ public:
+ explicit pool_base(
+ poolsize const& psize,
+ posix_time::time_duration const& asleep = posix_time::microseconds( 10),
+ scanns const& max_scns = scanns( 20) )
+ :
+ wg_(),
+ mtx_wg_(),
+ state_( 0),
+ channel_(),
+ active_worker_( 0),
+ idle_worker_( 0)
+ {
+ if ( asleep.is_special() || asleep.is_negative() )
+ throw invalid_timeduration();
+ channel_.activate();
+ unique_lock< 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(
+ poolsize const& psize,
+ high_watermark const& hwm,
+ low_watermark const& lwm,
+ posix_time::time_duration const& asleep = posix_time::microseconds( 100),
+ scanns const& max_scns = scanns( 20) )
+ :
+ wg_(),
+ mtx_wg_(),
+ state_( 0),
+ channel_(
+ hwm,
+ lwm),
+ active_worker_( 0),
+ idle_worker_( 0)
+ {
+ if ( asleep.is_special() || asleep.is_negative() )
+ throw invalid_timeduration();
+ channel_.activate();
+ unique_lock< shared_mutex > lk( mtx_wg_);
+ for ( std::size_t i( 0); i < psize; ++i)
+ create_worker_( psize, asleep, max_scns);
+ lk.unlock();
+ }
 
- bool closed_() const
- { return state_ > 0; }
+# if defined(BOOST_HAS_PROCESSOR_BINDINGS)
+ explicit pool_base(
+ posix_time::time_duration const& asleep = posix_time::microseconds( 10),
+ scanns const& max_scns = scanns( 20) )
+ :
+ wg_(),
+ mtx_wg_(),
+ state_( 0),
+ channel_(),
+ active_worker_( 0),
+ idle_worker_( 0)
+ {
+ if ( asleep.is_special() || asleep.is_negative() )
+ throw invalid_timeduration();
+ poolsize psize( thread::hardware_concurrency() );
+ BOOST_ASSERT( psize > 0);
+ channel_.activate();
+ unique_lock< 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(
+ high_watermark const& hwm,
+ low_watermark const& lwm,
+ posix_time::time_duration const& asleep = posix_time::microseconds( 100),
+ scanns const& max_scns = scanns( 20) )
+ :
+ wg_(),
+ mtx_wg_(),
+ state_( 0),
+ channel_(
+ hwm,
+ lwm),
+ active_worker_( 0),
+ idle_worker_( 0)
+ {
+ if ( asleep.is_special() || asleep.is_negative() )
+ throw invalid_timeduration();
+ poolsize psize( thread::hardware_concurrency() );
+ BOOST_ASSERT( psize > 0);
+ channel_.activate();
+ unique_lock< shared_mutex > lk( mtx_wg_);
+ for ( std::size_t i( 0); i < psize; ++i)
+ create_worker_( psize, asleep, max_scns, i);
+ lk.unlock();
+ }
+# endif
 
- unsigned int close_()
- { return detail::atomic_fetch_add( & state_, 1); }
+ ~pool_base()
+ { shutdown(); }
+
+ std::size_t active()
+ {
+ shared_lock< shared_mutex > lk( mtx_wg_);
+ return active_();
+ }
+
+ std::size_t idle()
+ {
+ shared_lock< shared_mutex > lk( mtx_wg_);
+ return idle_();
+ }
+
+ void shutdown()
+ {
+ if ( closed_() || close_() > 1) return;
+
+ channel_.deactivate();
+ shared_lock< shared_mutex > lk( mtx_wg_);
+ wg_.signal_shutdown_all();
+ wg_.join_all();
+ lk.unlock();
+ }
+
+ const void shutdown_now()
+ {
+ if ( closed_() || close_() > 1) return;
+
+ channel_.deactivate_now();
+ shared_lock< shared_mutex > lk( mtx_wg_);
+ wg_.signal_shutdown_now_all();
+ wg_.interrupt_all();
+ wg_.join_all();
+ lk.unlock();
+ }
+
+ std::size_t size()
+ {
+ shared_lock< shared_mutex > lk( mtx_wg_);
+ return size_();
+ }
+
+ bool closed()
+ { return closed_(); }
+
+ void clear()
+ { channel_.clear(); }
+
+ bool empty()
+ { return channel_.empty(); }
+
+ std::size_t pending()
+ { return channel_.size(); }
+
+ std::size_t upper_bound()
+ { return channel_.upper_bound(); }
+
+ void upper_bound( high_watermark const& hwm)
+ { channel_.upper_bound( hwm); }
+
+ std::size_t lower_bound()
+ { return channel_.lower_bound(); }
+
+ void lower_bound( low_watermark const lwm)
+ { channel_.lower_bound( lwm); }
+
+ template< typename R >
+# if defined(BOOST_HAS_RVALUE_REFS)
+ handle< R > submit( task< R > && t_)
+#else
+ handle< R > submit( boost::detail::thread_move_t< task< R > > t_)
+# endif
+ {
+ if ( closed_() )
+ throw task_rejected("pool is closed");
+
+ task< R > t( t_);
+ shared_future< R > fut( t.get_future() );
+ detail::interrupter intr;
+ channel_.put( detail::pool_callable( boost::move( t), intr) );
+ return handle< R >( fut, intr);
+ }
+
+ template<
+ typename R,
+ typename Attr
+ >
+# if defined(BOOST_HAS_RVALUE_REFS)
+ handle< R > submit( task< R > && t_, Attr const& attr)
+#else
+
+ handle< R > submit( boost::detail::thread_move_t< task< R > > t_, Attr const& attr)
+# endif
+ {
+ if ( closed_() )
+ throw task_rejected("pool is closed");
+
+ task< R > t( t_);
+ shared_future< R > fut( t.get_future() );
+ detail::interrupter intr;
+ channel_.put( channel_item( detail::pool_callable( boost::move( t), intr), attr) );
+ return handle< R >( fut, intr);
+ }
+ };
+
+ shared_ptr< pool_base > pool_;
 
 public:
+ static_pool()
+ : pool_()
+ {}
+
         explicit static_pool(
                 poolsize const& psize,
                 posix_time::time_duration const& asleep = posix_time::microseconds( 10),
                 scanns const& max_scns = scanns( 20) )
- :
- wg_(),
- mtx_wg_(),
- state_( 0),
- channel_(),
- active_worker_( 0),
- idle_worker_( 0)
- {
- if ( asleep.is_special() || asleep.is_negative() )
- throw invalid_timeduration();
- channel_.activate();
- unique_lock< shared_mutex > lk( mtx_wg_);
- for ( std::size_t i( 0); i < psize; ++i)
- create_worker_( psize, asleep, max_scns);
- lk.unlock();
- }
+ : pool_( new pool_base( psize, asleep, max_scns) )
+ {}
 
         explicit static_pool(
                 poolsize const& psize,
@@ -157,169 +364,198 @@
                 low_watermark const& lwm,
                 posix_time::time_duration const& asleep = posix_time::microseconds( 100),
                 scanns const& max_scns = scanns( 20) )
- :
- wg_(),
- mtx_wg_(),
- state_( 0),
- channel_(
- hwm,
- lwm),
- active_worker_( 0),
- idle_worker_( 0)
- {
- if ( asleep.is_special() || asleep.is_negative() )
- throw invalid_timeduration();
- channel_.activate();
- unique_lock< shared_mutex > lk( mtx_wg_);
- for ( std::size_t i( 0); i < psize; ++i)
- create_worker_( psize, asleep, max_scns);
- lk.unlock();
- }
+ : pool_( new pool_base( psize, hwm, lwm, asleep, max_scns) )
+ {}
 
 # if defined(BOOST_HAS_PROCESSOR_BINDINGS)
         explicit static_pool(
+ tag_bind_to_processors,
                 posix_time::time_duration const& asleep = posix_time::microseconds( 10),
                 scanns const& max_scns = scanns( 20) )
- :
- wg_(),
- mtx_wg_(),
- state_( 0),
- channel_(),
- active_worker_( 0),
- idle_worker_( 0)
- {
- if ( asleep.is_special() || asleep.is_negative() )
- throw invalid_timeduration();
- poolsize psize( thread::hardware_concurrency() );
- BOOST_ASSERT( psize > 0);
- channel_.activate();
- unique_lock< shared_mutex > lk( mtx_wg_);
- for ( std::size_t i( 0); i < psize; ++i)
- create_worker_( psize, asleep, max_scns, i);
- lk.unlock();
- }
+ : pool_( new pool_base( asleep, max_scns) )
+ {}
 
         explicit static_pool(
+ tag_bind_to_processors,
                 high_watermark const& hwm,
                 low_watermark const& lwm,
                 posix_time::time_duration const& asleep = posix_time::microseconds( 100),
                 scanns const& max_scns = scanns( 20) )
- :
- wg_(),
- mtx_wg_(),
- state_( 0),
- channel_(
- hwm,
- lwm),
- active_worker_( 0),
- idle_worker_( 0)
- {
- if ( asleep.is_special() || asleep.is_negative() )
- throw invalid_timeduration();
- poolsize psize( thread::hardware_concurrency() );
- BOOST_ASSERT( psize > 0);
- channel_.activate();
- unique_lock< shared_mutex > lk( mtx_wg_);
- for ( std::size_t i( 0); i < psize; ++i)
- create_worker_( psize, asleep, max_scns, i);
- lk.unlock();
- }
+ : pool_( new pool_base( hwm, lwm, asleep, max_scns) )
+ {}
+
+ static tag_bind_to_processors bind_to_processors()
+ { return tag_bind_to_processors(); }
 # endif
 
- ~static_pool()
- { shutdown(); }
+# if defined(BOOST_HAS_RVALUE_REFS)
+ static_pool( static_pool && other)
+ : pool_()
+ { pool_.swap( other.pool_); }
+
+ static_pool & operator=( static_pool && other)
+ {
+ static_pool tmp( static_cast< static_pool && >( other) );
+ swap( tmp);
+ return * this;
+ }
+
+ static_pool && move()
+ { return static_cast< static_pool && >( * this); }
+# else
+ static_pool( boost::detail::thread_move_t< static_pool > other)
+ : pool_()
+ { pool_.swap( other->pool_); }
+
+ static_pool & operator=( boost::detail::thread_move_t< static_pool > other)
+ {
+ static_pool tmp( other);
+ swap( tmp);
+ return * this;
+ }
+
+ operator boost::detail::thread_move_t< static_pool >()
+ { return boost::detail::thread_move_t< static_pool >( * this); }
+# endif
 
         std::size_t active()
         {
- shared_lock< shared_mutex > lk( mtx_wg_);
- return active_();
+ if ( ! pool_)
+ throw pool_moved();
+ return pool_->active();
         }
 
         std::size_t idle()
         {
- shared_lock< shared_mutex > lk( mtx_wg_);
- return idle_();
+ if ( ! pool_)
+ throw pool_moved();
+ return pool_->idle();
         }
         
         void shutdown()
         {
- if ( closed_() || close_() > 1) return;
-
- channel_.deactivate();
- shared_lock< shared_mutex > lk( mtx_wg_);
- wg_.signal_shutdown_all();
- wg_.join_all();
- lk.unlock();
+ if ( ! pool_)
+ throw pool_moved();
+ pool_->shutdown();
         }
 
         const void shutdown_now()
         {
- if ( closed_() || close_() > 1) return;
-
- channel_.deactivate_now();
- shared_lock< shared_mutex > lk( mtx_wg_);
- wg_.signal_shutdown_now_all();
- wg_.interrupt_all();
- wg_.join_all();
- lk.unlock();
+ if ( ! pool_)
+ throw pool_moved();
+ pool_->shutdown_now();
         }
 
         std::size_t size()
         {
- shared_lock< shared_mutex > lk( mtx_wg_);
- return size_();
+ if ( ! pool_)
+ throw pool_moved();
+ return pool_->size();
         }
 
         bool closed()
- { return closed_(); }
+ {
+ if ( ! pool_)
+ throw pool_moved();
+ return pool_->closed();
+ }
 
         void clear()
- { channel_.clear(); }
+ {
+ if ( ! pool_)
+ throw pool_moved();
+ pool_->clear();
+ }
 
         bool empty()
- { return channel_.empty(); }
+ {
+ if ( ! pool_)
+ throw pool_moved();
+ return pool_->empty();
+ }
 
         std::size_t pending()
- { return channel_.size(); }
+ {
+ if ( ! pool_)
+ throw pool_moved();
+ return pool_->pending();
+ }
 
         std::size_t upper_bound()
- { return channel_.upper_bound(); }
+ {
+ if ( ! pool_)
+ throw pool_moved();
+ return pool_->upper_bound();
+ }
 
         void upper_bound( high_watermark const& hwm)
- { return channel_.upper_bound( hwm); }
+ {
+ if ( ! pool_)
+ throw pool_moved();
+ pool_->upper_bound( hwm);
+ }
 
         std::size_t lower_bound()
- { return channel_.lower_bound(); }
+ {
+ if ( ! pool_)
+ throw pool_moved();
+ return pool_->lower_bound();
+ }
 
         void lower_bound( low_watermark const lwm)
- { return channel_.lower_bound( lwm); }
+ {
+ if ( ! pool_)
+ throw pool_moved();
+ pool_->lower_bound( lwm);
+ }
 
         template< typename R >
- handle< R > submit( task< R > t)
+# if defined(BOOST_HAS_RVALUE_REFS)
+ handle< R > submit( task< R > && t)
+#else
+ handle< R > submit( boost::detail::thread_move_t< task< R > > t)
+# endif
         {
- if ( closed_() )
- throw task_rejected("pool is closed");
-
- detail::interrupter intr;
- channel_.put( detail::pool_callable( t, intr) );
- return handle< R >( t.get_id(), t.get_future(), intr);
+ if ( ! pool_)
+ throw pool_moved();
+ return pool_->submit( t);
         }
 
         template<
                 typename R,
                 typename Attr
>
- handle< R > submit( task< R > t, Attr const& attr)
+# if defined(BOOST_HAS_RVALUE_REFS)
+ handle< R > submit( task< R > && t, Attr const& attr)
+#else
+
+ handle< R > submit( boost::detail::thread_move_t< task< R > > t, Attr const& attr)
+# endif
         {
- if ( closed_() )
- throw task_rejected("pool is closed");
-
- detail::interrupter intr;
- channel_.put( channel_item( detail::pool_callable( t, intr), attr) );
- return handle< R >( t.get_id(), t.get_future(), intr);
+ if ( ! pool_)
+ throw pool_moved();
+ return pool_->submit( t, attr);
         }
+
+ void swap( static_pool & other) // throw()
+ { pool_.swap( other.pool_); }
 };
-}}
+}
+
+template< typename Channel >
+void swap( task::static_pool< Channel > & l, task::static_pool< Channel > & r)
+{ return l.swap( r); }
+
+# if defined(BOOST_HAS_RVALUE_REFS)
+template< typename Channel >
+task::static_pool< Channel > && move( task::static_pool< Channel > && t)
+{ return t; }
+# else
+template< typename Channel >
+boost::detail::thread_move_t< task::static_pool< Channel > > move( task::static_pool< Channel > & t)
+{ return t; }
+# endif
+}
 
 #include <boost/config/abi_suffix.hpp>
 

Modified: sandbox/task/boost/task/task.hpp
==============================================================================
--- sandbox/task/boost/task/task.hpp (original)
+++ sandbox/task/boost/task/task.hpp 2009-06-17 14:57:41 EDT (Wed, 17 Jun 2009)
@@ -7,141 +7,171 @@
 #ifndef BOOST_TASK_TASK_H
 #define BOOST_TASK_TASK_H
 
-#include <exception>
-#include <ios>
-#include <new>
-#include <stdexcept>
-#include <string>
-#include <typeinfo>
-
-#include <boost/lexical_cast.hpp>
-#include <boost/preprocessor/repetition.hpp>
+#include <boost/bind.hpp>
+#include <boost/config.hpp>
 #include <boost/thread.hpp>
-#include <boost/thread/thread_time.hpp>
-#include <boost/utility/result_of.hpp>
 
 #include <boost/task/future.hpp>
 #include <boost/task/exceptions.hpp>
-#include <boost/task/handle.hpp>
-#include <boost/task/id.hpp>
 
 #include <boost/config/abi_prefix.hpp>
 
 namespace boost { namespace task
 {
-
 template< typename Channel >
 class static_pool;
 
 struct as_sub_task;
 
+namespace detail
+{
 template< typename R >
-class task
+class task_base
 {
-private:
- template< typename Channel >
- friend class static_pool;
-
- friend struct as_sub_task;
+protected:
+ bool done_;
 
- struct impl
- {
- promise< R > prom;
- unique_future< R > fut;
+protected:
+ promise< R > prom_;
 
- impl()
- :
- prom(),
- fut( prom.get_future() )
- {}
+ virtual void do_run() = 0;
 
- virtual ~impl()
- {}
+public:
+ task_base()
+ : done_( false), prom_()
+ {}
 
- virtual void operator()() = 0;
- };
+ virtual ~task_base() {}
 
- template< typename Fn >
- class impl_wrapper : public impl
+ void run()
         {
- private:
- Fn fn_;
-
- public:
- impl_wrapper( Fn const& fn)
- : fn_( fn)
- {}
-
- void operator()() // throw()
- {
- try
- { impl::prom.set_value( fn_() ); }
- catch ( promise_already_satisfied const&)
- { throw task_already_executed(); }
- catch ( thread_interrupted const&)
- { impl::prom.set_exception( copy_exception( task_interrupted() ) ); }
- catch ( boost::exception const& e)
- { impl::prom.set_exception( copy_exception( e) ); }
- catch ( std::ios_base::failure const& e)
- { impl::prom.set_exception( copy_exception( e) ); }
- catch ( std::domain_error const& e)
- { impl::prom.set_exception( copy_exception( e) ); }
- catch ( std::invalid_argument const& e)
- { impl::prom.set_exception( copy_exception( e) ); }
- catch ( std::length_error const& e)
- { impl::prom.set_exception( copy_exception( e) ); }
- catch ( std::out_of_range const& e)
- { impl::prom.set_exception( copy_exception( e) ); }
- catch ( std::logic_error const& e)
- { impl::prom.set_exception( copy_exception( e) ); }
- catch ( std::overflow_error const& e)
- { impl::prom.set_exception( copy_exception( e) ); }
- catch ( std::range_error const& e)
- { impl::prom.set_exception( copy_exception( e) ); }
- catch ( std::underflow_error const& e)
- { impl::prom.set_exception( copy_exception( e) ); }
- catch ( std::runtime_error const& e)
- { impl::prom.set_exception( copy_exception( e) ); }
- catch ( std::bad_alloc const& e)
- { impl::prom.set_exception( copy_exception( e) ); }
- catch ( std::bad_cast const& e)
- { impl::prom.set_exception( copy_exception( e) ); }
- catch ( std::bad_typeid const& e)
- { impl::prom.set_exception( copy_exception( e) ); }
- catch ( std::bad_exception const& e)
- { impl::prom.set_exception( copy_exception( e) ); }
- catch(...)
- { impl::prom.set_exception( current_exception() ); }
- }
- };
+ if ( this->done_) throw task_already_executed();
+ do_run();
+ done_ = true;
+ }
+
+ unique_future< R > get_future()
+ { return prom_.get_future(); }
+
+ template< typename Cb >
+ void set_wait_callback( Cb const& cb)
+ { prom_.set_wait_callback( cb); }
+};
 
- shared_ptr< impl > impl_;
+template< typename R, typename Fn >
+class task_wrapper : public task_base< R >
+{
+private:
+ Fn fn_;
 
- template< typename F >
- void set_wait_callback( F const& f)
- { impl_->prom.set_wait_callback( f); }
+ void do_run()
+ {
+ try
+ { this->prom_.set_value( fn_() ); }
+ catch ( promise_already_satisfied const&)
+ { throw task_already_executed(); }
+ catch ( thread_interrupted const&)
+ { this->prom_.set_exception( copy_exception( task_interrupted() ) ); }
+ catch ( boost::exception const& e)
+ { this->prom_.set_exception( copy_exception( e) ); }
+ catch ( std::ios_base::failure const& e)
+ { this->prom_.set_exception( copy_exception( e) ); }
+ catch ( std::domain_error const& e)
+ { this->prom_.set_exception( copy_exception( e) ); }
+ catch ( std::invalid_argument const& e)
+ { this->prom_.set_exception( copy_exception( e) ); }
+ catch ( std::length_error const& e)
+ { this->prom_.set_exception( copy_exception( e) ); }
+ catch ( std::out_of_range const& e)
+ { this->prom_.set_exception( copy_exception( e) ); }
+ catch ( std::logic_error const& e)
+ { this->prom_.set_exception( copy_exception( e) ); }
+ catch ( std::overflow_error const& e)
+ { this->prom_.set_exception( copy_exception( e) ); }
+ catch ( std::range_error const& e)
+ { this->prom_.set_exception( copy_exception( e) ); }
+ catch ( std::underflow_error const& e)
+ { this->prom_.set_exception( copy_exception( e) ); }
+ catch ( std::runtime_error const& e)
+ { this->prom_.set_exception( copy_exception( e) ); }
+ catch ( std::bad_alloc const& e)
+ { this->prom_.set_exception( copy_exception( e) ); }
+ catch ( std::bad_cast const& e)
+ { this->prom_.set_exception( copy_exception( e) ); }
+ catch ( std::bad_typeid const& e)
+ { this->prom_.set_exception( copy_exception( e) ); }
+ catch ( std::bad_exception const& e)
+ { this->prom_.set_exception( copy_exception( e) ); }
+ catch(...)
+ { this->prom_.set_exception( current_exception() ); }
+ }
 
 public:
- template< typename Fn >
- task( Fn const& fn)
- : impl_( new impl_wrapper< Fn >( fn) )
+ task_wrapper( Fn const& fn)
+ : task_base< R >(), fn_( fn)
         {}
+};
 
- const id get_id() const
- { return id( lexical_cast< std::string >( impl_.get() ) ); }
-
- shared_future< R > get_future()
- { return shared_future< R >( impl_->fut); }
+template< typename Fn >
+class task_wrapper< void, Fn > : public task_base< void >
+{
+private:
+ Fn fn_;
 
- void swap( task< R > & other) // throw()
- { impl_.swap( other.impl_); }
+ void do_run()
+ {
+ try
+ {
+ fn_();
+ this->prom_.set_value();
+ }
+ catch ( promise_already_satisfied const&)
+ { throw task_already_executed(); }
+ catch ( thread_interrupted const&)
+ { this->prom_.set_exception( copy_exception( task_interrupted() ) ); }
+ catch ( boost::exception const& e)
+ { this->prom_.set_exception( copy_exception( e) ); }
+ catch ( std::ios_base::failure const& e)
+ { this->prom_.set_exception( copy_exception( e) ); }
+ catch ( std::domain_error const& e)
+ { this->prom_.set_exception( copy_exception( e) ); }
+ catch ( std::invalid_argument const& e)
+ { this->prom_.set_exception( copy_exception( e) ); }
+ catch ( std::length_error const& e)
+ { this->prom_.set_exception( copy_exception( e) ); }
+ catch ( std::out_of_range const& e)
+ { this->prom_.set_exception( copy_exception( e) ); }
+ catch ( std::logic_error const& e)
+ { this->prom_.set_exception( copy_exception( e) ); }
+ catch ( std::overflow_error const& e)
+ { this->prom_.set_exception( copy_exception( e) ); }
+ catch ( std::range_error const& e)
+ { this->prom_.set_exception( copy_exception( e) ); }
+ catch ( std::underflow_error const& e)
+ { this->prom_.set_exception( copy_exception( e) ); }
+ catch ( std::runtime_error const& e)
+ { this->prom_.set_exception( copy_exception( e) ); }
+ catch ( std::bad_alloc const& e)
+ { this->prom_.set_exception( copy_exception( e) ); }
+ catch ( std::bad_cast const& e)
+ { this->prom_.set_exception( copy_exception( e) ); }
+ catch ( std::bad_typeid const& e)
+ { this->prom_.set_exception( copy_exception( e) ); }
+ catch ( std::bad_exception const& e)
+ { this->prom_.set_exception( copy_exception( e) ); }
+ catch(...)
+ { this->prom_.set_exception( current_exception() ); }
+ }
 
- void operator()() // throw()
- { ( * impl_)(); }
+public:
+ task_wrapper( Fn const& fn)
+ : task_base< void >(), fn_( fn)
+ {}
 };
+}
 
-template<>
-class task< void >
+template< typename R >
+class task : private noncopyable
 {
 private:
         template< typename Channel >
@@ -149,133 +179,98 @@
 
         friend struct as_sub_task;
 
- struct impl
- {
- promise< void > prom;
- unique_future< void > fut;
-
- impl()
- :
- prom(),
- fut( prom.get_future() )
- {}
-
- virtual ~impl()
- {}
-
- virtual void operator()() = 0;
- };
+ shared_ptr< detail::task_base< R > > task_;
 
+public:
+ task()
+ : task_()
+ {}
+
         template< typename Fn >
- class impl_wrapper : public impl
- {
- private:
- Fn fn_;
-
- public:
- impl_wrapper( Fn const& fn)
- : fn_( fn)
- {}
+ explicit task( Fn const& fn)
+ : task_( new detail::task_wrapper< R, Fn >( fn) )
+ {}
+
+ explicit task( R( * fn)())
+ : task_( new detail::task_wrapper< R, R( *)() >( fn) )
+ {}
+
+ template< typename Fn >
+ explicit task( boost::detail::thread_move_t< Fn > fn)
+ : task_( new detail::task_wrapper< R, Fn >( fn) )
+ {}
 
- void operator()() // throw()
- {
- try
- {
- fn_();
- impl::prom.set_value();
- }
- catch ( promise_already_satisfied const&)
- { throw task_already_executed(); }
- catch ( thread_interrupted const&)
- { impl::prom.set_exception( copy_exception( task_interrupted() ) ); }
- catch ( boost::exception const& e)
- { impl::prom.set_exception( copy_exception( e) ); }
- catch ( std::ios_base::failure const& e)
- { impl::prom.set_exception( copy_exception( e) ); }
- catch ( std::domain_error const& e)
- { impl::prom.set_exception( copy_exception( e) ); }
- catch ( std::invalid_argument const& e)
- { impl::prom.set_exception( copy_exception( e) ); }
- catch ( std::length_error const& e)
- { impl::prom.set_exception( copy_exception( e) ); }
- catch ( std::out_of_range const& e)
- { impl::prom.set_exception( copy_exception( e) ); }
- catch ( std::logic_error const& e)
- { impl::prom.set_exception( copy_exception( e) ); }
- catch ( std::overflow_error const& e)
- { impl::prom.set_exception( copy_exception( e) ); }
- catch ( std::range_error const& e)
- { impl::prom.set_exception( copy_exception( e) ); }
- catch ( std::underflow_error const& e)
- { impl::prom.set_exception( copy_exception( e) ); }
- catch ( std::runtime_error const& e)
- { impl::prom.set_exception( copy_exception( e) ); }
- catch ( std::bad_alloc const& e)
- { impl::prom.set_exception( copy_exception( e) ); }
- catch ( std::bad_cast const& e)
- { impl::prom.set_exception( copy_exception( e) ); }
- catch ( std::bad_typeid const& e)
- { impl::prom.set_exception( copy_exception( e) ); }
- catch ( std::bad_exception const& e)
- { impl::prom.set_exception( copy_exception( e) ); }
- catch(...)
- { impl::prom.set_exception( current_exception() ); }
- }
- };
+# if defined(BOOST_HAS_RVALUE_REFS)
+ task( task && other)
+ : task_()
+ { task_.swap( other.task_); }
 
- shared_ptr< impl > impl_;
+ task & operator=( task && other)
+ {
+ task tmp( static_cast< task && >( other) );
+ swap( tmp);
+ return * this;
+ }
+
+ task && move()
+ { return static_cast< task && >( * this); }
+# else
+ task( boost::detail::thread_move_t< task > other)
+ : task_()
+ { task_.swap( other->task_); }
 
- template< typename F >
- void set_wait_callback( F const& f)
- { impl_->prom.set_wait_callback( f); }
+ task & operator=( boost::detail::thread_move_t< task > other)
+ {
+ task tmp( other);
+ swap( tmp);
+ return * this;
+ }
 
-public:
- template< typename Fn >
- task( Fn const& fn)
- : impl_( new impl_wrapper< Fn >( fn) )
- {}
+ operator boost::detail::thread_move_t< task >()
+ { return boost::detail::thread_move_t< task >( * this); }
+# endif
 
- const id get_id() const
- { return id( lexical_cast< std::string >( impl_.get() ) ); }
+ unique_future< R > get_future()
+ {
+ if ( ! task_)
+ throw task_moved();
+ return task_->get_future();
+ }
 
- shared_future< void > get_future()
- { return shared_future< void >( impl_->fut); }
+ void swap( task & other) // throw()
+ { task_.swap( other.task_); }
 
- void swap( task< void > & other) // throw()
- { impl_.swap( other.impl_); }
+ void operator()()
+ {
+ if ( ! task_)
+ throw task_moved();
+ task_->run();
+ }
 
- void operator()() // throw()
- { ( * impl_)(); }
+ template< typename Cb >
+ void set_wait_callback( Cb const& cb)
+ {
+ if ( ! task_)
+ throw task_moved();
+ task_->set_wait_callback( cb);
+ }
 };
+}
 
-template< typename Fn >
-task< typename result_of< Fn() >::type > make_task( Fn fn)
-{ return task< typename boost::result_of< Fn() >::type >( fn); }
+template< typename R >
+void swap( task::task< R > & l, task::task< R > & r)
+{ return l.swap( r); }
 
-# ifndef BOOST_TASK_MAKE_TASK_MAX_ARITY
-# define BOOST_TASK_MAKE_TASK_MAX_ARITY 10
+# if defined(BOOST_HAS_RVALUE_REFS)
+template< typename R >
+task::task< R > && move( task::task< R > && t)
+{ return t; }
+# else
+template< typename R >
+boost::detail::thread_move_t< task::task< R > > move( task::task< R > & t)
+{ return t; }
 # endif
-
-# define BOOST_TASK_MAKE_TASK_FUNC_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_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_MAKE_TASK_FUNC_ARGS(n)) \
-{ return make_task( boost::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, ~)
-
-# undef BOOST_TASK_MAKE_TASK_FUNCTION
-# undef BOOST_TASK_MAKE_TASK_FUNC_ARG
-# undef BOOST_ENUM_TASK_MAKE_TASK_FUNC_ARGS
-
-}}
+}
 
 #include <boost/config/abi_suffix.hpp>
 

Modified: sandbox/task/change.log
==============================================================================
--- sandbox/task/change.log (original)
+++ sandbox/task/change.log 2009-06-17 14:57:41 EDT (Wed, 17 Jun 2009)
@@ -6,5 +6,8 @@
 - async() with as_sub_task as default execution-policy
 - functions interrupt_and_wait_until() and interrupt_and_wait_for() from handle< R > returning
   boolean indicating if op. succeeded or timed out
+- move sematics for task< R >
+- move sematics for static_pool< R >
 - tests updated
-- documentation updated
\ No newline at end of file
+- examples updated
+- documentation updated

Modified: sandbox/task/libs/task/doc/overview.qbk
==============================================================================
--- sandbox/task/libs/task/doc/overview.qbk (original)
+++ sandbox/task/libs/task/doc/overview.qbk 2009-06-17 14:57:41 EDT (Wed, 17 Jun 2009)
@@ -129,7 +129,7 @@
 * Debian GNU/Linux 2.6.29.2 (x86_64), GCC 4.3.3
 * Ubuntu GNU/Linux 2.6.28.11 (x86), GCC 4.3.3
 * FreeBSD 7.2 (x86), GCC 4.2.1
-[/ * OpenSolaris 0811 (x86_64), SunCC 5.10 ]
+* OpenSolaris 2009.06 (x86_64), GCC 4.3.2
 * Windows XP Professional (x86), MSVC 9.0
 
 

Modified: sandbox/task/libs/task/examples/Jamfile.v2
==============================================================================
--- sandbox/task/libs/task/examples/Jamfile.v2 (original)
+++ sandbox/task/libs/task/examples/Jamfile.v2 2009-06-17 14:57:41 EDT (Wed, 17 Jun 2009)
@@ -23,7 +23,7 @@
 exe pending : pending.cpp ;
 exe priority : priority.cpp ;
 exe reschedule_until : reschedule_until.cpp ;
-exe shutdonw_now : shutdonw_now.cpp ;
+exe shutdonw_now : shutdown_now.cpp ;
 exe smart : smart.cpp ;
 exe submit : submit.cpp ;
 exe yield : yield.cpp ;

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-06-17 14:57:41 EDT (Wed, 17 Jun 2009)
@@ -20,7 +20,7 @@
 
 typedef tsk::static_pool< tsk::unbounded_channel< tsk::fifo > > pool_type;
 
-long serial_fib( long n)
+int serial_fib( int n)
 {
         if( n < 2)
                 return n;
@@ -28,46 +28,31 @@
                 return serial_fib( n - 1) + serial_fib( n - 2);
 }
 
-class fib_task
+int parallel_fib( int n, int cutof)
 {
-private:
- long cutof_;
-
-public:
- fib_task( long cutof)
- : cutof_( cutof)
- {}
-
- long execute( long n)
+ if ( n < cutof)
         {
- if ( n < cutof_) return serial_fib( n);
- else
- {
- BOOST_ASSERT( boost::this_task::runs_in_pool() );
- tsk::handle< long > h1(
- tsk::async(
- tsk::make_task(
- & fib_task::execute,
- this,
- n - 1),
- boost::task::as_sub_task() ) ); // do not use this_task::get_pool() because it doesn't create as sub-task
- tsk::handle< long > h2(
- tsk::async(
- tsk::make_task(
- & fib_task::execute,
- this,
- n - 2),
- boost::task::as_sub_task() ) ); // do not use this_task::get_pool() because it doesn't create as sub-task
- return h1.get() + h2.get();
- }
+ return serial_fib( n);
+ }
+ else
+ {
+ BOOST_ASSERT( boost::this_task::runs_in_pool() );
+ tsk::task< int > t1(
+ boost::bind(
+ parallel_fib,
+ n - 1,
+ cutof) );
+ tsk::task< int > t2(
+ boost::bind(
+ parallel_fib,
+ n - 2,
+ cutof) );
+ tsk::handle< int > h1(
+ tsk::async( boost::move( t1), tsk::as_sub_task() ) );
+ tsk::handle< int > h2(
+ tsk::async( boost::move( t2), tsk::as_sub_task() ) );
+ return h1.get() + h2.get();
         }
-};
-
-
-long parallel_fib( long n)
-{
- fib_task a( 5);
- return a.execute( n);
 }
 
 int main( int argc, char *argv[])
@@ -75,34 +60,34 @@
 # if defined(BOOST_HAS_PROCESSOR_BINDINGS)
         try
         {
- pool_type pool;
+ pool_type pool( pool_type::bind_to_processors() );
 
- std::vector< tsk::handle< long > > results;
+ std::vector< tsk::handle< int > > results;
                 results.reserve( 10);
 
- pt::ptime start( pt::microsec_clock::universal_time() );
-
                 for ( int i = 0; i < 10; ++i)
+ {
+ tsk::task< int > t(
+ boost::bind(
+ & parallel_fib,
+ i,
+ 5) );
                         results.push_back(
                                 tsk::async(
- tsk::make_task(
- & parallel_fib,
- i),
+ boost::move( t),
                                         pool) );
+ }
 
                 tsk::waitfor_all( results.begin(), results.end() );
 
                 int k = 0;
- std::vector< tsk::handle< long > >::iterator e( results.end() );
+ std::vector< tsk::handle< int > >::iterator e( results.end() );
                 for (
- std::vector< tsk::handle< long > >::iterator i( results.begin() );
- i != e;
- ++i)
+ std::vector< tsk::handle< int > >::iterator i( results.begin() );
+ i != e;
+ ++i)
                         std::cout << "fibonacci(" << k++ << ") == " << i->get() << std::endl;
 
- pt::ptime stop( pt::microsec_clock::universal_time() );
- std::cout << ( stop - start).total_milliseconds() << " milli seconds" << std::endl;
-
                 return EXIT_SUCCESS;
         }
         catch ( std::exception const& e)
@@ -115,3 +100,4 @@
         return EXIT_FAILURE;
 }
 
+

Modified: sandbox/task/libs/task/examples/delay.cpp
==============================================================================
--- sandbox/task/libs/task/examples/delay.cpp (original)
+++ sandbox/task/libs/task/examples/delay.cpp 2009-06-17 14:57:41 EDT (Wed, 17 Jun 2009)
@@ -17,7 +17,7 @@
 namespace pt = boost::posix_time;
 namespace tsk = boost::task;
 
-long serial_fib( long n)
+int serial_fib( int n)
 {
         if( n < 2)
                 return n;
@@ -25,7 +25,7 @@
                 return serial_fib( n - 1) + serial_fib( n - 2);
 }
 
-long parallel_fib_( long n, long cutof)
+int parallel_fib_( int n, int cutof)
 {
         if ( n < cutof)
         {
@@ -36,28 +36,28 @@
         else
         {
                 BOOST_ASSERT( boost::this_task::runs_in_pool() );
- tsk::handle< long > h1(
- tsk::async(
- tsk::make_task(
- parallel_fib_,
- n - 1,
- cutof),
- tsk::as_sub_task() ) ) ;
- tsk::handle< long > h2(
- tsk::async(
- tsk::make_task(
- parallel_fib_,
- n - 2,
- cutof),
- tsk::as_sub_task() ) );
+ tsk::task< int > t1(
+ boost::bind(
+ parallel_fib_,
+ n - 1,
+ cutof) );
+ tsk::task< int > t2(
+ boost::bind(
+ parallel_fib_,
+ n - 2,
+ cutof) );
+ tsk::handle< int > h1(
+ tsk::async( boost::move( t1), tsk::as_sub_task() ) );
+ tsk::handle< int > h2(
+ tsk::async( boost::move( t2), tsk::as_sub_task() ) );
                 return h1.get() + h2.get();
         }
 }
 
-void parallel_fib( long n)
+void parallel_fib( int n)
 {
- long result = parallel_fib_( n, 5);
- printf("fibonnaci(%ld) == %ld\n", n, result);
+ int result = parallel_fib_( n, 5);
+ printf("fibonnaci(%d) == %d\n", n, result);
 }
 
 int main( int argc, char *argv[])
@@ -65,11 +65,15 @@
         try
         {
                 for ( int i = 0; i < 10; ++i)
- tsk::async(
- tsk::make_task(
+ {
+ tsk::task< void > t(
+ boost::bind(
                                         & parallel_fib,
- i),
+ i) );
+ tsk::async(
+ boost::move( t),
                                 tsk::default_pool() );
+ }
 
                 return EXIT_SUCCESS;
         }

Modified: sandbox/task/libs/task/examples/fork_join.cpp
==============================================================================
--- sandbox/task/libs/task/examples/fork_join.cpp (original)
+++ sandbox/task/libs/task/examples/fork_join.cpp 2009-06-17 14:57:41 EDT (Wed, 17 Jun 2009)
@@ -19,7 +19,7 @@
 
 typedef tsk::static_pool< tsk::unbounded_channel< tsk::fifo > > pool_type;
 
-long serial_fib( long n)
+int serial_fib( int n)
 {
         if( n < 2)
                 return n;
@@ -27,25 +27,29 @@
                 return serial_fib( n - 1) + serial_fib( n - 2);
 }
 
-long parallel_fib( long n, long cutof)
+int parallel_fib( int n, int cutof)
 {
         if ( n < cutof) return serial_fib( n);
         else
         {
                 BOOST_ASSERT( boost::this_task::runs_in_pool() );
- tsk::handle< long > h1(
+ tsk::task< int > t1(
+ boost::bind(
+ parallel_fib,
+ n - 1,
+ cutof) );
+ tsk::task< int > t2(
+ boost::bind(
+ parallel_fib,
+ n - 2,
+ cutof) );
+ tsk::handle< int > h1(
                         tsk::async(
- tsk::make_task(
- parallel_fib,
- n - 1,
- cutof),
+ boost::move( t1),
                                 tsk::as_sub_task() ) ) ;
- tsk::handle< long > h2(
+ tsk::handle< int > h2(
                         tsk::async(
- tsk::make_task(
- parallel_fib,
- n - 2,
- cutof),
+ boost::move( t2),
                                 tsk::as_sub_task() ) );
                 return h1.get() + h2.get();
         }
@@ -57,26 +61,30 @@
         {
                 pool_type pool( tsk::poolsize( 5) );
 
- std::vector< tsk::handle< long > > results;
+ std::vector< tsk::handle< int > > results;
                 results.reserve( 10);
 
                 pt::ptime start( pt::microsec_clock::universal_time() );
 
                 for ( int i = 0; i < 10; ++i)
+ {
+ tsk::task< int > t(
+ boost::bind(
+ & parallel_fib,
+ i,
+ 5) );
                         results.push_back(
                                 tsk::async(
- tsk::make_task(
- & parallel_fib,
- i,
- 5),
+ boost::move( t),
                                         pool) );
+ }
 
                 tsk::waitfor_all( results.begin(), results.end() );
 
                 int k = 0;
- std::vector< tsk::handle< long > >::iterator e( results.end() );
+ std::vector< tsk::handle< int > >::iterator e( results.end() );
                 for (
- std::vector< tsk::handle< long > >::iterator i( results.begin() );
+ std::vector< tsk::handle< int > >::iterator i( results.begin() );
                         i != e;
                         ++i)
                         std::cout << "fibonacci(" << k++ << ") == " << i->get() << std::endl;

Modified: sandbox/task/libs/task/examples/interrupt.cpp
==============================================================================
--- sandbox/task/libs/task/examples/interrupt.cpp (original)
+++ sandbox/task/libs/task/examples/interrupt.cpp 2009-06-17 14:57:41 EDT (Wed, 17 Jun 2009)
@@ -42,17 +42,20 @@
 {
         try
         {
+ tsk::task< void > t1( long_running_fn);
+ tsk::task< int > t2(
+ boost::bind(
+ fibonacci_fn,
+ 10) );
                 tsk::async(
- tsk::make_task( long_running_fn),
+ boost::move( t1),
                         tsk::default_pool() );
                 std::cout << "poolsize == " << tsk::default_pool().size() << std::endl;
                 std::cout << "idle threads == " << tsk::default_pool().idle() << std::endl;
                 std::cout << "active threads == " << tsk::default_pool().active() << std::endl;
                 tsk::handle< int > h(
                         tsk::async(
- tsk::make_task(
- fibonacci_fn,
- 10),
+ boost::move( t2),
                                 tsk::default_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-06-17 14:57:41 EDT (Wed, 17 Jun 2009)
@@ -43,14 +43,17 @@
 {
         try
         {
+ tsk::task< void > t1( long_running_fn);
                 tsk::async(
- tsk::make_task( long_running_fn),
+ boost::move( t1),
                         tsk::default_pool() );
+ tsk::task< int > t2(
+ boost::bind(
+ fibonacci_fn,
+ 10) );
                 tsk::handle< int > h(
                         tsk::async(
- tsk::make_task(
- fibonacci_fn,
- 10),
+ boost::move( t2),
                                 tsk::default_pool() ) );
                 std::cout << "pending tasks == " << tsk::default_pool().pending() << std::endl;
                 std::cout << h.get() << std::endl;

Modified: sandbox/task/libs/task/examples/priority.cpp
==============================================================================
--- sandbox/task/libs/task/examples/priority.cpp (original)
+++ sandbox/task/libs/task/examples/priority.cpp 2009-06-17 14:57:41 EDT (Wed, 17 Jun 2009)
@@ -33,27 +33,34 @@
                         tsk::unbounded_channel< tsk::priority< int > >
> pool( tsk::poolsize( 1) );
 
+ tsk::task< void > t1( long_running_fn);
+ tsk::task< void > t2(
+ boost::bind(
+ print_fn,
+ "This") );
+ tsk::task< void > t3(
+ boost::bind(
+ print_fn,
+ "a text.\n") );
+ tsk::task< void > t4(
+ boost::bind(
+ print_fn,
+ " is ") );
+
                 tsk::async(
- tsk::make_task(
- long_running_fn),
+ boost::move( t1),
                         0,
                         pool);
                 tsk::async(
- tsk::make_task(
- print_fn,
- "This"),
+ boost::move( t2),
                         0,
                         pool);
                 tsk::async(
- tsk::make_task(
- print_fn,
- "a text.\n"),
+ boost::move( t3),
                         2,
                         pool);
                 tsk::async(
- tsk::make_task(
- print_fn,
- " is "),
+ boost::move( t4),
                         1,
                         pool);
 

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-06-17 14:57:41 EDT (Wed, 17 Jun 2009)
@@ -33,7 +33,7 @@
 namespace pt = boost::posix_time;
 namespace tsk = boost::task;
 
-long serial_fib( long n)
+int serial_fib( int n)
 {
         if( n < 2)
                 return n;
@@ -41,45 +41,41 @@
                 return serial_fib( n - 1) + serial_fib( n - 2);
 }
 
-class fib_task
+int parallel_fib_( int n, int cutof)
 {
-private:
- long cutof_;
+ if ( n == 4)
+ boost::this_task::yield();
 
-public:
- fib_task( long cutof)
- : cutof_( cutof)
- {}
-
- long execute( long n)
+ if ( n < cutof)
         {
- if ( n < cutof_) return serial_fib( n);
- else
- {
- BOOST_ASSERT( boost::this_task::runs_in_pool() );
- tsk::handle< long > h1(
- tsk::async(
- tsk::make_task(
- & fib_task::execute,
- boost::ref( * this),
- n - 1),
- tsk::as_sub_task() ) );
- tsk::handle< long > h2(
- tsk::async(
- tsk::make_task(
- & fib_task::execute,
- boost::ref( * this),
- n - 2),
- tsk::as_sub_task() ) );
- return h1.get() + h2.get();
- }
+ if ( n == 0)
+ boost::this_task::delay( pt::seconds( 2) );
+ return serial_fib( n);
         }
-};
+ else
+ {
+ BOOST_ASSERT( boost::this_task::runs_in_pool() );
+ tsk::task< int > t1(
+ boost::bind(
+ parallel_fib_,
+ n - 1,
+ cutof) );
+ tsk::task< int > t2(
+ boost::bind(
+ parallel_fib_,
+ n - 2,
+ cutof) );
+ tsk::handle< int > h1(
+ tsk::async( boost::move( t1), tsk::as_sub_task() ) );
+ tsk::handle< int > h2(
+ tsk::async( boost::move( t2), tsk::as_sub_task() ) );
+ return h1.get() + h2.get();
+ }
+}
 
-void parallel_fib( long n)
+void parallel_fib( int n)
 {
- fib_task a( 5);
- printf("fibonacci(%d) == %ld\n", n, a.execute( n) );
+ printf("fibonacci(%d) == %d\n", n, parallel_fib_( n, 5) );
 }
 
 # if defined(BOOST_POSIX_API)
@@ -151,21 +147,28 @@
                 int fd[2];
                 create_sockets( fd);
 
- tsk::async(
- tsk::make_task(
+ tsk::task< void > t1(
+ boost::bind(
                                 & do_read,
- fd[0]),
+ fd[0]) );
+
+ tsk::async(
+ boost::move( t1),
                         tsk::default_pool() );
 
                 do_write( fd[1], "Hello ");
                 boost::this_thread::sleep( pt::seconds( 1) );
 
                 for ( int i = 0; i < 10; ++i)
- tsk::async(
- tsk::make_task(
+ {
+ tsk::task< void > t(
+ boost::bind(
                                         & parallel_fib,
- i),
+ i) );
+ tsk::async(
+ boost::move( t),
                                 tsk::default_pool() );
+ }
 
                 do_write( fd[1], "World!");
 

Deleted: sandbox/task/libs/task/examples/shutdonw_now.cpp
==============================================================================
--- sandbox/task/libs/task/examples/shutdonw_now.cpp 2009-06-17 14:57:41 EDT (Wed, 17 Jun 2009)
+++ (empty file)
@@ -1,70 +0,0 @@
-
-// 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 <iostream>
-#include <cstdlib>
-#include <stdexcept>
-#include <vector>
-
-#include <boost/bind.hpp>
-#include <boost/date_time/posix_time/posix_time.hpp>
-#include <boost/ref.hpp>
-
-#include "boost/task.hpp"
-
-namespace pt = boost::posix_time;
-namespace tsk = boost::task;
-
-inline
-int fibonacci_fn( int n)
-{
- boost::this_thread::sleep( pt::milliseconds( 500) );
- if ( n == 0) return 0;
- if ( n == 1) return 1;
- int k1( 1), k2( 0);
- for ( int i( 2); i <= n; ++i)
- {
- boost::this_thread::interruption_point();
- int tmp( k1);
- k1 = k1 + k2;
- k2 = tmp;
- }
- boost::this_thread::interruption_point();
- return k1;
-}
-
-int main( int argc, char *argv[])
-{
- try
- {
- tsk::static_pool<
- tsk::unbounded_channel< tsk::fifo >
- > pool( tsk::poolsize( 1) );
-
- tsk::handle< int > h(
- tsk::async(
- tsk::make_task(
- fibonacci_fn,
- 10),
- pool) );
-
- boost::this_thread::sleep( pt::milliseconds( 250) );
-
- pool.shutdown_now();
-
- std::cout << h.get() << std::endl;
-
- return EXIT_SUCCESS;
- }
- catch ( tsk::task_interrupted const& )
- { std::cerr << "task_interrupted: task was interrupted" << std::endl; }
- catch ( std::exception const& e)
- { std::cerr << "exception: " << e.what() << std::endl; }
- catch ( ... )
- { std::cerr << "unhandled" << std::endl; }
-
- return EXIT_FAILURE;
-}

Added: sandbox/task/libs/task/examples/shutdown_now.cpp
==============================================================================
--- (empty file)
+++ sandbox/task/libs/task/examples/shutdown_now.cpp 2009-06-17 14:57:41 EDT (Wed, 17 Jun 2009)
@@ -0,0 +1,73 @@
+
+// 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 <iostream>
+#include <cstdlib>
+#include <stdexcept>
+#include <vector>
+
+#include <boost/bind.hpp>
+#include <boost/date_time/posix_time/posix_time.hpp>
+#include <boost/ref.hpp>
+
+#include "boost/task.hpp"
+
+namespace pt = boost::posix_time;
+namespace tsk = boost::task;
+
+inline
+int fibonacci_fn( int n)
+{
+ boost::this_thread::sleep( pt::milliseconds( 500) );
+ if ( n == 0) return 0;
+ if ( n == 1) return 1;
+ int k1( 1), k2( 0);
+ for ( int i( 2); i <= n; ++i)
+ {
+ boost::this_thread::interruption_point();
+ int tmp( k1);
+ k1 = k1 + k2;
+ k2 = tmp;
+ }
+ boost::this_thread::interruption_point();
+ return k1;
+}
+
+int main( int argc, char *argv[])
+{
+ try
+ {
+ tsk::static_pool<
+ tsk::unbounded_channel< tsk::fifo >
+ > pool( tsk::poolsize( 1) );
+
+ tsk::task< int > t(
+ boost::bind(
+ fibonacci_fn,
+ 10) );
+
+ tsk::handle< int > h(
+ tsk::async(
+ boost::move( t),
+ pool) );
+
+ boost::this_thread::sleep( pt::milliseconds( 250) );
+
+ pool.shutdown_now();
+
+ std::cout << h.get() << std::endl;
+
+ return EXIT_SUCCESS;
+ }
+ catch ( tsk::task_interrupted const& )
+ { std::cerr << "task_interrupted: task was interrupted" << std::endl; }
+ catch ( std::exception const& e)
+ { std::cerr << "exception: " << e.what() << std::endl; }
+ catch ( ... )
+ { std::cerr << "unhandled" << std::endl; }
+
+ return EXIT_FAILURE;
+}

Modified: sandbox/task/libs/task/examples/smart.cpp
==============================================================================
--- sandbox/task/libs/task/examples/smart.cpp (original)
+++ sandbox/task/libs/task/examples/smart.cpp 2009-06-17 14:57:41 EDT (Wed, 17 Jun 2009)
@@ -59,27 +59,34 @@
>
> pool( tsk::poolsize( 1) );
 
+ tsk::task< void > t1( long_running_fn);
+ tsk::task< void > t2(
+ boost::bind(
+ fibonacci_fn,
+ 0) );
+ tsk::task< void > t3(
+ boost::bind(
+ fibonacci_fn,
+ 1) );
+ tsk::task< void > t4(
+ boost::bind(
+ fibonacci_fn,
+ 10) );
+
                 tsk::async(
- tsk::make_task(
- long_running_fn),
+ boost::move( t1),
                         0,
                         pool);
                 tsk::async(
- tsk::make_task(
- fibonacci_fn,
- 0),
+ boost::move( t2),
                         1,
                         pool);
                 tsk::async(
- tsk::make_task(
- fibonacci_fn,
- 1),
+ boost::move( t3),
                         2,
                         pool);
                 tsk::async(
- tsk::make_task(
- fibonacci_fn,
- 10),
+ boost::move( t4),
                         2,
                         pool);
 

Modified: sandbox/task/libs/task/examples/submit.cpp
==============================================================================
--- sandbox/task/libs/task/examples/submit.cpp (original)
+++ sandbox/task/libs/task/examples/submit.cpp 2009-06-17 14:57:41 EDT (Wed, 17 Jun 2009)
@@ -35,33 +35,43 @@
 {
         try
         {
+ tsk::static_pool<
+ tsk::unbounded_channel< tsk::priority< int > >
+ > pool( tsk::poolsize( 3) );
+
+ tsk::task< int > t1(
+ boost::bind(
+ fibonacci_fn,
+ 10) );
+ tsk::task< int > t2(
+ boost::bind(
+ fibonacci_fn,
+ 10) );
+ tsk::task< int > t3(
+ boost::bind(
+ fibonacci_fn,
+ 10) );
+ tsk::task< int > t4(
+ boost::bind(
+ fibonacci_fn,
+ 10) );
+
                 tsk::handle< int > h1(
- tsk::async(
- tsk::make_task(
- fibonacci_fn,
- 10) ) );
+ tsk::async( boost::move( t1) ) );
                 tsk::handle< int > h2(
                         tsk::async(
- tsk::make_task(
- fibonacci_fn,
- 10),
+ boost::move( t2),
                                 tsk::new_thread() ) );
                 tsk::handle< int > h3(
                         tsk::async(
- tsk::make_task(
- fibonacci_fn,
- 10),
+ boost::move( t3),
                                 tsk::default_pool() ) );
- tsk::static_pool<
- tsk::unbounded_channel< tsk::priority< int > >
- > pool( tsk::poolsize( 3) );
                 tsk::handle< int > h4(
                         tsk::async(
- tsk::make_task(
- fibonacci_fn,
- 10),
+ boost::move( t4),
                                 2,
                                 pool) );
+
                 std::cout << h1.get() << std::endl;
                 std::cout << h2.get() << std::endl;
                 std::cout << h3.get() << std::endl;

Modified: sandbox/task/libs/task/examples/yield.cpp
==============================================================================
--- sandbox/task/libs/task/examples/yield.cpp (original)
+++ sandbox/task/libs/task/examples/yield.cpp 2009-06-17 14:57:41 EDT (Wed, 17 Jun 2009)
@@ -20,7 +20,7 @@
 
 typedef tsk::default_pool_t pool_type;
 
-long serial_fib( long n)
+int serial_fib( int n)
 {
         if( n < 2)
                 return n;
@@ -28,51 +28,42 @@
                 return serial_fib( n - 1) + serial_fib( n - 2);
 }
 
-class fib_task
+int parallel_fib_( int n, int cutof)
 {
-private:
- long cutof_;
+ if ( n == 4)
+ boost::this_task::yield();
 
-public:
- fib_task( long cutof)
- : cutof_( cutof)
- {}
-
- long execute( long n)
+ if ( n < cutof)
         {
- if ( n == 4)
- boost::this_task::yield();
-
- if ( n < cutof_)
- return serial_fib( n);
- else
- {
- BOOST_ASSERT( boost::this_task::runs_in_pool() );
- tsk::handle< long > h1(
- tsk::async(
- tsk::make_task(
- & fib_task::execute,
- boost::ref( * this),
- n - 1),
- tsk::as_sub_task() ) );
- tsk::handle< long > h2(
- tsk::async(
- tsk::make_task(
- & fib_task::execute,
- boost::ref( * this),
- n - 2),
- tsk::as_sub_task() ) );
- return h1.get() + h2.get();
- }
+ if ( n == 0)
+ boost::this_task::delay( pt::seconds( 2) );
+ return serial_fib( n);
         }
-};
-
+ else
+ {
+ BOOST_ASSERT( boost::this_task::runs_in_pool() );
+ tsk::task< int > t1(
+ boost::bind(
+ parallel_fib_,
+ n - 1,
+ cutof) );
+ tsk::task< int > t2(
+ boost::bind(
+ parallel_fib_,
+ n - 2,
+ cutof) );
+ tsk::handle< int > h1(
+ tsk::async( boost::move( t1), tsk::as_sub_task() ) );
+ tsk::handle< int > h2(
+ tsk::async( boost::move( t2), tsk::as_sub_task() ) );
+ return h1.get() + h2.get();
+ }
+}
 
-void parallel_fib( long n)
+void parallel_fib( int n)
 {
- fib_task a( 5);
- long result = a.execute( n);
- printf("fibonnaci(%ld) == %d\n", n, result);
+ int result = parallel_fib_( n, 5);
+ printf("fibonnaci(%d) == %d\n", n, result);
 }
 
 int main( int argc, char *argv[])
@@ -80,11 +71,15 @@
         try
         {
                 for ( int i = 0; i < 10; ++i)
- tsk::async(
- tsk::make_task(
+ {
+ tsk::task< void > t(
+ boost::bind(
                                         & parallel_fib,
- i),
+ i) );
+ tsk::async(
+ boost::move( t),
                                 tsk::default_pool() );
+ }
 
                 return EXIT_SUCCESS;
         }

Modified: sandbox/task/libs/task/test/Jamfile.v2
==============================================================================
--- sandbox/task/libs/task/test/Jamfile.v2 (original)
+++ sandbox/task/libs/task/test/Jamfile.v2 2009-06-17 14:57:41 EDT (Wed, 17 Jun 2009)
@@ -26,6 +26,7 @@
 
 test-suite task :
     [ task-test test_futures ]
+ [ task-test test_task ]
     [ task-test test_own_thread ]
     [ task-test test_new_thread ]
     [ task-test test_default_pool ]

Modified: sandbox/task/libs/task/test/test_bounded_pool.cpp
==============================================================================
--- sandbox/task/libs/task/test/test_bounded_pool.cpp (original)
+++ sandbox/task/libs/task/test/test_bounded_pool.cpp 2009-06-17 14:57:41 EDT (Wed, 17 Jun 2009)
@@ -35,57 +35,60 @@
         {
                 tsk::static_pool<
                         tsk::bounded_channel< tsk::fifo >
- > pool(
+ > pool1(
                         tsk::poolsize( 3),
                         tsk::high_watermark( 10),
- tsk::low_watermark( 10) );
- BOOST_CHECK_EQUAL( pool.size(), std::size_t( 3) );
- BOOST_CHECK_EQUAL( pool.idle(), std::size_t( 3) );
- BOOST_CHECK_EQUAL( pool.active(), std::size_t( 0) );
- }
+ tsk::low_watermark( 5) );
+ BOOST_CHECK_EQUAL( pool1.size(), std::size_t( 3) );
+ BOOST_CHECK_EQUAL( pool1.idle(), std::size_t( 3) );
+ BOOST_CHECK_EQUAL( pool1.active(), std::size_t( 0) );
+ BOOST_CHECK_EQUAL( pool1.upper_bound(), std::size_t( 10) );
+ BOOST_CHECK_EQUAL( pool1.lower_bound(), std::size_t( 5) );
 
- // check submit
- void test_case_2()
- {
                 tsk::static_pool<
                         tsk::bounded_channel< tsk::fifo >
- > pool(
- tsk::poolsize( 1),
- tsk::high_watermark( 10),
- tsk::low_watermark( 10) );
- tsk::handle< int > h(
- tsk::async(
- tsk::make_task(
- fibonacci_fn,
- 10),
- pool) );
- BOOST_CHECK_EQUAL( h.get(), 55);
+ > pool2;
+ BOOST_CHECK_THROW( pool2.size(), tsk::pool_moved);
+ BOOST_CHECK_THROW( pool2.idle(), tsk::pool_moved);
+ BOOST_CHECK_THROW( pool2.active(), tsk::pool_moved);
+ BOOST_CHECK_THROW( pool2.upper_bound(), tsk::pool_moved);
+ BOOST_CHECK_THROW( pool2.lower_bound(), tsk::pool_moved);
+
+ pool2 = boost::move( pool1);
+
+ BOOST_CHECK_THROW( pool1.size(), tsk::pool_moved);
+ BOOST_CHECK_THROW( pool1.idle(), tsk::pool_moved);
+ BOOST_CHECK_THROW( pool1.active(), tsk::pool_moved);
+ BOOST_CHECK_THROW( pool1.upper_bound(), tsk::pool_moved);
+ BOOST_CHECK_THROW( pool1.lower_bound(), tsk::pool_moved);
+
+ BOOST_CHECK_EQUAL( pool2.size(), std::size_t( 3) );
+ BOOST_CHECK_EQUAL( pool2.idle(), std::size_t( 3) );
+ BOOST_CHECK_EQUAL( pool2.active(), std::size_t( 0) );
+ BOOST_CHECK_EQUAL( pool2.upper_bound(), std::size_t( 10) );
+ BOOST_CHECK_EQUAL( pool2.lower_bound(), std::size_t( 5) );
         }
 
- // check id
- void test_case_3()
+ // check submit
+ void test_case_2()
         {
                 tsk::static_pool<
                         tsk::bounded_channel< tsk::fifo >
> pool(
- tsk::poolsize( 5),
+ tsk::poolsize( 1),
                         tsk::high_watermark( 10),
                         tsk::low_watermark( 10) );
-
                 tsk::task< int > t(
- tsk::make_task(
+ boost::bind(
                                 fibonacci_fn,
                                 10) );
                 tsk::handle< int > h(
- tsk::async(
- t,
- pool) );
- BOOST_CHECK_EQUAL( h.get_id(), t.get_id() );
+ tsk::async( boost::move( t), pool) );
                 BOOST_CHECK_EQUAL( h.get(), 55);
         }
 
         // check assignment
- void test_case_4()
+ void test_case_3()
         {
                 tsk::static_pool<
                         tsk::bounded_channel< tsk::fifo >
@@ -93,22 +96,20 @@
                         tsk::poolsize( 5),
                         tsk::high_watermark( 10),
                         tsk::low_watermark( 10) );
-
+ tsk::task< int > t(
+ boost::bind(
+ fibonacci_fn,
+ 10) );
                 tsk::handle< int > h1;
                 tsk::handle< int > h2(
- tsk::async(
- tsk::make_task(
- fibonacci_fn,
- 10),
- pool) );
+ tsk::async( boost::move( t), pool) );
                 h1 = h2;
- BOOST_CHECK_EQUAL( h1.get_id(), h2.get_id() );
                 BOOST_CHECK_EQUAL( h1.get(), 55);
                 BOOST_CHECK_EQUAL( h2.get(), 55);
         }
 
         // check swap
- void test_case_5()
+ void test_case_4()
         {
                 tsk::static_pool<
                         tsk::bounded_channel< tsk::fifo >
@@ -116,19 +117,18 @@
                         tsk::poolsize( 5),
                         tsk::high_watermark( 10),
                         tsk::low_watermark( 10) );
-
+ tsk::task< int > t1(
+ boost::bind(
+ fibonacci_fn,
+ 5) );
+ tsk::task< int > t2(
+ boost::bind(
+ fibonacci_fn,
+ 10) );
                 tsk::handle< int > h1(
- tsk::async(
- tsk::make_task(
- fibonacci_fn,
- 5),
- pool) );
+ tsk::async( boost::move( t1), pool) );
                 tsk::handle< int > h2(
- tsk::async(
- tsk::make_task(
- fibonacci_fn,
- 10),
- pool) );
+ tsk::async( boost::move( t2), pool) );
                 BOOST_CHECK_EQUAL( h1.get(), 5);
                 BOOST_CHECK_EQUAL( h2.get(), 55);
                 BOOST_CHECK_NO_THROW( h1.swap( h2) );
@@ -137,7 +137,7 @@
         }
         
         // check runs in pool
- void test_case_6()
+ void test_case_5()
         {
                 tsk::static_pool<
                         tsk::bounded_channel< tsk::fifo >
@@ -145,15 +145,14 @@
                         tsk::poolsize( 1),
                         tsk::high_watermark( 10),
                         tsk::low_watermark( 10) );
+ tsk::task< bool > t( runs_in_pool_fn);
                 tsk::handle< bool > h(
- tsk::async(
- tsk::make_task( runs_in_pool_fn),
- pool) );
+ tsk::async( boost::move( t), pool) );
                 BOOST_CHECK_EQUAL( h.get(), true);
         }
 
         // check shutdown
- void test_case_7()
+ void test_case_6()
         {
                 tsk::static_pool<
                         tsk::bounded_channel< tsk::fifo >
@@ -161,19 +160,19 @@
                         tsk::poolsize( 1),
                         tsk::high_watermark( 10),
                         tsk::low_watermark( 10) );
+ tsk::task< int > t(
+ boost::bind(
+ fibonacci_fn,
+ 10) );
                 tsk::handle< int > h(
- tsk::async(
- tsk::make_task(
- fibonacci_fn,
- 10),
- pool) );
+ tsk::async( boost::move( t), pool) );
                 pool.shutdown();
                 BOOST_CHECK( pool.closed() );
                 BOOST_CHECK_EQUAL( h.get(), 55);
         }
 
         // check runtime_error throw inside task
- void test_case_8()
+ void test_case_7()
         {
                 tsk::static_pool<
                         tsk::bounded_channel< tsk::fifo >
@@ -181,16 +180,15 @@
                         tsk::poolsize( 1),
                         tsk::high_watermark( 10),
                         tsk::low_watermark( 10) );
+ tsk::task< void > t( throwing_fn);
                 tsk::handle< void > h(
- tsk::async(
- tsk::make_task( throwing_fn),
- pool) );
+ tsk::async( boost::move( t), pool) );
                 pool.shutdown();
                 BOOST_CHECK_THROW( h.get(), std::runtime_error);
         }
 
         // check shutdown with task_rejected exception
- void test_case_9()
+ void test_case_8()
         {
                 tsk::static_pool<
                         tsk::bounded_channel< tsk::fifo >
@@ -198,20 +196,19 @@
                         tsk::poolsize( 1),
                         tsk::high_watermark( 10),
                         tsk::low_watermark( 10) );
+ tsk::task< int > t(
+ boost::bind(
+ fibonacci_fn,
+ 10) );
                 pool.shutdown();
                 BOOST_CHECK( pool.closed() );
                 BOOST_CHECK_THROW(
- tsk::async(
- tsk::make_task(
- boost::bind(
- fibonacci_fn,
- 10) ),
- pool),
+ tsk::async( boost::move( t), pool),
                         tsk::task_rejected);
         }
 
         // check shutdown_now with thread_interrupted exception
- void test_case_10()
+ void test_case_9()
         {
                 tsk::static_pool<
                         tsk::bounded_channel< tsk::fifo >
@@ -219,12 +216,12 @@
                         tsk::poolsize( 1),
                         tsk::high_watermark( 1),
                         tsk::low_watermark( 1) );
+ tsk::task< void > t(
+ boost::bind(
+ delay_fn,
+ pt::millisec( 500) ) );
                 tsk::handle< void > h(
- tsk::async(
- tsk::make_task(
- delay_fn,
- pt::millisec( 500) ),
- pool) );
+ tsk::async( boost::move( t), pool) );
                 boost::this_thread::sleep( pt::millisec( 250) );
                 BOOST_CHECK_EQUAL( pool.size(), std::size_t( 1) );
                 pool.shutdown_now();
@@ -236,7 +233,7 @@
         }
 
         // check pending
- void test_case_11()
+ void test_case_10()
         {
                 typedef tsk::static_pool<
                         tsk::bounded_channel< tsk::fifo >
@@ -246,28 +243,28 @@
                         tsk::high_watermark( 10),
                         tsk::low_watermark( 10) );
                 boost::barrier b( 2);
+ tsk::task< void > t1(
+ boost::bind(
+ barrier_fn,
+ boost::ref( b) ) );
+ tsk::task< int > t2(
+ boost::bind(
+ fibonacci_fn,
+ 10) );
+ tsk::task< int > t3(
+ boost::bind(
+ fibonacci_fn,
+ 10) );
                 tsk::handle< void > h1(
- tsk::async(
- tsk::make_task(
- barrier_fn,
- boost::ref( b) ),
- pool) );
+ tsk::async( boost::move( t1), pool) );
                 boost::this_thread::sleep( pt::millisec( 250) );
                 BOOST_CHECK_EQUAL( pool.pending(), std::size_t( 0) );
                 tsk::handle< int > h2(
- tsk::async(
- tsk::make_task(
- fibonacci_fn,
- 10),
- pool) );
+ tsk::async( boost::move( t2), pool) );
                 boost::this_thread::sleep( pt::millisec(250) );
                 BOOST_CHECK_EQUAL( pool.pending(), std::size_t( 1) );
                 tsk::handle< int > h3(
- tsk::async(
- tsk::make_task(
- fibonacci_fn,
- 10),
- pool) );
+ tsk::async( boost::move( t3), pool) );
                 boost::this_thread::sleep( pt::millisec(250) );
                 BOOST_CHECK_EQUAL( pool.pending(), std::size_t( 2) );
                 b.wait();
@@ -278,7 +275,7 @@
         }
 
         // check wait
- void test_case_12()
+ void test_case_11()
         {
                 tsk::static_pool<
                         tsk::bounded_channel< tsk::fifo >
@@ -286,12 +283,12 @@
                         tsk::poolsize( 5),
                         tsk::high_watermark( 1),
                         tsk::low_watermark( 1) );
+ tsk::task< int > t(
+ boost::bind(
+ fibonacci_fn,
+ 10) );
                 tsk::handle< int > h(
- tsk::async(
- tsk::make_task(
- fibonacci_fn,
- 10),
- pool) );
+ tsk::async( boost::move( t), pool) );
                 h.wait();
                 BOOST_CHECK( h.is_ready() );
                 BOOST_CHECK( h.has_value() );
@@ -300,7 +297,7 @@
         }
 
         // check wait_for
- void test_case_13()
+ void test_case_12()
         {
                 tsk::static_pool<
                         tsk::bounded_channel< tsk::fifo >
@@ -308,12 +305,12 @@
                         tsk::poolsize( 5),
                         tsk::high_watermark( 1),
                         tsk::low_watermark( 1) );
+ tsk::task< void > t(
+ boost::bind(
+ delay_fn,
+ pt::seconds( 1) ) );
                 tsk::handle< void > h(
- tsk::async(
- tsk::make_task(
- delay_fn,
- pt::seconds( 1) ),
- pool) );
+ tsk::async( boost::move( t), pool) );
                 BOOST_CHECK( h.wait_for( pt::seconds( 3) ) );
                 BOOST_CHECK( h.is_ready() );
                 BOOST_CHECK( h.has_value() );
@@ -321,7 +318,7 @@
         }
 
         // check wait_for
- void test_case_14()
+ void test_case_13()
         {
                 tsk::static_pool<
                         tsk::bounded_channel< tsk::fifo >
@@ -329,12 +326,12 @@
                         tsk::poolsize( 5),
                         tsk::high_watermark( 1),
                         tsk::low_watermark( 1) );
+ tsk::task< void > t(
+ boost::bind(
+ delay_fn,
+ pt::seconds( 3) ) );
                 tsk::handle< void > h(
- tsk::async(
- tsk::make_task(
- delay_fn,
- pt::seconds( 3) ),
- pool) );
+ tsk::async( boost::move( t), pool) );
                 BOOST_CHECK( ! h.wait_for( pt::seconds( 1) ) );
                 BOOST_CHECK( ! h.is_ready() );
                 BOOST_CHECK( ! h.has_value() );
@@ -342,7 +339,7 @@
         }
 
         // check wait_for
- void test_case_15()
+ void test_case_14()
         {
                 tsk::static_pool<
                         tsk::bounded_channel< tsk::fifo >
@@ -350,12 +347,12 @@
                         tsk::poolsize( 5),
                         tsk::high_watermark( 1),
                         tsk::low_watermark( 1) );
+ tsk::task< void > t(
+ boost::bind(
+ delay_fn,
+ pt::seconds( 1) ) );
                 tsk::handle< void > h(
- tsk::async(
- tsk::make_task(
- delay_fn,
- pt::seconds( 1) ),
- pool) );
+ tsk::async( boost::move( t), pool) );
                 BOOST_CHECK( h.wait_until( boost::get_system_time() + pt::seconds( 3) ) );
                 BOOST_CHECK( h.is_ready() );
                 BOOST_CHECK( h.has_value() );
@@ -363,7 +360,7 @@
         }
 
         // check wait_for
- void test_case_16()
+ void test_case_15()
         {
                 tsk::static_pool<
                         tsk::bounded_channel< tsk::fifo >
@@ -371,12 +368,12 @@
                         tsk::poolsize( 5),
                         tsk::high_watermark( 1),
                         tsk::low_watermark( 1) );
+ tsk::task< void > t(
+ boost::bind(
+ delay_fn,
+ pt::seconds( 3) ) );
                 tsk::handle< void > h(
- tsk::async(
- tsk::make_task(
- delay_fn,
- pt::seconds( 3) ),
- pool) );
+ tsk::async( boost::move( t), pool) );
                 BOOST_CHECK( ! h.wait_until( boost::get_system_time() + pt::seconds( 1) ) );
                 BOOST_CHECK( ! h.is_ready() );
                 BOOST_CHECK( ! h.has_value() );
@@ -384,7 +381,7 @@
         }
 
         // check interrupt
- void test_case_17()
+ void test_case_16()
         {
                 tsk::static_pool<
                         tsk::bounded_channel< tsk::fifo >
@@ -392,19 +389,19 @@
                         tsk::poolsize( 5),
                         tsk::high_watermark( 10),
                         tsk::low_watermark( 10) );
+ tsk::task< void > t(
+ boost::bind(
+ delay_fn,
+ pt::seconds( 3) ) );
                 tsk::handle< void > h(
- tsk::async(
- tsk::make_task(
- delay_fn,
- pt::seconds( 3) ),
- pool) );
+ tsk::async( boost::move( t), pool) );
                 h.interrupt();
                 BOOST_CHECK( h.interruption_requested() );
                 BOOST_CHECK_THROW( h.get(), tsk::task_interrupted);
         }
 
         // check interrupt_and_wait
- void test_case_18()
+ void test_case_17()
         {
                 tsk::static_pool<
                         tsk::bounded_channel< tsk::fifo >
@@ -413,13 +410,13 @@
                         tsk::high_watermark( 10),
                         tsk::low_watermark( 10) );
                 bool finished( false);
+ tsk::task< void > t(
+ boost::bind(
+ interrupt_fn,
+ pt::seconds( 1),
+ boost::ref( finished) ) );
                 tsk::handle< void > h(
- tsk::async(
- tsk::make_task(
- interrupt_fn,
- pt::seconds( 1),
- boost::ref( finished) ),
- pool) );
+ tsk::async( boost::move( t), pool) );
                 h.interrupt_and_wait();
                 BOOST_CHECK( finished);
                 BOOST_CHECK( h.is_ready() );
@@ -430,7 +427,7 @@
         }
 
         // check interrupt_and_wait_for
- void test_case_19()
+ void test_case_18()
         {
                 tsk::static_pool<
                         tsk::bounded_channel< tsk::fifo >
@@ -439,13 +436,13 @@
                         tsk::high_watermark( 10),
                         tsk::low_watermark( 10) );
                 bool finished( false);
+ tsk::task< void > t(
+ boost::bind(
+ interrupt_fn,
+ pt::seconds( 1),
+ boost::ref( finished) ) );
                 tsk::handle< void > h(
- tsk::async(
- tsk::make_task(
- interrupt_fn,
- pt::seconds( 1),
- boost::ref( finished) ),
- pool) );
+ tsk::async( boost::move( t), pool) );
                 BOOST_CHECK( h.interrupt_and_wait_for( pt::seconds( 3) ) );
                 BOOST_CHECK( finished);
                 BOOST_CHECK( h.is_ready() );
@@ -456,7 +453,7 @@
         }
 
         // check interrupt_and_wait_for
- void test_case_20()
+ void test_case_19()
         {
                 tsk::static_pool<
                         tsk::bounded_channel< tsk::fifo >
@@ -464,17 +461,17 @@
                         tsk::poolsize( 5),
                         tsk::high_watermark( 10),
                         tsk::low_watermark( 10) );
+ tsk::task< void > t(
+ boost::bind(
+ non_interrupt_fn,
+ 3) );
                 tsk::handle< void > h(
- tsk::async(
- tsk::make_task(
- non_interrupt_fn,
- 3),
- pool) );
+ tsk::async( boost::move( t), pool) );
                 BOOST_CHECK( ! h.interrupt_and_wait_for( pt::seconds( 1) ) );
         }
 
         // check interrupt_and_wait_until
- void test_case_21()
+ void test_case_20()
         {
                 tsk::static_pool<
                         tsk::bounded_channel< tsk::fifo >
@@ -483,13 +480,13 @@
                         tsk::high_watermark( 10),
                         tsk::low_watermark( 10) );
                 bool finished( false);
+ tsk::task< void > t(
+ boost::bind(
+ interrupt_fn,
+ pt::seconds( 1),
+ boost::ref( finished) ) );
                 tsk::handle< void > h(
- tsk::async(
- tsk::make_task(
- interrupt_fn,
- pt::seconds( 1),
- boost::ref( finished) ),
- pool) );
+ tsk::async( boost::move( t), pool) );
                 BOOST_CHECK( h.interrupt_and_wait_until( boost::get_system_time() + pt::seconds( 3) ) );
                 BOOST_CHECK( finished);
                 BOOST_CHECK( h.is_ready() );
@@ -500,7 +497,7 @@
         }
 
         // check interrupt_and_wait_until
- void test_case_22()
+ void test_case_21()
         {
                 tsk::static_pool<
                         tsk::bounded_channel< tsk::fifo >
@@ -508,17 +505,17 @@
                         tsk::poolsize( 5),
                         tsk::high_watermark( 10),
                         tsk::low_watermark( 10) );
+ tsk::task< void > t(
+ boost::bind(
+ non_interrupt_fn,
+ 3) );
                 tsk::handle< void > h(
- tsk::async(
- tsk::make_task(
- non_interrupt_fn,
- 3),
- pool) );
+ tsk::async( boost::move( t), pool) );
                 BOOST_CHECK( ! h.interrupt_and_wait_until( boost::get_system_time() + pt::seconds( 1) ) );
         }
 
         // check fifo scheduling
- void test_case_23()
+ void test_case_22()
         {
                 typedef tsk::static_pool<
                         tsk::bounded_channel< tsk::fifo >
@@ -529,24 +526,24 @@
                         tsk::high_watermark( 10),
                         tsk::low_watermark( 10) );
                 boost::barrier b( 2);
- tsk::async(
- tsk::make_task(
- barrier_fn,
- boost::ref( b) ),
- pool);
                 std::vector< int > buffer;
- tsk::async(
- tsk::make_task(
+ tsk::task< void > t1(
+ boost::bind(
+ barrier_fn,
+ boost::ref( b) ) );
+ tsk::task< void > t2(
+ boost::bind(
                                 buffer_fibonacci_fn,
                                 boost::ref( buffer),
- 10),
- pool);
- tsk::async(
- tsk::make_task(
+ 10) );
+ tsk::task< void > t3(
+ boost::bind(
                                 buffer_fibonacci_fn,
                                 boost::ref( buffer),
- 0),
- pool);
+ 0) );
+ tsk::async( boost::move( t1), pool);
+ tsk::async( boost::move( t2), pool);
+ tsk::async( boost::move( t3), pool);
                 b.wait();
                 pool.shutdown();
                 BOOST_CHECK_EQUAL( buffer[0], 55);
@@ -555,7 +552,7 @@
         }
 
         // check priority scheduling
- void test_case_24()
+ void test_case_23()
         {
                 typedef tsk::static_pool<
                         tsk::bounded_channel< tsk::priority< int > >
@@ -568,27 +565,24 @@
                         tsk::high_watermark( 10),
                         tsk::low_watermark( 10) );
                 boost::barrier b( 2);
- tsk::async(
- tsk::make_task(
- barrier_fn,
- boost::ref( b) ),
- 0,
- pool);
                 std::vector< int > buffer;
- tsk::async(
- tsk::make_task(
- buffer_fibonacci_fn,
- boost::ref( buffer),
- 10),
- 1,
- pool);
- tsk::async(
- tsk::make_task(
+ tsk::task< void > t1(
+ boost::bind(
+ barrier_fn,
+ boost::ref( b) ) );
+ tsk::task< void > t2(
+ boost::bind(
+ buffer_fibonacci_fn,
+ boost::ref( buffer),
+ 10) );
+ tsk::task< void > t3(
+ boost::bind(
                                 buffer_fibonacci_fn,
                                 boost::ref( buffer),
- 0),
- 0,
- pool);
+ 0) );
+ tsk::async( boost::move( t1), 0, pool);
+ tsk::async( boost::move( t2), 1, pool);
+ tsk::async( boost::move( t3), 0, pool);
                 b.wait();
                 pool.shutdown();
                 BOOST_CHECK_EQUAL( buffer[0], 0);
@@ -597,7 +591,7 @@
         }
 
         // check smart scheduling
- void test_case_25()
+ void test_case_24()
         {
                 typedef tsk::static_pool<
                         tsk::bounded_channel< tsk::smart< int, std::less< int >, tsk::replace_oldest, tsk::take_oldest > >
@@ -610,34 +604,30 @@
                         tsk::high_watermark( 10),
                         tsk::low_watermark( 10) );
                 boost::barrier b( 2);
- tsk::async(
- tsk::make_task(
- barrier_fn,
- boost::ref( b) ),
- 0,
- pool);
                 std::vector< int > buffer;
- tsk::async(
- tsk::make_task(
+ tsk::task< void > t1(
+ boost::bind(
+ barrier_fn,
+ boost::ref( b) ) );
+ tsk::task< void > t2(
+ boost::bind(
                                 buffer_fibonacci_fn,
                                 boost::ref( buffer),
- 10),
- 2,
- pool);
- tsk::async(
- tsk::make_task(
+ 10) );
+ tsk::task< void > t3(
+ boost::bind(
                                 buffer_fibonacci_fn,
                                 boost::ref( buffer),
- 0),
- 1,
- pool);
- tsk::async(
- tsk::make_task(
+ 0) );
+ tsk::task< void > t4(
+ boost::bind(
                                 buffer_fibonacci_fn,
                                 boost::ref( buffer),
- 1),
- 2,
- pool);
+ 1) );
+ tsk::async( boost::move( t1), 0, pool);
+ tsk::async( boost::move( t2), 2, pool);
+ tsk::async( boost::move( t3), 1, pool);
+ tsk::async( boost::move( t4), 2, pool);
                 b.wait();
                 pool.shutdown();
                 BOOST_CHECK_EQUAL( buffer[0], 0);
@@ -675,7 +665,6 @@
         test->add( BOOST_CLASS_TEST_CASE( & test_bounded_pool::test_case_22, instance) );
         test->add( BOOST_CLASS_TEST_CASE( & test_bounded_pool::test_case_23, instance) );
         test->add( BOOST_CLASS_TEST_CASE( & test_bounded_pool::test_case_24, instance) );
- test->add( BOOST_CLASS_TEST_CASE( & test_bounded_pool::test_case_25, instance) );
 
         return test;
 }

Modified: sandbox/task/libs/task/test/test_default_pool.cpp
==============================================================================
--- sandbox/task/libs/task/test/test_default_pool.cpp (original)
+++ sandbox/task/libs/task/test/test_default_pool.cpp 2009-06-17 14:57:41 EDT (Wed, 17 Jun 2009)
@@ -29,52 +29,36 @@
 class test_default_pool
 {
 public:
- // check id
+ // check assignment
         void test_case_1()
         {
                 tsk::task< int > t(
- tsk::make_task(
+ boost::bind(
                                 fibonacci_fn,
                                 10) );
- tsk::handle< int > h(
- tsk::async(
- t,
- tsk::default_pool() ) );
- BOOST_CHECK_EQUAL( h.get_id(), t.get_id() );
- BOOST_CHECK_EQUAL( h.get(), 55);
- }
-
- // check assignment
- void test_case_2()
- {
                 tsk::handle< int > h1;
                 tsk::handle< int > h2(
- tsk::async(
- tsk::make_task(
- fibonacci_fn,
- 10),
- tsk::default_pool() ) );
+ tsk::async( boost::move( t), tsk::default_pool() ) );
                 h1 = h2;
- BOOST_CHECK_EQUAL( h1.get_id(), h2.get_id() );
                 BOOST_CHECK_EQUAL( h1.get(), 55);
                 BOOST_CHECK_EQUAL( h2.get(), 55);
         }
 
         // check swap
- void test_case_3()
+ void test_case_2()
         {
+ tsk::task< int > t1(
+ boost::bind(
+ fibonacci_fn,
+ 5) );
+ tsk::task< int > t2(
+ boost::bind(
+ fibonacci_fn,
+ 10) );
                 tsk::handle< int > h1(
- tsk::async(
- tsk::make_task(
- fibonacci_fn,
- 5),
- tsk::default_pool() ) );
+ tsk::async( boost::move( t1), tsk::default_pool() ) );
                 tsk::handle< int > h2(
- tsk::async(
- tsk::make_task(
- fibonacci_fn,
- 10),
- tsk::default_pool() ) );
+ tsk::async( boost::move( t2), tsk::default_pool() ) );
                 BOOST_CHECK_EQUAL( h1.get(), 5);
                 BOOST_CHECK_EQUAL( h2.get(), 55);
                 BOOST_CHECK_NO_THROW( h1.swap( h2) );
@@ -83,50 +67,50 @@
         }
 
         // check runs in pool
- void test_case_4()
+ void test_case_3()
         {
+ tsk::task< bool > t(
+ boost::bind( runs_in_pool_fn) );
                 tsk::handle< bool > h(
- tsk::async(
- tsk::make_task( runs_in_pool_fn),
- tsk::default_pool() ) );
+ tsk::async( boost::move( t), tsk::default_pool() ) );
                 BOOST_CHECK_EQUAL( h.get(), true);
         }
 
         // check runtime_error throw inside task
- void test_case_5()
+ void test_case_4()
         {
+ tsk::task< void > t(
+ boost::bind( throwing_fn) );
                 tsk::handle< void > h(
- tsk::async(
- tsk::make_task( throwing_fn),
- tsk::default_pool() ) );
+ tsk::async( boost::move( t), tsk::default_pool() ) );
                 BOOST_CHECK_THROW( h.get(), std::runtime_error);
         }
 
         // check interrupt
- void test_case_6()
+ void test_case_5()
         {
+ tsk::task< void > t(
+ boost::bind(
+ delay_fn,
+ pt::seconds( 3) ) );
                 tsk::handle< void > h(
- tsk::async(
- tsk::make_task(
- delay_fn,
- pt::seconds( 3) ),
- tsk::default_pool() ) );
+ tsk::async( boost::move( t), tsk::default_pool() ) );
                 h.interrupt();
                 BOOST_CHECK( h.interruption_requested() );
                 BOOST_CHECK_THROW( h.get(), tsk::task_interrupted);
         }
 
         // check interrupt_and_wait
- void test_case_7()
+ void test_case_6()
         {
                 bool finished( false);
+ tsk::task< void > t(
+ boost::bind(
+ interrupt_fn,
+ pt::seconds( 3),
+ boost::ref( finished) ) );
                 tsk::handle< void > h(
- tsk::async(
- tsk::make_task(
- interrupt_fn,
- pt::seconds( 3),
- boost::ref( finished) ),
- tsk::default_pool() ) );
+ tsk::async( boost::move( t), tsk::default_pool() ) );
                 h.interrupt_and_wait();
                 BOOST_CHECK( finished);
                 BOOST_CHECK( h.is_ready() );
@@ -137,14 +121,14 @@
         }
 
         // check wait
- void test_case_8()
+ void test_case_7()
         {
+ tsk::task< int > t(
+ boost::bind(
+ fibonacci_fn,
+ 10) );
                 tsk::handle< int > h(
- tsk::async(
- tsk::make_task(
- fibonacci_fn,
- 10),
- tsk::default_pool() ) );
+ tsk::async( boost::move( t), tsk::default_pool() ) );
                 h.wait();
                 BOOST_CHECK( h.is_ready() );
                 BOOST_CHECK( h.has_value() );
@@ -153,16 +137,18 @@
         }
 
         // check waitfor_all()
- void test_case_9()
+ void test_case_8()
         {
                 std::vector< tsk::handle< int > > vec;
                 for ( int i = 0; i <= 5; ++i)
+ {
+ tsk::task< int > t(
+ boost::bind(
+ fibonacci_fn,
+ i) );
                         vec.push_back(
- tsk::async(
- tsk::make_task(
- fibonacci_fn,
- i),
- tsk::default_pool() ) );
+ tsk::async( boost::move( t), tsk::default_pool() ) );
+ }
                 tsk::waitfor_all( vec.begin(), vec.end() );
                 BOOST_CHECK( vec[0].is_ready() );
                 BOOST_CHECK( vec[1].is_ready() );
@@ -179,20 +165,20 @@
         }
 
         // check waitfor_any()
- void test_case_10()
+ void test_case_9()
         {
+ tsk::task< void > t1(
+ boost::bind(
+ delay_fn,
+ pt::seconds( 3) ) );
+ tsk::task< int > t2(
+ boost::bind(
+ fibonacci_fn,
+ 10) );
                 tsk::handle< void > h1(
- tsk::async(
- tsk::make_task(
- delay_fn,
- pt::seconds( 3) ),
- tsk::default_pool() ) );
+ tsk::async( boost::move( t1), tsk::default_pool() ) );
                 tsk::handle< int > h2(
- tsk::async(
- tsk::make_task(
- fibonacci_fn,
- 10),
- tsk::default_pool() ) );
+ tsk::async( boost::move( t2), tsk::default_pool() ) );
                 tsk::waitfor_any( h1, h2);
                 BOOST_CHECK( ! h1.is_ready() );
                 BOOST_CHECK( h2.is_ready() );
@@ -214,7 +200,6 @@
         test->add( BOOST_CLASS_TEST_CASE( & test_default_pool::test_case_7, instance) );
         test->add( BOOST_CLASS_TEST_CASE( & test_default_pool::test_case_8, instance) );
         test->add( BOOST_CLASS_TEST_CASE( & test_default_pool::test_case_9, instance) );
- test->add( BOOST_CLASS_TEST_CASE( & test_default_pool::test_case_10, instance) );
 
         return test;
 }

Modified: sandbox/task/libs/task/test/test_new_thread.cpp
==============================================================================
--- sandbox/task/libs/task/test/test_new_thread.cpp (original)
+++ sandbox/task/libs/task/test/test_new_thread.cpp 2009-06-17 14:57:41 EDT (Wed, 17 Jun 2009)
@@ -29,52 +29,36 @@
 class test_new_thread
 {
 public:
- // check id
+ // check assignment
         void test_case_1()
         {
                 tsk::task< int > t(
- tsk::make_task(
+ boost::bind(
                                 fibonacci_fn,
                                 10) );
- tsk::handle< int > h(
- tsk::async(
- t,
- tsk::new_thread() ) );
- BOOST_CHECK_EQUAL( h.get_id(), t.get_id() );
- BOOST_CHECK_EQUAL( h.get(), 55);
- }
-
- // check assignment
- void test_case_2()
- {
                 tsk::handle< int > h1;
                 tsk::handle< int > h2(
- tsk::async(
- tsk::make_task(
- fibonacci_fn,
- 10),
- tsk::new_thread() ) );
+ tsk::async( boost::move( t), tsk::new_thread() ) );
                 h1 = h2;
- BOOST_CHECK_EQUAL( h1.get_id(), h2.get_id() );
                 BOOST_CHECK_EQUAL( h1.get(), 55);
                 BOOST_CHECK_EQUAL( h2.get(), 55);
         }
 
         // check swap
- void test_case_3()
+ void test_case_2()
         {
+ tsk::task< int > t1(
+ boost::bind(
+ fibonacci_fn,
+ 5) );
+ tsk::task< int > t2(
+ boost::bind(
+ fibonacci_fn,
+ 10) );
                 tsk::handle< int > h1(
- tsk::async(
- tsk::make_task(
- fibonacci_fn,
- 5),
- tsk::new_thread() ) );
+ tsk::async( boost::move( t1), tsk::new_thread() ) );
                 tsk::handle< int > h2(
- tsk::async(
- tsk::make_task(
- fibonacci_fn,
- 10),
- tsk::new_thread() ) );
+ tsk::async( boost::move( t2), tsk::new_thread() ) );
                 BOOST_CHECK_EQUAL( h1.get(), 5);
                 BOOST_CHECK_EQUAL( h2.get(), 55);
                 BOOST_CHECK_NO_THROW( h1.swap( h2) );
@@ -83,34 +67,32 @@
         }
 
         // check runs not in pool
- void test_case_4()
+ void test_case_3()
         {
+ tsk::task< bool > t( runs_in_pool_fn);
                 tsk::handle< bool > h(
- tsk::async(
- tsk::make_task( runs_in_pool_fn),
- tsk::new_thread() ) );
+ tsk::async( boost::move( t), tsk::new_thread() ) );
                 BOOST_CHECK_EQUAL( h.get(), false);
         }
 
         // check runtime_error throw inside task
- void test_case_5()
+ void test_case_4()
         {
+ tsk::task< void > t( throwing_fn);
                 tsk::handle< void > h(
- tsk::async(
- tsk::make_task( throwing_fn),
- tsk::new_thread() ) );
+ tsk::async( boost::move( t), tsk::new_thread() ) );
                 BOOST_CHECK_THROW( h.get(), std::runtime_error);
         }
 
         // check wait
- void test_case_6()
+ void test_case_5()
         {
+ tsk::task< int > t(
+ boost::bind(
+ fibonacci_fn,
+ 10) );
                 tsk::handle< int > h(
- tsk::async(
- tsk::make_task(
- fibonacci_fn,
- 10),
- tsk::new_thread() ) );
+ tsk::async( boost::move( t), tsk::new_thread() ) );
                 h.wait();
                 BOOST_CHECK( h.is_ready() );
                 BOOST_CHECK( h.has_value() );
@@ -119,14 +101,14 @@
         }
 
         // check wait_for
- void test_case_7()
+ void test_case_6()
         {
+ tsk::task< void > t(
+ boost::bind(
+ delay_fn,
+ pt::seconds( 1) ) );
                 tsk::handle< void > h(
- tsk::async(
- tsk::make_task(
- delay_fn,
- pt::seconds( 1) ),
- tsk::new_thread() ) );
+ tsk::async( boost::move( t), tsk::new_thread() ) );
                 BOOST_CHECK( h.wait_for( pt::seconds( 3) ) );
                 BOOST_CHECK( h.is_ready() );
                 BOOST_CHECK( h.has_value() );
@@ -134,14 +116,14 @@
         }
 
         // check wait_for
- void test_case_8()
+ void test_case_7()
         {
+ tsk::task< void > t(
+ boost::bind(
+ delay_fn,
+ pt::seconds( 3) ) );
                 tsk::handle< void > h(
- tsk::async(
- tsk::make_task(
- delay_fn,
- pt::seconds( 3) ),
- tsk::new_thread() ) );
+ tsk::async( boost::move( t), tsk::new_thread() ) );
                 BOOST_CHECK( ! h.wait_for( pt::seconds( 1) ) );
                 BOOST_CHECK( ! h.is_ready() );
                 BOOST_CHECK( ! h.has_value() );
@@ -149,14 +131,14 @@
         }
 
         // check wait_for
- void test_case_9()
+ void test_case_8()
         {
+ tsk::task< void > t(
+ boost::bind(
+ delay_fn,
+ pt::seconds( 1) ) );
                 tsk::handle< void > h(
- tsk::async(
- tsk::make_task(
- delay_fn,
- pt::seconds( 1) ),
- tsk::new_thread() ) );
+ tsk::async( boost::move( t), tsk::new_thread() ) );
                 BOOST_CHECK( h.wait_until( boost::get_system_time() + pt::seconds( 3) ) );
                 BOOST_CHECK( h.is_ready() );
                 BOOST_CHECK( h.has_value() );
@@ -164,14 +146,14 @@
         }
 
         // check wait_for
- void test_case_10()
+ void test_case_9()
         {
+ tsk::task< void > t(
+ boost::bind(
+ delay_fn,
+ pt::seconds( 3) ) );
                 tsk::handle< void > h(
- tsk::async(
- tsk::make_task(
- delay_fn,
- pt::seconds( 3) ),
- tsk::new_thread() ) );
+ tsk::async( boost::move( t), tsk::new_thread() ) );
                 BOOST_CHECK( ! h.wait_until( boost::get_system_time() + pt::seconds( 1) ) );
                 BOOST_CHECK( ! h.is_ready() );
                 BOOST_CHECK( ! h.has_value() );
@@ -179,30 +161,30 @@
         }
 
         // check interrupt
- void test_case_11()
+ void test_case_10()
         {
+ tsk::task< void > t(
+ boost::bind(
+ delay_fn,
+ pt::seconds( 3) ) );
                 tsk::handle< void > h(
- tsk::async(
- tsk::make_task(
- delay_fn,
- pt::seconds( 3) ),
- tsk::new_thread() ) );
+ tsk::async( boost::move( t), tsk::new_thread() ) );
                 h.interrupt();
                 BOOST_CHECK( h.interruption_requested() );
                 BOOST_CHECK_THROW( h.get(), tsk::task_interrupted);
         }
 
         // check interrupt_and_wait
- void test_case_12()
+ void test_case_11()
         {
                 bool finished( false);
+ tsk::task< void > t(
+ boost::bind(
+ interrupt_fn,
+ pt::seconds( 1),
+ boost::ref( finished) ) );
                 tsk::handle< void > h(
- tsk::async(
- tsk::make_task(
- interrupt_fn,
- pt::seconds( 1),
- boost::ref( finished) ),
- tsk::new_thread() ) );
+ tsk::async( boost::move( t), tsk::new_thread() ) );
                 h.interrupt_and_wait();
                 BOOST_CHECK( finished);
                 BOOST_CHECK( h.is_ready() );
@@ -213,16 +195,16 @@
         }
 
         // check interrupt_and_wait_for
- void test_case_13()
+ void test_case_12()
         {
                 bool finished( false);
+ tsk::task< void > t(
+ boost::bind(
+ interrupt_fn,
+ pt::seconds( 1),
+ boost::ref( finished) ) );
                 tsk::handle< void > h(
- tsk::async(
- tsk::make_task(
- interrupt_fn,
- pt::seconds( 1),
- boost::ref( finished) ),
- tsk::new_thread() ) );
+ tsk::async( boost::move( t), tsk::new_thread() ) );
                 BOOST_CHECK( h.interrupt_and_wait_for( pt::seconds( 3) ) );
                 BOOST_CHECK( finished);
                 BOOST_CHECK( h.is_ready() );
@@ -233,28 +215,28 @@
         }
 
         // check interrupt_and_wait_for
- void test_case_14()
+ void test_case_13()
         {
+ tsk::task< void > t(
+ boost::bind(
+ non_interrupt_fn,
+ 3) );
                 tsk::handle< void > h(
- tsk::async(
- tsk::make_task(
- non_interrupt_fn,
- 3),
- tsk::new_thread() ) );
+ tsk::async( boost::move( t), tsk::new_thread() ) );
                 BOOST_CHECK( ! h.interrupt_and_wait_for( pt::seconds( 1) ) );
         }
 
         // check interrupt_and_wait_until
- void test_case_15()
+ void test_case_14()
         {
                 bool finished( false);
+ tsk::task< void > t(
+ boost::bind(
+ interrupt_fn,
+ pt::seconds( 1),
+ boost::ref( finished) ) );
                 tsk::handle< void > h(
- tsk::async(
- tsk::make_task(
- interrupt_fn,
- pt::seconds( 1),
- boost::ref( finished) ),
- tsk::new_thread() ) );
+ tsk::async( boost::move( t), tsk::new_thread() ) );
                 BOOST_CHECK( h.interrupt_and_wait_until( boost::get_system_time() + pt::seconds( 3) ) );
                 BOOST_CHECK( finished);
                 BOOST_CHECK( h.is_ready() );
@@ -265,28 +247,30 @@
         }
 
         // check interrupt_and_wait_until
- void test_case_16()
+ void test_case_15()
         {
+ tsk::task< void > t(
+ boost::bind(
+ non_interrupt_fn,
+ 3) );
                 tsk::handle< void > h(
- tsk::async(
- tsk::make_task(
- non_interrupt_fn,
- 3),
- tsk::new_thread() ) );
+ tsk::async( boost::move( t), tsk::new_thread() ) );
                 BOOST_CHECK( ! h.interrupt_and_wait_until( boost::get_system_time() + pt::seconds( 1) ) );
         }
 
         // check waitfor_all()
- void test_case_17()
+ void test_case_16()
         {
                 std::vector< tsk::handle< int > > vec;
                 for ( int i = 0; i <= 5; ++i)
+ {
+ tsk::task< int > t(
+ boost::bind(
+ fibonacci_fn,
+ i) );
                         vec.push_back(
- tsk::async(
- tsk::make_task(
- fibonacci_fn,
- i),
- tsk::new_thread() ) );
+ tsk::async( boost::move( t), tsk::new_thread() ) );
+ }
                 tsk::waitfor_all( vec.begin(), vec.end() );
                 BOOST_CHECK( vec[0].is_ready() );
                 BOOST_CHECK( vec[1].is_ready() );
@@ -303,20 +287,20 @@
         }
 
         // check waitfor_any()
- void test_case_18()
+ void test_case_17()
         {
+ tsk::task< void > t1(
+ boost::bind(
+ delay_fn,
+ pt::seconds( 3) ) );
+ tsk::task< int > t2(
+ boost::bind(
+ fibonacci_fn,
+ 10) );
                 tsk::handle< void > h1(
- tsk::async(
- tsk::make_task(
- delay_fn,
- pt::seconds( 3) ),
- tsk::new_thread() ) );
+ tsk::async( boost::move( t1), tsk::new_thread() ) );
                 tsk::handle< int > h2(
- tsk::async(
- tsk::make_task(
- fibonacci_fn,
- 10),
- tsk::new_thread() ) );
+ tsk::async( boost::move( t2), tsk::new_thread() ) );
                 tsk::waitfor_any( h1, h2);
                 BOOST_CHECK( ! h1.is_ready() );
                 BOOST_CHECK( h2.is_ready() );
@@ -346,7 +330,6 @@
         test->add( BOOST_CLASS_TEST_CASE( & test_new_thread::test_case_15, instance) );
         test->add( BOOST_CLASS_TEST_CASE( & test_new_thread::test_case_16, instance) );
         test->add( BOOST_CLASS_TEST_CASE( & test_new_thread::test_case_17, instance) );
- test->add( BOOST_CLASS_TEST_CASE( & test_new_thread::test_case_18, instance) );
 
         return test;
 }

Modified: sandbox/task/libs/task/test/test_own_thread.cpp
==============================================================================
--- sandbox/task/libs/task/test/test_own_thread.cpp (original)
+++ sandbox/task/libs/task/test/test_own_thread.cpp 2009-06-17 14:57:41 EDT (Wed, 17 Jun 2009)
@@ -29,52 +29,36 @@
 class test_own_thread
 {
 public:
- // check id
+ // check assignment
         void test_case_1()
         {
                 tsk::task< int > t(
- tsk::make_task(
+ boost::bind(
                                 fibonacci_fn,
                                 10) );
- tsk::handle< int > h(
- tsk::async(
- t,
- tsk::own_thread() ) );
- BOOST_CHECK_EQUAL( h.get_id(), t.get_id() );
- BOOST_CHECK_EQUAL( h.get(), 55);
- }
-
- // check assignment
- void test_case_2()
- {
                 tsk::handle< int > h1;
                 tsk::handle< int > h2(
- tsk::async(
- tsk::make_task(
- fibonacci_fn,
- 10),
- tsk::own_thread() ) );
+ tsk::async( boost::move( t), tsk::own_thread() ) );
                 h1 = h2;
- BOOST_CHECK_EQUAL( h1.get_id(), h2.get_id() );
                 BOOST_CHECK_EQUAL( h1.get(), 55);
                 BOOST_CHECK_EQUAL( h2.get(), 55);
         }
 
         // check swap
- void test_case_3()
+ void test_case_2()
         {
+ tsk::task< int > t1(
+ boost::bind(
+ fibonacci_fn,
+ 5) );
+ tsk::task< int > t2(
+ boost::bind(
+ fibonacci_fn,
+ 10) );
                 tsk::handle< int > h1(
- tsk::async(
- tsk::make_task(
- fibonacci_fn,
- 5),
- tsk::own_thread() ) );
+ tsk::async( boost::move( t1), tsk::own_thread() ) );
                 tsk::handle< int > h2(
- tsk::async(
- tsk::make_task(
- fibonacci_fn,
- 10),
- tsk::own_thread() ) );
+ tsk::async( boost::move( t2), tsk::own_thread() ) );
                 BOOST_CHECK_EQUAL( h1.get(), 5);
                 BOOST_CHECK_EQUAL( h2.get(), 55);
                 BOOST_CHECK_NO_THROW( h1.swap( h2) );
@@ -83,27 +67,25 @@
         }
 
         // check runs not in pool
- void test_case_4()
+ void test_case_3()
         {
+ tsk::task< bool > t( runs_in_pool_fn);
                 tsk::handle< bool > h(
- tsk::async(
- tsk::make_task( runs_in_pool_fn),
- tsk::own_thread() ) );
+ tsk::async( boost::move( t), tsk::own_thread() ) );
                 BOOST_CHECK_EQUAL( h.get(), false);
         }
 
         // check runtime_error throw inside task
- void test_case_5()
+ void test_case_4()
         {
+ tsk::task< void > t( throwing_fn);
                 tsk::handle< void > h(
- tsk::async(
- tsk::make_task( throwing_fn),
- tsk::own_thread() ) );
+ tsk::async( boost::move( t), tsk::own_thread() ) );
                 BOOST_CHECK_THROW( h.get(), std::runtime_error);
         }
 
         // check task_uninitialized
- void test_case_6()
+ void test_case_5()
         {
                 tsk::handle< int > h;
                 BOOST_CHECK_THROW( h.get(), tsk::task_uninitialized);
@@ -118,14 +100,14 @@
         }
 
         // check wait
- void test_case_7()
+ void test_case_6()
         {
+ tsk::task< int > t(
+ boost::bind(
+ fibonacci_fn,
+ 10) );
                 tsk::handle< int > h(
- tsk::async(
- tsk::make_task(
- fibonacci_fn,
- 10),
- tsk::own_thread() ) );
+ tsk::async( boost::move( t), tsk::own_thread() ) );
                 h.wait();
                 BOOST_CHECK( h.is_ready() );
                 BOOST_CHECK( h.has_value() );
@@ -134,14 +116,14 @@
         }
 
         // check wait_for
- void test_case_8()
+ void test_case_7()
         {
+ tsk::task< void > t(
+ boost::bind(
+ delay_fn,
+ pt::seconds( 1) ) );
                 tsk::handle< void > h(
- tsk::async(
- tsk::make_task(
- delay_fn,
- pt::seconds( 1) ),
- tsk::own_thread() ) );
+ tsk::async( boost::move( t), tsk::own_thread() ) );
                 BOOST_CHECK( h.wait_for( pt::seconds( 2) ) );
                 BOOST_CHECK( h.is_ready() );
                 BOOST_CHECK( h.has_value() );
@@ -149,14 +131,14 @@
         }
 
         // check wait_for
- void test_case_9()
+ void test_case_8()
         {
+ tsk::task< void > t(
+ boost::bind(
+ delay_fn,
+ pt::seconds( 2) ) );
                 tsk::handle< void > h(
- tsk::async(
- tsk::make_task(
- delay_fn,
- pt::seconds( 2) ),
- tsk::own_thread() ) );
+ tsk::async( boost::move( t), tsk::own_thread() ) );
                 BOOST_CHECK( h.wait_for( pt::seconds( 1) ) );
                 BOOST_CHECK( h.is_ready() );
                 BOOST_CHECK( h.has_value() );
@@ -164,14 +146,14 @@
         }
 
         // check wait_for
- void test_case_10()
+ void test_case_9()
         {
+ tsk::task< void > t(
+ boost::bind(
+ delay_fn,
+ pt::seconds( 1) ) );
                 tsk::handle< void > h(
- tsk::async(
- tsk::make_task(
- delay_fn,
- pt::seconds( 1) ),
- tsk::own_thread() ) );
+ tsk::async( boost::move( t), tsk::own_thread() ) );
                 BOOST_CHECK( h.wait_until( boost::get_system_time() + pt::seconds( 3) ) );
                 BOOST_CHECK( h.is_ready() );
                 BOOST_CHECK( h.has_value() );
@@ -179,14 +161,14 @@
         }
 
         // check wait_for
- void test_case_11()
+ void test_case_10()
         {
+ tsk::task< void > t(
+ boost::bind(
+ delay_fn,
+ pt::seconds( 2) ) );
                 tsk::handle< void > h(
- tsk::async(
- tsk::make_task(
- delay_fn,
- pt::seconds( 2) ),
- tsk::own_thread() ) );
+ tsk::async( boost::move( t), tsk::own_thread() ) );
                 BOOST_CHECK( h.wait_until( boost::get_system_time() + pt::seconds( 1) ) );
                 BOOST_CHECK( h.is_ready() );
                 BOOST_CHECK( h.has_value() );
@@ -194,30 +176,30 @@
         }
 
         // check interrupt
- void test_case_12()
+ void test_case_11()
         {
+ tsk::task< void > t(
+ boost::bind(
+ delay_fn,
+ pt::seconds( 3) ) );
                 tsk::handle< void > h(
- tsk::async(
- tsk::make_task(
- delay_fn,
- pt::seconds( 3) ),
- tsk::own_thread() ) );
+ tsk::async( boost::move( t), tsk::own_thread() ) );
                 h.interrupt();
                 BOOST_CHECK( h.interruption_requested() );
                 BOOST_CHECK_NO_THROW( h.get() );
         }
 
         // check interrupt_and_wait
- void test_case_13()
+ void test_case_12()
         {
                 bool finished( false);
+ tsk::task< void > t(
+ boost::bind(
+ interrupt_fn,
+ pt::seconds( 3),
+ boost::ref( finished) ) );
                 tsk::handle< void > h(
- tsk::async(
- tsk::make_task(
- interrupt_fn,
- pt::seconds( 3),
- boost::ref( finished) ),
- tsk::own_thread() ) );
+ tsk::async( boost::move( t), tsk::own_thread() ) );
                 h.interrupt_and_wait();
                 BOOST_CHECK( ! finished);
                 BOOST_CHECK( h.is_ready() );
@@ -226,16 +208,16 @@
         }
 
         // check interrupt_and_wait_for
- void test_case_14()
+ void test_case_13()
         {
                 bool finished( false);
+ tsk::task< void > t(
+ boost::bind(
+ interrupt_fn,
+ pt::seconds( 1),
+ boost::ref( finished) ) );
                 tsk::handle< void > h(
- tsk::async(
- tsk::make_task(
- interrupt_fn,
- pt::seconds( 1),
- boost::ref( finished) ),
- tsk::own_thread() ) );
+ tsk::async( boost::move( t), tsk::own_thread() ) );
                 BOOST_CHECK( h.interrupt_and_wait_for( pt::seconds( 2) ) );
                 BOOST_CHECK( ! finished);
                 BOOST_CHECK( h.is_ready() );
@@ -246,29 +228,29 @@
         }
 
         // check interrupt_and_wait_for
- void test_case_15()
+ void test_case_14()
         {
+ tsk::task< void > t(
+ boost::bind(
+ non_interrupt_fn,
+ 2) );
                 tsk::handle< void > h(
- tsk::async(
- tsk::make_task(
- non_interrupt_fn,
- 2),
- tsk::own_thread() ) );
+ tsk::async( boost::move( t), tsk::own_thread() ) );
                 BOOST_CHECK( h.interrupt_and_wait_for( pt::seconds( 1) ) );
                 BOOST_CHECK_NO_THROW( h.get() );
         }
 
         // check interrupt_and_wait_until
- void test_case_16()
+ void test_case_15()
         {
                 bool finished( false);
+ tsk::task< void > t(
+ boost::bind(
+ interrupt_fn,
+ pt::seconds( 1),
+ boost::ref( finished) ) );
                 tsk::handle< void > h(
- tsk::async(
- tsk::make_task(
- interrupt_fn,
- pt::seconds( 1),
- boost::ref( finished) ),
- tsk::own_thread() ) );
+ tsk::async( boost::move( t), tsk::own_thread() ) );
                 BOOST_CHECK( h.interrupt_and_wait_until( boost::get_system_time() + pt::seconds( 2) ) );
                 BOOST_CHECK( ! finished);
                 BOOST_CHECK( h.is_ready() );
@@ -279,29 +261,31 @@
         }
 
         // check interrupt_and_wait_until
- void test_case_17()
+ void test_case_16()
         {
+ tsk::task< void > t(
+ boost::bind(
+ non_interrupt_fn,
+ 2) );
                 tsk::handle< void > h(
- tsk::async(
- tsk::make_task(
- non_interrupt_fn,
- 2),
- tsk::own_thread() ) );
+ tsk::async( boost::move( t), tsk::own_thread() ) );
                 BOOST_CHECK( h.interrupt_and_wait_until( boost::get_system_time() + pt::seconds( 1) ) );
                 BOOST_CHECK_NO_THROW( h.get() );
         }
 
         // check waitfor_all()
- void test_case_18()
+ void test_case_17()
         {
                 std::vector< tsk::handle< int > > vec;
                 for ( int i = 0; i <= 5; ++i)
+ {
+ tsk::task< int > t(
+ boost::bind(
+ fibonacci_fn,
+ i) );
                         vec.push_back(
- tsk::async(
- tsk::make_task(
- fibonacci_fn,
- i),
- tsk::own_thread() ) );
+ tsk::async( boost::move( t), tsk::own_thread() ) );
+ }
                 tsk::waitfor_all( vec.begin(), vec.end() );
                 BOOST_CHECK( vec[0].is_ready() );
                 BOOST_CHECK( vec[1].is_ready() );
@@ -318,20 +302,20 @@
         }
 
         // check waitfor_any()
- void test_case_19()
+ void test_case_18()
         {
+ tsk::task< void > t1(
+ boost::bind(
+ delay_fn,
+ pt::seconds( 3) ) );
+ tsk::task< int > t2(
+ boost::bind(
+ fibonacci_fn,
+ 10) );
                 tsk::handle< void > h1(
- tsk::async(
- tsk::make_task(
- delay_fn,
- pt::seconds( 3) ),
- tsk::own_thread() ) );
+ tsk::async( boost::move( t1), tsk::own_thread() ) );
                 tsk::handle< int > h2(
- tsk::async(
- tsk::make_task(
- fibonacci_fn,
- 10),
- tsk::own_thread() ) );
+ tsk::async( boost::move( t2), tsk::own_thread() ) );
                 tsk::waitfor_any( h1, h2);
                 BOOST_CHECK( h1.is_ready() );
                 BOOST_CHECK( h2.is_ready() );
@@ -339,14 +323,14 @@
         }
 
         // check interrupt + wait
- void test_case_20()
+ void test_case_19()
         {
+ tsk::task< void > t(
+ boost::bind(
+ delay_fn,
+ pt::seconds( 3) ) );
                 tsk::handle< void > h(
- tsk::async(
- tsk::make_task(
- delay_fn,
- pt::seconds( 3) ),
- tsk::own_thread() ) );
+ tsk::async( boost::move( t), tsk::own_thread() ) );
                 h.interrupt();
                 BOOST_CHECK_NO_THROW( h.wait() );
                 BOOST_CHECK_NO_THROW( h.get() );
@@ -377,7 +361,6 @@
         test->add( BOOST_CLASS_TEST_CASE( & test_own_thread::test_case_17, instance) );
         test->add( BOOST_CLASS_TEST_CASE( & test_own_thread::test_case_18, instance) );
         test->add( BOOST_CLASS_TEST_CASE( & test_own_thread::test_case_19, instance) );
- test->add( BOOST_CLASS_TEST_CASE( & test_own_thread::test_case_20, instance) );
 
         return test;
 }

Added: sandbox/task/libs/task/test/test_task.cpp
==============================================================================
--- (empty file)
+++ sandbox/task/libs/task/test/test_task.cpp 2009-06-17 14:57:41 EDT (Wed, 17 Jun 2009)
@@ -0,0 +1,81 @@
+
+// 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;
+
+class test_task
+{
+public:
+ // check moved task
+ void test_case_1()
+ {
+ tsk::task< int > t1(
+ boost::bind(
+ fibonacci_fn,
+ 10) );
+ tsk::task< int > t2( boost::move( t1) );
+ BOOST_CHECK_THROW( t1(), tsk::task_moved);
+ BOOST_CHECK_NO_THROW( t2() );
+ }
+
+ // check execute twice
+ void test_case_2()
+ {
+ tsk::task< int > t1(
+ boost::bind(
+ fibonacci_fn,
+ 10) );
+ BOOST_CHECK_NO_THROW( t1() );
+ BOOST_CHECK_THROW( t1(), tsk::task_already_executed);
+ }
+
+ // check swap
+ void test_case_3()
+ {
+ tsk::task< int > t1(
+ boost::bind(
+ fibonacci_fn,
+ 10) );
+ tsk::task< int > t2;
+ BOOST_CHECK_NO_THROW( t1() );
+ BOOST_CHECK_THROW( t2(), tsk::task_moved);
+ t1.swap( t2);
+ BOOST_CHECK_THROW( t1(), tsk::task_moved);
+ BOOST_CHECK_THROW( t2(), tsk::task_already_executed);
+ }
+};
+
+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_task > instance( new test_task() );
+ test->add( BOOST_CLASS_TEST_CASE( & test_task::test_case_1, instance) );
+ test->add( BOOST_CLASS_TEST_CASE( & test_task::test_case_2, instance) );
+ test->add( BOOST_CLASS_TEST_CASE( & test_task::test_case_3, instance) );
+
+ return test;
+}

Modified: sandbox/task/libs/task/test/test_unbounded_pool.cpp
==============================================================================
--- sandbox/task/libs/task/test/test_unbounded_pool.cpp (original)
+++ sandbox/task/libs/task/test/test_unbounded_pool.cpp 2009-06-17 14:57:41 EDT (Wed, 17 Jun 2009)
@@ -35,82 +35,80 @@
         {
                 tsk::static_pool<
                         tsk::unbounded_channel< tsk::fifo >
- > pool( tsk::poolsize( 3) );
- BOOST_CHECK_EQUAL( pool.size(), std::size_t( 3) );
- BOOST_CHECK_EQUAL( pool.idle(), std::size_t( 3) );
- BOOST_CHECK_EQUAL( pool.active(), std::size_t( 0) );
- }
+ > pool1( tsk::poolsize( 3) );
+ BOOST_CHECK_EQUAL( pool1.size(), std::size_t( 3) );
+ BOOST_CHECK_EQUAL( pool1.idle(), std::size_t( 3) );
+ BOOST_CHECK_EQUAL( pool1.active(), std::size_t( 0) );
 
- // check submit
- void test_case_2()
- {
                 tsk::static_pool<
                         tsk::unbounded_channel< tsk::fifo >
- > pool( tsk::poolsize( 3) );
- tsk::handle< int > h(
- tsk::async(
- tsk::make_task(
- fibonacci_fn,
- 10),
- pool) );
- BOOST_CHECK_EQUAL( h.get(), 55);
+ > pool2;
+ BOOST_CHECK_THROW( pool2.size(), tsk::pool_moved);
+ BOOST_CHECK_THROW( pool2.idle(), tsk::pool_moved);
+ BOOST_CHECK_THROW( pool2.active(), tsk::pool_moved);
+
+ pool2 = boost::move( pool1);
+
+ BOOST_CHECK_THROW( pool1.size(), tsk::pool_moved);
+ BOOST_CHECK_THROW( pool1.idle(), tsk::pool_moved);
+ BOOST_CHECK_THROW( pool1.active(), tsk::pool_moved);
+
+ BOOST_CHECK_EQUAL( pool2.size(), std::size_t( 3) );
+ BOOST_CHECK_EQUAL( pool2.idle(), std::size_t( 3) );
+ BOOST_CHECK_EQUAL( pool2.active(), std::size_t( 0) );
         }
 
- // check id
- void test_case_3()
+ // check submit
+ void test_case_2()
         {
                 tsk::static_pool<
                         tsk::unbounded_channel< tsk::fifo >
> pool( tsk::poolsize( 3) );
                 tsk::task< int > t(
- tsk::make_task(
+ boost::bind(
                                 fibonacci_fn,
                                 10) );
                 tsk::handle< int > h(
- tsk::async(
- t,
- pool) );
- BOOST_CHECK_EQUAL( h.get_id(), t.get_id() );
+ tsk::async( boost::move( t), pool) );
                 BOOST_CHECK_EQUAL( h.get(), 55);
         }
 
         // check assignment
- void test_case_4()
+ void test_case_3()
         {
                 tsk::static_pool<
                         tsk::unbounded_channel< tsk::fifo >
> pool( tsk::poolsize( 3) );
+ tsk::task< int > t(
+ boost::bind(
+ fibonacci_fn,
+ 10) );
                 tsk::handle< int > h1;
                 tsk::handle< int > h2(
- tsk::async(
- tsk::make_task(
- fibonacci_fn,
- 10),
- pool) );
+ tsk::async( boost::move( t), pool) );
                 h1 = h2;
- BOOST_CHECK_EQUAL( h1.get_id(), h2.get_id() );
                 BOOST_CHECK_EQUAL( h1.get(), 55);
                 BOOST_CHECK_EQUAL( h2.get(), 55);
         }
 
         // check swap
- void test_case_5()
+ void test_case_4()
         {
                 tsk::static_pool<
                         tsk::unbounded_channel< tsk::fifo >
> pool( tsk::poolsize( 3) );
+ tsk::task< int > t1(
+ boost::bind(
+ fibonacci_fn,
+ 5) );
+ tsk::task< int > t2(
+ boost::bind(
+ fibonacci_fn,
+ 10) );
                 tsk::handle< int > h1(
- tsk::async(
- tsk::make_task(
- fibonacci_fn,
- 5),
- pool) );
+ tsk::async( boost::move( t1), pool) );
                 tsk::handle< int > h2(
- tsk::async(
- tsk::make_task(
- fibonacci_fn,
- 10),
- pool) );
+ tsk::async( boost::move( t2), pool) );
                 BOOST_CHECK_EQUAL( h1.get(), 5);
                 BOOST_CHECK_EQUAL( h2.get(), 55);
                 BOOST_CHECK_NO_THROW( h1.swap( h2) );
@@ -119,79 +117,77 @@
         }
 
         // check runs in pool
- void test_case_6()
+ void test_case_5()
         {
                 tsk::static_pool<
                         tsk::unbounded_channel< tsk::fifo >
> pool( tsk::poolsize( 1) );
+ tsk::task< bool > t( runs_in_pool_fn);
                 tsk::handle< bool > h(
- tsk::async(
- tsk::make_task( runs_in_pool_fn),
- pool) );
+ tsk::async( boost::move( t), pool) );
                 BOOST_CHECK_EQUAL( h.get(), true);
         }
 
         // check shutdown
- void test_case_7()
+ void test_case_6()
         {
                 tsk::static_pool<
                         tsk::unbounded_channel< tsk::fifo >
> pool( tsk::poolsize( 1) );
+ tsk::task< int > t(
+ boost::bind(
+ fibonacci_fn,
+ 10) );
                 tsk::handle< int > h(
- tsk::async(
- tsk::make_task(
- fibonacci_fn,
- 10),
- pool) );
+ tsk::async( boost::move( t), pool) );
                 pool.shutdown();
                 BOOST_CHECK( pool.closed() );
                 BOOST_CHECK_EQUAL( h.get(), 55);
         }
 
         // check runtime_error throw inside task
- void test_case_8()
+ void test_case_7()
         {
                 tsk::static_pool<
                         tsk::unbounded_channel< tsk::fifo >
> pool( tsk::poolsize( 1) );
+ tsk::task< void > t( throwing_fn);
                 tsk::handle< void > h(
- tsk::async(
- tsk::make_task( throwing_fn),
- pool) );
+ tsk::async( boost::move( t), pool) );
                 pool.shutdown();
                 BOOST_CHECK_THROW( h.get(), std::runtime_error);
         }
 
         // check shutdown with task_rejected exception
- void test_case_9()
+ void test_case_8()
         {
                 tsk::static_pool<
                         tsk::unbounded_channel< tsk::fifo >
> pool( tsk::poolsize( 1) );
+ tsk::task< int > t(
+ boost::bind(
+ boost::bind(
+ fibonacci_fn,
+ 10) ) );
                 pool.shutdown();
                 BOOST_CHECK( pool.closed() );
                 BOOST_CHECK_THROW(
- tsk::async(
- tsk::make_task(
- boost::bind(
- fibonacci_fn,
- 10) ),
- pool),
+ tsk::async( boost::move( t), pool),
                         tsk::task_rejected);
         }
 
         // check shutdown_now with thread_interrupted exception
- void test_case_10()
+ void test_case_9()
         {
                 tsk::static_pool<
                         tsk::unbounded_channel< tsk::fifo >
> pool( tsk::poolsize( 1) );
+ tsk::task< void > t(
+ boost::bind(
+ delay_fn,
+ pt::millisec( 500) ) );
                 tsk::handle< void > h(
- tsk::async(
- tsk::make_task(
- delay_fn,
- pt::millisec( 500) ),
- pool) );
+ tsk::async( boost::move( t), pool) );
                 boost::this_thread::sleep( pt::millisec( 250) );
                 BOOST_CHECK_EQUAL( pool.size(), std::size_t( 1) );
                 pool.shutdown_now();
@@ -203,35 +199,35 @@
         }
 
         // check pending
- void test_case_11()
+ void test_case_10()
         {
                 typedef tsk::static_pool<
                         tsk::unbounded_channel< tsk::fifo >
> pool_type;
                 pool_type pool( tsk::poolsize( 1) );
                 boost::barrier b( 2);
+ tsk::task< void > t1(
+ boost::bind(
+ barrier_fn,
+ boost::ref( b) ) );
+ tsk::task< int > t2(
+ boost::bind(
+ fibonacci_fn,
+ 10) );
+ tsk::task< int > t3(
+ boost::bind(
+ fibonacci_fn,
+ 10) );
                 tsk::handle< void > h1(
- tsk::async(
- tsk::make_task(
- barrier_fn,
- boost::ref( b) ),
- pool) );
+ tsk::async( boost::move( t1), pool) );
                 boost::this_thread::sleep( pt::millisec( 250) );
                 BOOST_CHECK_EQUAL( pool.pending(), std::size_t( 0) );
                 tsk::handle< int > h2(
- tsk::async(
- tsk::make_task(
- fibonacci_fn,
- 10),
- pool) );
+ tsk::async( boost::move( t2), pool) );
                 boost::this_thread::sleep( pt::millisec(250) );
                 BOOST_CHECK_EQUAL( pool.pending(), std::size_t( 1) );
                 tsk::handle< int > h3(
- tsk::async(
- tsk::make_task(
- fibonacci_fn,
- 10),
- pool) );
+ tsk::async( boost::move( t3), pool) );
                 boost::this_thread::sleep( pt::millisec(250) );
                 BOOST_CHECK_EQUAL( pool.pending(), std::size_t( 2) );
                 b.wait();
@@ -242,17 +238,17 @@
         }
 
         // check wait
- void test_case_12()
+ void test_case_11()
         {
                 tsk::static_pool<
                         tsk::unbounded_channel< tsk::fifo >
> pool( tsk::poolsize( 3) );
+ tsk::task< int > t(
+ boost::bind(
+ fibonacci_fn,
+ 10) );
                 tsk::handle< int > h(
- tsk::async(
- tsk::make_task(
- fibonacci_fn,
- 10),
- pool) );
+ tsk::async( boost::move( t), pool) );
                 h.wait();
                 BOOST_CHECK( h.is_ready() );
                 BOOST_CHECK( h.has_value() );
@@ -261,17 +257,17 @@
         }
 
         // check wait_for
- void test_case_13()
+ void test_case_12()
         {
                 tsk::static_pool<
                         tsk::unbounded_channel< tsk::fifo >
> pool( tsk::poolsize( 3) );
+ tsk::task< void > t(
+ boost::bind(
+ delay_fn,
+ pt::seconds( 1) ) );
                 tsk::handle< void > h(
- tsk::async(
- tsk::make_task(
- delay_fn,
- pt::seconds( 1) ),
- pool) );
+ tsk::async( boost::move( t), pool) );
                 BOOST_CHECK( h.wait_for( pt::seconds( 3) ) );
                 BOOST_CHECK( h.is_ready() );
                 BOOST_CHECK( h.has_value() );
@@ -279,17 +275,17 @@
         }
 
         // check wait_for
- void test_case_14()
+ void test_case_13()
         {
                 tsk::static_pool<
                         tsk::unbounded_channel< tsk::fifo >
> pool( tsk::poolsize( 3) );
+ tsk::task< void > t(
+ boost::bind(
+ delay_fn,
+ pt::seconds( 3) ) );
                 tsk::handle< void > h(
- tsk::async(
- tsk::make_task(
- delay_fn,
- pt::seconds( 3) ),
- pool) );
+ tsk::async( boost::move( t), pool) );
                 BOOST_CHECK( ! h.wait_for( pt::seconds( 1) ) );
                 BOOST_CHECK( ! h.is_ready() );
                 BOOST_CHECK( ! h.has_value() );
@@ -297,17 +293,17 @@
         }
 
         // check wait_until
- void test_case_15()
+ void test_case_14()
         {
                 tsk::static_pool<
                         tsk::unbounded_channel< tsk::fifo >
> pool( tsk::poolsize( 3) );
+ tsk::task< void > t(
+ boost::bind(
+ delay_fn,
+ pt::seconds( 1) ) );
                 tsk::handle< void > h(
- tsk::async(
- tsk::make_task(
- delay_fn,
- pt::seconds( 1) ),
- pool) );
+ tsk::async( boost::move( t), pool) );
                 BOOST_CHECK( h.wait_until( boost::get_system_time() + pt::seconds( 3) ) );
                 BOOST_CHECK( h.is_ready() );
                 BOOST_CHECK( h.has_value() );
@@ -315,17 +311,17 @@
         }
 
         // check wait_until
- void test_case_16()
+ void test_case_15()
         {
                 tsk::static_pool<
                         tsk::unbounded_channel< tsk::fifo >
> pool( tsk::poolsize( 3) );
+ tsk::task< void > t(
+ boost::bind(
+ delay_fn,
+ pt::seconds( 3) ) );
                 tsk::handle< void > h(
- tsk::async(
- tsk::make_task(
- delay_fn,
- pt::seconds( 3) ),
- pool) );
+ tsk::async( boost::move( t), pool) );
                 BOOST_CHECK( ! h.wait_until( boost::get_system_time() + pt::seconds( 1) ) );
                 BOOST_CHECK( ! h.is_ready() );
                 BOOST_CHECK( ! h.has_value() );
@@ -333,36 +329,36 @@
         }
 
         // check interrupt
- void test_case_17()
+ void test_case_16()
         {
                 tsk::static_pool<
                         tsk::unbounded_channel< tsk::fifo >
> pool( tsk::poolsize( 3) );
+ tsk::task< void > t(
+ boost::bind(
+ delay_fn,
+ pt::seconds( 3) ) );
                 tsk::handle< void > h(
- tsk::async(
- tsk::make_task(
- delay_fn,
- pt::seconds( 3) ),
- pool) );
+ tsk::async( boost::move( t), pool) );
                 h.interrupt();
                 BOOST_CHECK( h.interruption_requested() );
                 BOOST_CHECK_THROW( h.get(), tsk::task_interrupted);
         }
 
         // check interrupt_and_wait
- void test_case_18()
+ void test_case_17()
         {
                 tsk::static_pool<
                         tsk::unbounded_channel< tsk::fifo >
> pool( tsk::poolsize( 3) );
                 bool finished( false);
+ tsk::task< void > t(
+ boost::bind(
+ interrupt_fn,
+ pt::seconds( 1),
+ boost::ref( finished) ) );
                 tsk::handle< void > h(
- tsk::async(
- tsk::make_task(
- interrupt_fn,
- pt::seconds( 1),
- boost::ref( finished) ),
- pool) );
+ tsk::async( boost::move( t), pool) );
                 h.interrupt_and_wait();
                 BOOST_CHECK( finished);
                 BOOST_CHECK( h.is_ready() );
@@ -373,19 +369,19 @@
         }
 
         // check interrupt_and_wait_for
- void test_case_19()
+ void test_case_18()
         {
                 tsk::static_pool<
                         tsk::unbounded_channel< tsk::fifo >
> pool( tsk::poolsize( 3) );
                 bool finished( false);
+ tsk::task< void > t(
+ boost::bind(
+ interrupt_fn,
+ pt::seconds( 1),
+ boost::ref( finished) ) );
                 tsk::handle< void > h(
- tsk::async(
- tsk::make_task(
- interrupt_fn,
- pt::seconds( 1),
- boost::ref( finished) ),
- pool) );
+ tsk::async( boost::move( t), pool) );
                 BOOST_CHECK( h.interrupt_and_wait_for( pt::seconds( 3) ) );
                 BOOST_CHECK( finished);
                 BOOST_CHECK( h.is_ready() );
@@ -396,34 +392,34 @@
         }
 
         // check interrupt_and_wait_for
- void test_case_20()
+ void test_case_19()
         {
                 tsk::static_pool<
                         tsk::unbounded_channel< tsk::fifo >
> pool( tsk::poolsize( 3) );
+ tsk::task< void > t(
+ boost::bind(
+ non_interrupt_fn,
+ 3) );
                 tsk::handle< void > h(
- tsk::async(
- tsk::make_task(
- non_interrupt_fn,
- 3),
- pool) );
+ tsk::async( boost::move( t), pool) );
                 BOOST_CHECK( ! h.interrupt_and_wait_for( pt::seconds( 1) ) );
         }
 
         // check interrupt_and_wait_until
- void test_case_21()
+ void test_case_20()
         {
                 tsk::static_pool<
                         tsk::unbounded_channel< tsk::fifo >
> pool( tsk::poolsize( 3) );
                 bool finished( false);
+ tsk::task< void > t(
+ boost::bind(
+ interrupt_fn,
+ pt::seconds( 1),
+ boost::ref( finished) ) );
                 tsk::handle< void > h(
- tsk::async(
- tsk::make_task(
- interrupt_fn,
- pt::seconds( 1),
- boost::ref( finished) ),
- pool) );
+ tsk::async( boost::move( t), pool) );
                 BOOST_CHECK( h.interrupt_and_wait_until( boost::get_system_time() + pt::seconds( 3) ) );
                 BOOST_CHECK( finished);
                 BOOST_CHECK( h.is_ready() );
@@ -434,22 +430,22 @@
         }
 
         // check interrupt_and_wait_until
- void test_case_22()
+ void test_case_21()
         {
                 tsk::static_pool<
                         tsk::unbounded_channel< tsk::fifo >
> pool( tsk::poolsize( 3) );
+ tsk::task< void > t(
+ boost::bind(
+ non_interrupt_fn,
+ 3) );
                 tsk::handle< void > h(
- tsk::async(
- tsk::make_task(
- non_interrupt_fn,
- 3),
- pool) );
+ tsk::async( boost::move( t), pool) );
                 BOOST_CHECK( ! h.interrupt_and_wait_until( boost::get_system_time() + pt::seconds( 1) ) );
         }
 
         // check fifo scheduling
- void test_case_23()
+ void test_case_22()
         {
                 typedef tsk::static_pool<
                         tsk::unbounded_channel< tsk::fifo >
@@ -457,24 +453,24 @@
                 BOOST_CHECK( ! tsk::has_attribute< pool_type >::value);
                 pool_type pool( tsk::poolsize( 1) );
                 boost::barrier b( 2);
- tsk::async(
- tsk::make_task(
- barrier_fn,
- boost::ref( b) ),
- pool);
                 std::vector< int > buffer;
- tsk::async(
- tsk::make_task(
+ tsk::task< void > t1(
+ boost::bind(
+ barrier_fn,
+ boost::ref( b) ) );
+ tsk::task< void > t2(
+ boost::bind(
                                 buffer_fibonacci_fn,
                                 boost::ref( buffer),
- 10),
- pool);
- tsk::async(
- tsk::make_task(
+ 10) );
+ tsk::task< void > t3(
+ boost::bind(
                                 buffer_fibonacci_fn,
                                 boost::ref( buffer),
- 0),
- pool);
+ 0) );
+ tsk::async( boost::move( t1), pool);
+ tsk::async( boost::move( t2), pool);
+ tsk::async( boost::move( t3), pool);
                 b.wait();
                 pool.shutdown();
                 BOOST_CHECK_EQUAL( buffer[0], 55);
@@ -483,7 +479,7 @@
         }
 
         // check priority scheduling
- void test_case_24()
+ void test_case_23()
         {
                 typedef tsk::static_pool<
                         tsk::unbounded_channel< tsk::priority< int > >
@@ -493,27 +489,24 @@
                 BOOST_CHECK( type::value);
                 pool_type pool( tsk::poolsize( 1) );
                 boost::barrier b( 2);
- tsk::async(
- tsk::make_task(
- barrier_fn,
- boost::ref( b) ),
- 0,
- pool);
                 std::vector< int > buffer;
- tsk::async(
- tsk::make_task(
+ tsk::task< void > t1(
+ boost::bind(
+ barrier_fn,
+ boost::ref( b) ) );
+ tsk::task< void > t2(
+ boost::bind(
                                 buffer_fibonacci_fn,
                                 boost::ref( buffer),
- 10),
- 1,
- pool);
- tsk::async(
- tsk::make_task(
+ 10) );
+ tsk::task< void > t3(
+ boost::bind(
                                 buffer_fibonacci_fn,
                                 boost::ref( buffer),
- 0),
- 0,
- pool);
+ 0) );
+ tsk::async( boost::move( t1), 0, pool);
+ tsk::async( boost::move( t2), 1, pool);
+ tsk::async( boost::move( t3), 0, pool);
                 b.wait();
                 pool.shutdown();
                 BOOST_CHECK_EQUAL( buffer[0], 0);
@@ -522,7 +515,7 @@
         }
 
         // check smart scheduling
- void test_case_25()
+ void test_case_24()
         {
                 typedef tsk::static_pool<
                         tsk::unbounded_channel< tsk::smart< int, std::less< int >, tsk::replace_oldest, tsk::take_oldest > >
@@ -532,33 +525,30 @@
                 BOOST_CHECK( type::value);
                 pool_type pool( tsk::poolsize( 1) );
                 boost::barrier b( 2);
- pool.submit(
- tsk::make_task(
- barrier_fn,
- boost::ref( b) ),
- 0);
                 std::vector< int > buffer;
- tsk::async(
- tsk::make_task(
+ tsk::task< void > t1(
+ boost::bind(
+ barrier_fn,
+ boost::ref( b) ) );
+ tsk::task< void > t2(
+ boost::bind(
                                 buffer_fibonacci_fn,
                                 boost::ref( buffer),
- 10),
- 2,
- pool);
- tsk::async(
- tsk::make_task(
+ 10) );
+ tsk::task< void > t3(
+ boost::bind(
                                 buffer_fibonacci_fn,
                                 boost::ref( buffer),
- 0),
- 1,
- pool);
- tsk::async(
- tsk::make_task(
+ 0) );
+ tsk::task< void > t4(
+ boost::bind(
                                 buffer_fibonacci_fn,
                                 boost::ref( buffer),
- 1),
- 2,
- pool);
+ 1) );
+ pool.submit( boost::move( t1), 0);
+ tsk::async( boost::move( t2), 2, pool);
+ tsk::async( boost::move( t3), 1, pool);
+ tsk::async( boost::move( t4), 2, pool);
                 b.wait();
                 pool.shutdown();
                 BOOST_CHECK_EQUAL( buffer[0], 0);
@@ -596,7 +586,6 @@
         test->add( BOOST_CLASS_TEST_CASE( & test_unbounded_pool::test_case_22, instance) );
         test->add( BOOST_CLASS_TEST_CASE( & test_unbounded_pool::test_case_23, instance) );
         test->add( BOOST_CLASS_TEST_CASE( & test_unbounded_pool::test_case_24, instance) );
- test->add( BOOST_CLASS_TEST_CASE( & test_unbounded_pool::test_case_25, instance) );
 
         return test;
 }


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