Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r58657 - in sandbox/task: boost/task boost/task/detail boost/task/spin libs/task/src libs/task/test
From: oliver.kowalke_at_[hidden]
Date: 2010-01-03 12:42:59


Author: olli
Date: 2010-01-03 12:42:57 EST (Sun, 03 Jan 2010)
New Revision: 58657
URL: http://svn.boost.org/trac/boost/changeset/58657

Log:
- check if spin::promise or promise hast obe used

Text files modified:
   sandbox/task/boost/task/as_sub_task.hpp | 3
   sandbox/task/boost/task/callable.hpp | 129 +++++++++++++++++++++-----------
   sandbox/task/boost/task/context.hpp | 55 +++++++------
   sandbox/task/boost/task/detail/pool_base.hpp | 35 +++++---
   sandbox/task/boost/task/handle.hpp | 158 ++++++---------------------------------
   sandbox/task/boost/task/new_thread.hpp | 16 ++-
   sandbox/task/boost/task/own_thread.hpp | 16 ++-
   sandbox/task/boost/task/spin/future.hpp | 1
   sandbox/task/boost/task/task.hpp | 86 +++++++++++---------
   sandbox/task/libs/task/src/callable.cpp | 12 +-
   sandbox/task/libs/task/src/context.cpp | 25 +++--
   sandbox/task/libs/task/test/test_new_thread.cpp | 6
   sandbox/task/libs/task/test/test_own_thread.cpp | 6
   13 files changed, 255 insertions(+), 293 deletions(-)

Modified: sandbox/task/boost/task/as_sub_task.hpp
==============================================================================
--- sandbox/task/boost/task/as_sub_task.hpp (original)
+++ sandbox/task/boost/task/as_sub_task.hpp 2010-01-03 12:42:57 EST (Sun, 03 Jan 2010)
@@ -35,10 +35,9 @@
                 {
                         spin::promise< R > prom;
                         spin::shared_future< R > f( prom.get_future() );
- t.set_promise( boost::move( prom) );
                         context ctx;
                         handle< R > h( f, ctx);
- w->put( callable( t, ctx) );
+ w->put( callable( t, boost::move( prom), ctx) );
                         return h;
                 }
                 else

Modified: sandbox/task/boost/task/callable.hpp
==============================================================================
--- sandbox/task/boost/task/callable.hpp (original)
+++ sandbox/task/boost/task/callable.hpp 2010-01-03 12:42:57 EST (Sun, 03 Jan 2010)
@@ -25,68 +25,107 @@
 
 namespace boost {
 namespace tasks {
+namespace detail {
 
-class BOOST_TASKS_DECL callable
+struct BOOST_TASKS_DECL callable_base
 {
-private:
- struct impl
- {
- atomic< unsigned int > use_count_;
+ atomic< unsigned int > use_count;
 
- impl() :
- use_count_( 0)
- {}
+ callable_base() :
+ use_count( 0)
+ {}
 
- virtual ~impl() {}
+ virtual ~callable_base() {}
 
- virtual void run() = 0;
+ virtual void run() = 0;
 
- virtual void reset( shared_ptr< thread > const&) = 0;
+ virtual void reset( shared_ptr< thread > const&) = 0;
 
- inline friend void intrusive_ptr_add_ref( impl * p)
- { p->use_count_.fetch_add( 1, memory_order_relaxed); }
-
- inline friend void intrusive_ptr_release( impl * p)
+ inline friend void intrusive_ptr_add_ref( callable_base * p)
+ { p->use_count.fetch_add( 1, memory_order_relaxed); }
+
+ inline friend void intrusive_ptr_release( callable_base * p)
+ {
+ if ( p->use_count.fetch_sub( 1, memory_order_release) == 1)
                 {
- if ( p->use_count_.fetch_sub( 1, memory_order_release) == 1)
- {
- atomic_thread_fence( memory_order_acquire);
- delete p;
- }
+ atomic_thread_fence( memory_order_acquire);
+ delete p;
                 }
- };
+ }
+};
 
- template< typename T >
- class wrapper : public impl
- {
- private:
- T t_;
- context ctx_;
-
- public:
- wrapper(
- BOOST_RV_REF( T) t,
- context const& ctx) :
- t_( t), ctx_( ctx)
- {}
-
- void run()
- { t_(); }
-
- void reset( shared_ptr< thread > const& thrd)
- { ctx_.reset( thrd); }
- };
+template< typename Task, typename Promise >
+class callable_object : public callable_base
+{
+private:
+ Task t_;
+ context ctx_;
+
+public:
+#ifdef BOOST_HAS_RVALUE_REFS
+ callable_object(
+ Task && t,
+ Promise && prom,
+ context const& ctx) :
+ t_( t), ctx_( ctx)
+ { t_.set_promise( prom); }
+#else
+ callable_object(
+ BOOST_RV_REF( Task) t,
+ boost::detail::thread_move_t< Promise > prom,
+ context const& ctx) :
+ t_( t), ctx_( ctx)
+ { t_.set_promise( prom); }
+#endif
+
+ callable_object(
+ BOOST_RV_REF( Task) t,
+ BOOST_RV_REF( Promise) prom,
+ context const& ctx) :
+ t_( t), ctx_( ctx)
+ { t_.set_promise( prom); }
 
- intrusive_ptr< impl > impl_;
+ void run()
+ { t_(); }
+
+ void reset( shared_ptr< thread > const& thrd)
+ { ctx_.reset( thrd); }
+};
+
+}
+
+class BOOST_TASKS_DECL callable
+{
+private:
+ intrusive_ptr< detail::callable_base > base_;
 
 public:
         callable();
 
- template< typename T >
+#ifdef BOOST_HAS_RVALUE_REFS
+ template< typename Task, typename Promise >
+ callable(
+ Task && t,
+ Promise && prom,
+ context const& ctx) :
+ base_( new detail::callable_object< Task, Promise >( t, prom, ctx) )
+ {}
+#else
+ template< typename Task, typename Promise >
+ callable(
+ BOOST_RV_REF( Task) t,
+ boost::detail::thread_move_t< Promise > prom,
+ context const& ctx) :
+ base_( new detail::callable_object< Task, Promise >( t, prom, ctx) )
+ {}
+#endif
+
+ template< typename Task, typename Promise >
         callable(
- BOOST_RV_REF( T) t,
+ BOOST_RV_REF( Task) t,
+ BOOST_RV_REF( Promise) prom,
                         context const& ctx) :
- impl_( new wrapper< T >( t, ctx) )
+ base_( new detail::callable_object< Task, Promise >( t, prom, ctx) )
         {}
 
         void operator()();

Modified: sandbox/task/boost/task/context.hpp
==============================================================================
--- sandbox/task/boost/task/context.hpp (original)
+++ sandbox/task/boost/task/context.hpp 2010-01-03 12:42:57 EST (Sun, 03 Jan 2010)
@@ -28,45 +28,48 @@
 
 namespace boost {
 namespace tasks {
+namespace detail {
 
-class BOOST_TASKS_DECL context
+class BOOST_TASKS_DECL context_base : private noncopyable
 {
 private:
- class impl : private noncopyable
- {
- private:
- atomic< unsigned int > use_count_;
- bool requested_;
- mutex mtx_;
- shared_ptr< thread > thrd_;
+ atomic< unsigned int > use_count_;
+ bool requested_;
+ mutex mtx_;
+ shared_ptr< thread > thrd_;
 
- void reset_( shared_ptr< thread > const& thrd);
+ void reset_( shared_ptr< thread > const& thrd);
 
- void interrupt_();
+ void interrupt_();
 
- public:
- impl();
+public:
+ context_base();
 
- void reset( shared_ptr< thread > const& thrd);
+ void reset( shared_ptr< thread > const& thrd);
 
- void interrupt();
+ void interrupt();
 
- bool interruption_requested();
+ bool interruption_requested();
 
- inline friend void intrusive_ptr_add_ref( impl * p)
- { p->use_count_.fetch_add( 1, memory_order_relaxed); }
-
- inline friend void intrusive_ptr_release( impl * p)
+ inline friend void intrusive_ptr_add_ref( context_base * p)
+ { p->use_count_.fetch_add( 1, memory_order_relaxed); }
+
+ inline friend void intrusive_ptr_release( context_base * p)
+ {
+ if ( p->use_count_.fetch_sub( 1, memory_order_release) == 1)
                 {
- if ( p->use_count_.fetch_sub( 1, memory_order_release) == 1)
- {
- atomic_thread_fence( memory_order_acquire);
- delete p;
- }
+ atomic_thread_fence( memory_order_acquire);
+ delete p;
                 }
- };
+ }
+};
+
+}
 
- intrusive_ptr< impl > impl_;
+class BOOST_TASKS_DECL context
+{
+private:
+ intrusive_ptr< detail::context_base > base_;
 
 public:
         context();

Modified: sandbox/task/boost/task/detail/pool_base.hpp
==============================================================================
--- sandbox/task/boost/task/detail/pool_base.hpp (original)
+++ sandbox/task/boost/task/detail/pool_base.hpp 2010-01-03 12:42:57 EST (Sun, 03 Jan 2010)
@@ -285,7 +285,7 @@
         { queue_.lower_bound( lwm); }
 
         template< typename R >
- handle< R > submit( task< R > t)
+ handle< R > submit( BOOST_RV_REF( task< R >) t)
         {
                 if ( deactivated_() )
                         throw task_rejected("pool is closed");
@@ -294,28 +294,33 @@
                 {
                         spin::promise< R > prom;
                         spin::shared_future< R > f( prom.get_future() );
- t.set_promise( boost::move( prom) );
                         context ctx;
                         handle< R > h( f, ctx);
- queue_.put( callable( boost::move( t), ctx) );
+ queue_.put( callable( t, boost::move( prom), ctx) );
                         return h;
                 }
                 else
                 {
                         promise< R > prom;
                         shared_future< R > f( prom.get_future() );
- // TODO: if boost.thread uses boost.move
- // use boost::move()
- t.set_promise( prom);
                         context ctx;
                         handle< R > h( f, ctx);
- queue_.put( callable( boost::move( t), ctx) );
+ queue_.put(
+ callable(
+ t,
+// TODO: workaround because thread_move_t will be abigous for move
+#ifdef BOOST_HAS_RVALUE_REFS
+ boost::move( prom),
+#else
+ boost::detail::thread_move_t< promise< R > >( prom),
+#endif
+ ctx) );
                         return h;
                 }
         }
 
         template< typename R, typename Attr >
- handle< R > submit( task< R > t, Attr const& attr)
+ handle< R > submit( BOOST_RV_REF( task< R >) t, Attr const& attr)
         {
                 if ( deactivated_() )
                         throw task_rejected("pool is closed");
@@ -324,12 +329,11 @@
                 {
                         spin::promise< R > prom;
                         spin::shared_future< R > f( prom.get_future() );
- t.set_promise( boost::move( prom) );
                         context ctx;
                         handle< R > h( f, ctx);
                         queue_.put(
                                 value_type(
- callable( boost::move( t), ctx),
+ callable( t, boost::move( prom), ctx),
                                         attr) );
                         return h;
                 }
@@ -339,12 +343,19 @@
                         shared_future< R > f( prom.get_future() );
                         // TODO: if boost.thread uses boost.move
                         // use boost::move()
- t.set_promise( prom);
                         context ctx;
                         handle< R > h( f, ctx);
                         queue_.put(
                                 value_type(
- callable( boost::move( t), ctx),
+ callable(
+ t,
+// TODO: workaround because thread_move_t will be abigous for move
+#ifdef BOOST_HAS_RVALUE_REFS
+ boost::move( prom),
+#else
+ boost::detail::thread_move_t< promise< R > >( prom),
+#endif
+ ctx),
                                         attr) );
                         return h;
                 }

Modified: sandbox/task/boost/task/handle.hpp
==============================================================================
--- sandbox/task/boost/task/handle.hpp (original)
+++ sandbox/task/boost/task/handle.hpp 2010-01-03 12:42:57 EST (Sun, 03 Jan 2010)
@@ -167,34 +167,6 @@
 class handle
 {
 private:
- template< typename T1, typename T2 >
- friend void waitfor_all( handle< T1 > &, handle< T2 > &);
- template< typename T1, typename T2, typename T3 >
- friend void waitfor_all( handle< T1 > &, handle< T2 > &, handle< T3 > &);
- template< typename T1, typename T2, typename T3, typename T4 >
- friend void waitfor_all(
- handle< T1 > &, handle< T2 > &, handle< T3 > &, handle< T4 > &);
- template< typename T1, typename T2, typename T3, typename T4, typename T5 >
- friend void waitfor_all(
- handle< T1 > &, handle< T2 > &, handle< T3 > &, handle< T4 > &,
- handle< T5 > &);
- template< typename Iterator >
- friend typename disable_if< is_handle_type< Iterator >, Iterator >::type
- waitfor_any( Iterator begin, Iterator end);
- template< typename H1, typename H2 >
- friend typename enable_if< is_handle_type< H1 >, unsigned >::type
- waitfor_any( H1 &, H2 &);
- template< typename T1, typename T2, typename T3 >
- friend unsigned int waitfor_any(
- handle< T1 > &, handle< T2 > &, handle< T3 > &);
- template< typename T1, typename T2, typename T3, typename T4 >
- friend unsigned int waitfor_any(
- handle< T1 > &, handle< T2 > &, handle< T3 > &, handle< T4 > &);
- template< typename T1, typename T2, typename T3, typename T4, typename T5 >
- friend unsigned int waitfor_any(
- handle< T1 > &, handle< T2 > &, handle< T3 > &, handle< T4 > &,
- handle< T5 > &);
-
         intrusive_ptr< detail::handle_base< R > > base_;
 
 public:
@@ -265,125 +237,45 @@
 typename disable_if< is_handle_type< Iterator >, void >::type waitfor_all(
         Iterator begin, Iterator end)
 {
- try
- {
- for ( Iterator i = begin; i != end; ++i)
- i->wait();
- }
- catch ( thread_interrupted const&)
- { throw task_interrupted(); }
+ for ( Iterator i = begin; i != end; ++i)
+ i->wait();
 }
 
-template< typename T1, typename T2 >
-void waitfor_all( handle< T1 > & t1, handle< T2 > & t2)
+template< typename R1, typename R2 >
+void waitfor_all( handle< R1 > & h1, handle< R2 > & h2)
 {
- try
- { wait_for_all( * t1.base_->fut_, * t2.base_->fut_); }
- catch ( thread_interrupted const&)
- { throw task_interrupted(); }
+ h1.wait();
+ h2.wait();
 }
 
-template< typename T1, typename T2, typename T3 >
-void waitfor_all( handle< T1 > & t1, handle< T2 > & t2, handle< T3 > & t3)
+template< typename R1, typename R2, typename R3 >
+void waitfor_all( handle< R1 > & h1, handle< R2 > & h2, handle< R3 > & h3)
 {
- try
- { wait_for_all( * t1.base_->fut_, * t2.base_->fut_, * t3.base_->fut_); }
- catch ( thread_interrupted const&)
- { throw task_interrupted(); }
+ h1.wait();
+ h2.wait();
+ h3.wait();
 }
 
-template< typename T1, typename T2, typename T3, typename T4 >
+template< typename R1, typename R2, typename R3, typename R4 >
 void waitfor_all(
- handle< T1 > & t1, handle< T2 > & t2, handle< T3 > & t3, handle< T4 > & t4)
+ handle< R1 > & h1, handle< R2 > & h2, handle< R3 > & h3, handle< R4 > & h4)
 {
- try
- {
- wait_for_all( * t1.base_->fut_, * t2.base_->fut_, * t3.base_->fut_,
- * t4.base_->fut_);
- }
- catch ( thread_interrupted const&)
- { throw task_interrupted(); }
+ h1.wait();
+ h2.wait();
+ h3.wait();
+ h4.wait();
 }
 
-template< typename T1, typename T2, typename T3, typename T4, typename T5 >
+template< typename R1, typename R2, typename R3, typename R4, typename R5 >
 void waitfor_all(
- handle< T1 > & t1, handle< T2 > & t2, handle< T3 > & t3, handle< T4 > & t4,
- handle< T5 > & t5)
+ handle< R1 > & h1, handle< R2 > & h2, handle< R3 > & h3, handle< R4 > & h4,
+ handle< R5 > & h5)
 {
- try
- {
- wait_for_all( * t1.base_->fut_, * t2.base_->fut_, * t3.base_->fut_,
- * t4.base_->fut_, * t5.base_->fut_);
- }
- catch ( thread_interrupted const&)
- { throw task_interrupted(); }
-}
-
-template< typename Iterator >
-typename disable_if< is_handle_type< Iterator >, Iterator >::type waitfor_any(
- Iterator begin, Iterator end)
-{
- try
- {
- boost::detail::future_waiter waiter;
- for ( Iterator i = begin; i != end; ++i)
- waiter.add( * ( i.base_->fut_) );
- return next( begin, waiter.wait() );
- }
- catch ( thread_interrupted const&)
- { throw task_interrupted(); }
-}
-
-template< typename H1, typename H2 >
-typename enable_if< is_handle_type< H1 >, unsigned >::type waitfor_any(
- H1 & h1, H2 & h2)
-{
- try
- { return wait_for_any( * h1.base_->fut_, * h2.base_->fut_ ); }
- catch ( thread_interrupted const&)
- { throw task_interrupted(); }
-}
-
-template< typename T1, typename T2, typename T3 >
-unsigned int waitfor_any(
- handle< T1 > & t1, handle< T2 > & t2, handle< T3 > & t3)
-{
- try
- {
- return wait_for_any(
- * t1.base_->fut_, * t2.base_->fut_, * t3.base_->fut_ );
- }
- catch ( thread_interrupted const&)
- { throw task_interrupted(); }
-}
-
-template< typename T1, typename T2, typename T3, typename T4 >
-unsigned int waitfor_any(
- handle< T1 > & t1, handle< T2 > & t2, handle< T3 > & t3, handle< T4 > & t4)
-{
- try
- {
- return wait_for_any(
- * t1.base_->fut_, * t2.base_->fut_, * t3.base_->fut_,
- * t4.base_->fut_ );
- }
- catch ( thread_interrupted const&)
- { throw task_interrupted(); }
-}
-
-template< typename T1, typename T2, typename T3, typename T4, typename T5 >
-unsigned int waitfor_any(
- handle< T1 > & t1, handle< T2 > & t2, handle< T3 > & t3, handle< T4 > & t4,
- handle< T5 > & t5)
-{
- try
- {
- return wait_for_any(
- * t1.base_->fut_, * t2.base_->fut_, * t3.base_->fut_,
- * t4.base_->fut_, * t5.base_->fut_ );
- }
- catch ( thread_interrupted const&)
- { throw task_interrupted(); }
+ h1.wait();
+ h2.wait();
+ h3.wait();
+ h4.wait();
+ h5.wait();
 }
 
 }}

Modified: sandbox/task/boost/task/new_thread.hpp
==============================================================================
--- sandbox/task/boost/task/new_thread.hpp (original)
+++ sandbox/task/boost/task/new_thread.hpp 2010-01-03 12:42:57 EST (Sun, 03 Jan 2010)
@@ -54,10 +54,9 @@
                 {
                         spin::promise< R > prom;
                         spin::shared_future< R > f( prom.get_future() );
- t.set_promise( boost::move( prom) );
                         context ctx1, ctx2;
                         handle< R > h( f, ctx1);
- callable ca( t, ctx2);
+ callable ca( t, boost::move( prom), ctx2);
                         shared_ptr< thread > thrd(
                                 new thread( ca),
                                 detail::joiner() );
@@ -68,12 +67,17 @@
                 {
                         promise< R > prom;
                         shared_future< R > f( prom.get_future() );
- // TODO: if boost.thread uses boost.move
- // use boost::move()
- t.set_promise( prom);
                         context ctx1, ctx2;
                         handle< R > h( f, ctx1);
- callable ca( t, ctx2);
+ callable ca(
+ t,
+// TODO: workaround because thread_move_t will be abigous for move
+#ifdef BOOST_HAS_RVALUE_REFS
+ boost::move( prom),
+#else
+ boost::detail::thread_move_t< promise< R > >( prom),
+#endif
+ ctx2);
                         shared_ptr< thread > thrd(
                                 new thread( ca),
                                 detail::joiner() );

Modified: sandbox/task/boost/task/own_thread.hpp
==============================================================================
--- sandbox/task/boost/task/own_thread.hpp (original)
+++ sandbox/task/boost/task/own_thread.hpp 2010-01-03 12:42:57 EST (Sun, 03 Jan 2010)
@@ -32,10 +32,9 @@
                 {
                         spin::promise< R > prom;
                         spin::shared_future< R > f( prom.get_future() );
- t.set_promise( boost::move( prom) );
                         context ctx;
                         handle< R > h( f, ctx);
- callable ca( t, ctx);
+ callable ca( t, boost::move( prom), ctx);
                         ca();
                         return h;
                 }
@@ -43,12 +42,17 @@
                 {
                         promise< R > prom;
                         shared_future< R > f( prom.get_future() );
- // TODO: if boost.thread uses boost.move
- // use boost::move()
- t.set_promise( prom);
                         context ctx;
                         handle< R > h( f, ctx);
- callable ca( t, ctx);
+ callable ca(
+ t,
+// TODO: workaround because thread_move_t will be abigous for move
+#ifdef BOOST_HAS_RVALUE_REFS
+ boost::move( prom),
+#else
+ boost::detail::thread_move_t< promise< R > >( prom),
+#endif
+ ctx);
                         ca();
                         return h;
                 }

Modified: sandbox/task/boost/task/spin/future.hpp
==============================================================================
--- sandbox/task/boost/task/spin/future.hpp (original)
+++ sandbox/task/boost/task/spin/future.hpp 2010-01-03 12:42:57 EST (Sun, 03 Jan 2010)
@@ -966,7 +966,6 @@
         }
     }
     
-
     virtual void do_run()=0;
 };
 

Modified: sandbox/task/boost/task/task.hpp
==============================================================================
--- sandbox/task/boost/task/task.hpp (original)
+++ sandbox/task/boost/task/task.hpp 2010-01-03 12:42:57 EST (Sun, 03 Jan 2010)
@@ -42,9 +42,11 @@
 
         virtual ~promise_adaptor() {}
 
- virtual void set_value( typename tasks::detail::future_traits< R >::source_reference_type) = 0;
+ virtual void set_value(
+ typename tasks::detail::future_traits< R >::source_reference_type) = 0;
 
- virtual void set_value( typename tasks::detail::future_traits< R >::rvalue_source_type) = 0;
+ virtual void set_value(
+ typename tasks::detail::future_traits< R >::rvalue_source_type) = 0;
 
         virtual void set_exception( exception_ptr) = 0;
 };
@@ -102,10 +104,12 @@
         {}
 #endif
 
- void set_value( typename tasks::detail::future_traits< R >::source_reference_type r)
+ void set_value(
+ typename tasks::detail::future_traits< R >::source_reference_type r)
         { prom_.set_value( r); };
 
- void set_value( typename tasks::detail::future_traits< R >::rvalue_source_type r)
+ void set_value(
+ typename tasks::detail::future_traits< R >::rvalue_source_type r)
         { prom_.set_value( r); };
 
         void set_exception( exception_ptr p)
@@ -151,10 +155,12 @@
                 prom_( prom)
         {}
 
- void set_value( typename tasks::detail::future_traits< R >::source_reference_type r)
+ void set_value(
+ typename tasks::detail::future_traits< R >::source_reference_type r)
         { prom_.set_value( r); };
 
- void set_value( typename tasks::detail::future_traits< R >::rvalue_source_type r)
+ void set_value(
+ typename tasks::detail::future_traits< R >::rvalue_source_type r)
         { prom_.set_value( r); };
 
         void set_exception( exception_ptr p)
@@ -237,8 +243,6 @@
 class task_wrapper : public task_base< R >
 {
 private:
- friend struct as_sub_task;
-
         Fn fn_;
 
         void do_run()
@@ -295,8 +299,6 @@
 class task_wrapper< void, Fn > : public task_base< void >
 {
 private:
- friend struct as_sub_task;
-
         Fn fn_;
 
         void do_run()
@@ -358,12 +360,38 @@
 class task
 {
 private:
- friend struct as_sub_task;
+ template< typename T >
+ friend class detail::callable_object;
 
         BOOST_MOVABLE_BUT_NOT_COPYABLE( task);
 
         intrusive_ptr< detail::task_base< R > > task_;
 
+// TODO: if boost.thread uses boost.move
+// re-work set_promise
+#ifdef BOOST_HAS_RVALUE_REFS
+ void set_promise( promise< R > && prom)
+ {
+ if ( ! task_) throw task_moved();
+ task_->set_promise(
+ new detail::promise_wrapper< R, promise >( prom) );
+ }
+#else
+ void set_promise( boost::detail::thread_move_t< promise< R > > prom)
+ {
+ if ( ! task_) throw task_moved();
+ task_->set_promise(
+ new detail::promise_wrapper< R, promise >( prom) );
+ }
+#endif
+
+ void set_promise( BOOST_RV_REF( spin::promise< R >) prom)
+ {
+ if ( ! task_) throw task_moved();
+ task_->set_promise(
+ new detail::promise_wrapper< R, spin::promise >( prom) );
+ }
+
 public:
         task() :
                 task_()
@@ -418,32 +446,8 @@
                 task_->run();
         }
 
-// TODO: if boost.thread uses boost.move
-// re-work set_promise
-#ifdef BOOST_HAS_RVALUE_REFS
- void set_promise( promise< R > && prom)
- {
- if ( ! task_) throw task_moved();
- task_->set_promise(
- new detail::promise_wrapper< R, promise >( prom) );
- }
-#else
- void set_promise( boost::detail::thread_move_t< promise< R > > prom)
- {
- if ( ! task_) throw task_moved();
- task_->set_promise(
- new detail::promise_wrapper< R, promise >( prom) );
- }
-#endif
-
- void set_promise( BOOST_RV_REF( spin::promise< R >) prom)
- {
- if ( ! task_) throw task_moved();
- task_->set_promise(
- new detail::promise_wrapper< R, spin::promise >( prom) );
- }
-
- typedef typename shared_ptr< detail::task_base< R > >::unspecified_bool_type unspecified_bool_type;
+ typedef typename shared_ptr< detail::task_base< R > >::unspecified_bool_type
+ unspecified_bool_type;
 
         operator unspecified_bool_type() const // throw()
         { return task_; }
@@ -466,9 +470,13 @@
> \
 task< typename result_of< Fn( BOOST_PP_ENUM_PARAMS(n, A)) >::type > \
 make_task( Fn fn, BOOST_ENUM_TASK_ARGS(n)) \
-{ return task< typename result_of< Fn( BOOST_PP_ENUM_PARAMS(n, A)) >::type >( fn, BOOST_PP_ENUM_PARAMS(n, a)); }
+{ \
+ return task< \
+ typename result_of< Fn( BOOST_PP_ENUM_PARAMS(n, A)) >::type >( \
+ fn, BOOST_PP_ENUM_PARAMS(n, a)); \
+}
 
-BOOST_PP_REPEAT_FROM_TO( 1, BOOST_TASKS_MAX_ARITY, BOOST_TASKS_MAKE_TASK_FUNCTION, ~)
+BOOST_PP_REPEAT_FROM_TO(1,BOOST_TASKS_MAX_ARITY,BOOST_TASKS_MAKE_TASK_FUNCTION, ~)
 
 # undef BOOST_TASKS_MAKE_TASK_FUNCTION
 # undef BOOST_ENUM_TASK_ARGS

Modified: sandbox/task/libs/task/src/callable.cpp
==============================================================================
--- sandbox/task/libs/task/src/callable.cpp (original)
+++ sandbox/task/libs/task/src/callable.cpp 2010-01-03 12:42:57 EST (Sun, 03 Jan 2010)
@@ -10,27 +10,27 @@
 namespace tasks {
 
 callable::callable() :
- impl_()
+ base_()
 {}
 
 void
 callable::operator()()
-{ impl_->run(); }
+{ base_->run(); }
 
 bool
 callable::empty() const
-{ return ! impl_; }
+{ return ! base_; }
 
 void
 callable::clear()
-{ impl_.reset(); }
+{ base_.reset(); }
 
 void
 callable::reset( shared_ptr< thread > const& thrd)
-{ impl_->reset( thrd); }
+{ base_->reset( thrd); }
 
 void
 callable::swap( callable & other)
-{ impl_.swap( other.impl_); }
+{ base_.swap( other.base_); }
 
 }}

Modified: sandbox/task/libs/task/src/context.cpp
==============================================================================
--- sandbox/task/libs/task/src/context.cpp (original)
+++ sandbox/task/libs/task/src/context.cpp 2010-01-03 12:42:57 EST (Sun, 03 Jan 2010)
@@ -10,9 +10,10 @@
 
 namespace boost {
 namespace tasks {
+namespace detail {
 
 void
-context::impl::reset_( shared_ptr< thread > const& thrd)
+context_base::reset_( shared_ptr< thread > const& thrd)
 {
         thrd_ = thrd;
         BOOST_ASSERT( thrd_);
@@ -21,7 +22,7 @@
 }
 
 void
-context::impl::interrupt_()
+context_base::interrupt_()
 {
         if ( ! requested_)
         {
@@ -30,7 +31,7 @@
         }
 }
 
-context::impl::impl() :
+context_base::context_base() :
         use_count_( 0),
         requested_( false),
         mtx_(),
@@ -38,44 +39,46 @@
 {}
 
 void
-context::impl::reset( shared_ptr< thread > const& thrd)
+context_base::reset( shared_ptr< thread > const& thrd)
 {
         lock_guard< mutex > lk( mtx_);
         reset_( thrd);
 }
 
 void
-context::impl::interrupt()
+context_base::interrupt()
 {
         lock_guard< mutex > lk( mtx_);
         interrupt_();
 }
 
 bool
-context::impl::interruption_requested()
+context_base::interruption_requested()
 {
         lock_guard< mutex > lk( mtx_);
         return requested_;
 }
 
+}
+
 context::context() :
- impl_( new impl() )
+ base_( new detail::context_base() )
 {}
 
 void
 context::reset( shared_ptr< thread > const& thrd)
-{ impl_->reset( thrd); }
+{ base_->reset( thrd); }
 
 void
 context::interrupt()
-{ impl_->interrupt(); }
+{ base_->interrupt(); }
 
 bool
 context::interruption_requested()
-{ return impl_->interruption_requested(); }
+{ return base_->interruption_requested(); }
 
 void
 context::swap( context & other)
-{ impl_.swap( other.impl_); }
+{ base_.swap( other.base_); }
 
 }}

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 2010-01-03 12:42:57 EST (Sun, 03 Jan 2010)
@@ -242,7 +242,7 @@
         BOOST_CHECK_EQUAL( vec[4].get(), 3);
         BOOST_CHECK_EQUAL( vec[5].get(), 5);
 }
-
+/*
 // check waitfor_any()
 void test_case_17()
 {
@@ -256,7 +256,7 @@
         BOOST_CHECK( ! h1.is_ready() );
         BOOST_CHECK( h2.is_ready() );
 }
-
+*/
 boost::unit_test::test_suite * init_unit_test_suite( int, char* [])
 {
         boost::unit_test::test_suite * test =
@@ -278,7 +278,7 @@
         test->add( BOOST_TEST_CASE( & test_case_14) );
         test->add( BOOST_TEST_CASE( & test_case_15) );
         test->add( BOOST_TEST_CASE( & test_case_16) );
- test->add( BOOST_TEST_CASE( & test_case_17) );
+// test->add( BOOST_TEST_CASE( & test_case_17) );
 
         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 2010-01-03 12:42:57 EST (Sun, 03 Jan 2010)
@@ -257,7 +257,7 @@
         BOOST_CHECK_EQUAL( vec[4].get(), 3);
         BOOST_CHECK_EQUAL( vec[5].get(), 5);
 }
-
+/*
 // check waitfor_any()
 void test_case_18()
 {
@@ -271,7 +271,7 @@
         BOOST_CHECK( h1.is_ready() );
         BOOST_CHECK( h2.is_ready() );
 }
-
+*/
 // check interrupt + wait
 void test_case_19()
 {
@@ -305,7 +305,7 @@
         test->add( BOOST_TEST_CASE( & test_case_15) );
         test->add( BOOST_TEST_CASE( & test_case_16) );
         test->add( BOOST_TEST_CASE( & test_case_17) );
- test->add( BOOST_TEST_CASE( & test_case_18) );
+// test->add( BOOST_TEST_CASE( & test_case_18) );
         test->add( BOOST_TEST_CASE( & test_case_19) );
 
         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