Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r52590 - in sandbox/task: boost/task boost/task/detail libs/task/src
From: oliver.kowalke_at_[hidden]
Date: 2009-04-25 08:13:47


Author: olli
Date: 2009-04-25 08:13:44 EDT (Sat, 25 Apr 2009)
New Revision: 52590
URL: http://svn.boost.org/trac/boost/changeset/52590

Log:
* separation of callables for pool and new thread

Added:
   sandbox/task/boost/task/detail/pool_callable.hpp (contents, props changed)
   sandbox/task/boost/task/detail/thread_callable.hpp (contents, props changed)
   sandbox/task/libs/task/src/pool_callable.cpp (contents, props changed)
   sandbox/task/libs/task/src/thread_callable.cpp (contents, props changed)
Removed:
   sandbox/task/boost/task/detail/callable.hpp
   sandbox/task/libs/task/src/callable.cpp
Text files modified:
   sandbox/task/boost/task/bounded_channel.hpp | 22 +++++++++++-----------
   sandbox/task/boost/task/detail/worker.hpp | 40 ++++++++++++++++++++--------------------
   sandbox/task/boost/task/detail/wsq.hpp | 10 +++++-----
   sandbox/task/boost/task/fifo.hpp | 4 ++--
   sandbox/task/boost/task/handle.hpp | 24 +++++++++++++++++++-----
   sandbox/task/boost/task/launch.hpp | 18 ++++++++++++++++++
   sandbox/task/boost/task/lifo.hpp | 4 ++--
   sandbox/task/boost/task/pool.hpp | 33 ++++++++++++++++++---------------
   sandbox/task/boost/task/priority.hpp | 10 +++++-----
   sandbox/task/boost/task/smart.hpp | 10 +++++-----
   sandbox/task/boost/task/task.hpp | 36 ++++++++----------------------------
   sandbox/task/boost/task/unbounded_channel.hpp | 22 +++++++++++-----------
   sandbox/task/libs/task/src/worker.cpp | 6 +++---
   sandbox/task/libs/task/src/wsq.cpp | 10 +++++-----
   14 files changed, 132 insertions(+), 117 deletions(-)

Modified: sandbox/task/boost/task/bounded_channel.hpp
==============================================================================
--- sandbox/task/boost/task/bounded_channel.hpp (original)
+++ sandbox/task/boost/task/bounded_channel.hpp 2009-04-25 08:13:44 EDT (Sat, 25 Apr 2009)
@@ -18,7 +18,7 @@
 #include <boost/thread/locks.hpp>
 #include <boost/thread/shared_mutex.hpp>
 
-#include <boost/task/detail/callable.hpp>
+#include <boost/task/detail/pool_callable.hpp>
 #include <boost/task/exceptions.hpp>
 #include <boost/task/watermark.hpp>
 
@@ -90,12 +90,12 @@
                 BOOST_ASSERT( deactive_now_() );
         }
 
- const std::vector< detail::callable > drain_()
+ const std::vector< detail::pool_callable > drain_()
         {
                 BOOST_ASSERT( deactive_now_() );
- std::vector< detail::callable > unprocessed;
+ std::vector< detail::pool_callable > unprocessed;
                 unprocessed.reserve( queue_.size() );
- BOOST_FOREACH( detail::callable ca, queue_)
+ BOOST_FOREACH( detail::pool_callable ca, queue_)
                 { unprocessed.push_back( ca); }
                 clear_();
                 BOOST_ASSERT( empty_() );
@@ -164,7 +164,7 @@
         }
 
         bool take_(
- detail::callable & ca,
+ detail::pool_callable & ca,
                 unique_lock< shared_mutex > & lk)
         {
                 if ( deactive_now_() || ( deactive_() && empty_() ) )
@@ -196,7 +196,7 @@
 
         template< typename Duration >
         bool take_(
- detail::callable & ca,
+ detail::pool_callable & ca,
                 Duration const& rel_time,
                 unique_lock< shared_mutex > & lk)
         {
@@ -229,7 +229,7 @@
                 return ! ca.empty();
         }
 
- bool try_take_( detail::callable & ca)
+ bool try_take_( detail::pool_callable & ca)
         {
                 if ( deactive_now_() || empty_() )
                         return false;
@@ -302,7 +302,7 @@
                 deactivate_now_();
         }
 
- const std::vector< detail::callable > drain()
+ const std::vector< detail::pool_callable > drain()
         {
                 unique_lock< shared_mutex > lk( mtx_);
                 return drain_();
@@ -365,7 +365,7 @@
                 put_( itm, rel_time, lk);
         }
 
- bool take( detail::callable & ca)
+ bool take( detail::pool_callable & ca)
         {
                 unique_lock< shared_mutex > lk( mtx_);
                 return take_( ca, lk);
@@ -373,14 +373,14 @@
 
         template< typename Duration >
         bool take(
- detail::callable & ca,
+ detail::pool_callable & ca,
                 Duration const& rel_time)
         {
                 unique_lock< shared_mutex > lk( mtx_);
                 return take_( ca, rel_time, lk);
         }
 
- bool try_take( detail::callable & ca)
+ bool try_take( detail::pool_callable & ca)
         {
                 unique_lock< shared_mutex > lk( mtx_);
                 return try_take_( ca);

Deleted: sandbox/task/boost/task/detail/callable.hpp
==============================================================================
--- sandbox/task/boost/task/detail/callable.hpp 2009-04-25 08:13:44 EDT (Sat, 25 Apr 2009)
+++ (empty file)
@@ -1,87 +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_DETAIL_CALLABLE_H
-#define BOOST_TASK_DETAIL_CALLABLE_H
-
-#include <boost/shared_ptr.hpp>
-#include <boost/thread.hpp>
-#include <boost/utility.hpp>
-
-#include <boost/task/detail/config.hpp>
-#include <boost/task/task.hpp>
-
-#include <boost/config/abi_prefix.hpp>
-
-namespace boost { namespace task
-{
-namespace detail
-{
-class BOOST_TASK_DECL callable
-{
-private:
- struct impl
- {
- virtual ~impl() {}
- virtual void run() = 0;
- virtual void set( shared_ptr< thread > &) = 0;
- virtual void reset() = 0;
- };
-
- template< typename R >
- class impl_wrapper : public impl
- {
- private:
- task< R > t_;
-
- public:
- impl_wrapper( task< R > const& t)
- : t_( t)
- {}
-
- void run()
- { t_(); }
-
- void set( shared_ptr< thread > & thrd)
- { t_.impl_->intr.set( thrd); }
-
- void reset()
- { t_.impl_->intr.reset(); }
- };
-
- shared_ptr< impl > impl_;
-
-public:
- class scoped_guard : public noncopyable
- {
- private:
- callable & ca_;
-
- public:
- scoped_guard( callable &, shared_ptr< thread > &);
-
- ~scoped_guard();
- };
-
- callable();
-
- template< typename R >
- callable( task< R > const& t)
- : impl_( new impl_wrapper< R >( t) )
- {}
-
- void operator()();
-
- bool empty() const;
-
- void clear();
-};
-} } }
-
-#include <boost/config/abi_suffix.hpp>
-
-#endif // BOOST_TASK_DETAIL_CALLABLE_H
-

Added: sandbox/task/boost/task/detail/pool_callable.hpp
==============================================================================
--- (empty file)
+++ sandbox/task/boost/task/detail/pool_callable.hpp 2009-04-25 08:13:44 EDT (Sat, 25 Apr 2009)
@@ -0,0 +1,93 @@
+
+// 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_DETAIL_POOL_CALLABLE_H
+#define BOOST_TASK_DETAIL_POOL_CALLABLE_H
+
+#include <boost/shared_ptr.hpp>
+#include <boost/thread.hpp>
+#include <boost/utility.hpp>
+
+#include <boost/task/detail/config.hpp>
+#include <boost/task/detail/interrupter.hpp>
+#include <boost/task/task.hpp>
+
+#include <boost/config/abi_prefix.hpp>
+
+namespace boost { namespace task
+{
+namespace detail
+{
+class BOOST_TASK_DECL pool_callable
+{
+private:
+ struct impl
+ {
+ virtual ~impl() {}
+ virtual void run() = 0;
+ virtual void set( shared_ptr< thread > &) = 0;
+ virtual void reset() = 0;
+ };
+
+ template< typename R >
+ class impl_wrapper : public impl
+ {
+ private:
+ task< R > t_;
+ detail::interrupter i_;
+
+ public:
+ impl_wrapper(
+ task< R > const& t,
+ detail::interrupter const& i)
+ : t_( t), i_( i)
+ {}
+
+ void run()
+ { t_(); }
+
+ void set( shared_ptr< thread > & thrd)
+ { i_.set( thrd); }
+
+ void reset()
+ { i_.reset(); }
+ };
+
+ shared_ptr< impl > impl_;
+
+public:
+ class scoped_guard : public noncopyable
+ {
+ private:
+ pool_callable & ca_;
+
+ public:
+ scoped_guard( pool_callable &, shared_ptr< thread > &);
+
+ ~scoped_guard();
+ };
+
+ pool_callable();
+
+ template< typename R >
+ pool_callable(
+ task< R > const& t,
+ detail::interrupter const& i)
+ : impl_( new impl_wrapper< R >( t, i) )
+ {}
+
+ void operator()();
+
+ bool empty() const;
+
+ void clear();
+};
+} } }
+
+#include <boost/config/abi_suffix.hpp>
+
+#endif // BOOST_TASK_DETAIL_POOL_CALLABLE_H
+

Added: sandbox/task/boost/task/detail/thread_callable.hpp
==============================================================================
--- (empty file)
+++ sandbox/task/boost/task/detail/thread_callable.hpp 2009-04-25 08:13:44 EDT (Sat, 25 Apr 2009)
@@ -0,0 +1,82 @@
+
+// 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_DETAIL_THREAD_CALLABLE_H
+#define BOOST_TASK_DETAIL_THREAD_CALLABLE_H
+
+#include <boost/shared_ptr.hpp>
+#include <boost/thread.hpp>
+#include <boost/utility.hpp>
+
+#include <boost/task/detail/config.hpp>
+#include <boost/task/detail/interrupter.hpp>
+#include <boost/task/semaphore.hpp>
+#include <boost/task/task.hpp>
+
+#include <boost/config/abi_prefix.hpp>
+
+namespace boost { namespace task
+{
+namespace detail
+{
+class BOOST_TASK_DECL thread_callable
+{
+private:
+ struct impl
+ {
+ virtual ~impl() {}
+ virtual void run() = 0;
+ virtual void set( shared_ptr< thread > &) = 0;
+ };
+
+ template< typename R >
+ class impl_wrapper : public impl
+ {
+ private:
+ task< R > t_;
+ detail::interrupter i_;
+ semaphore sem_;
+
+ public:
+ impl_wrapper(
+ task< R > const& t,
+ detail::interrupter const& i)
+ : t_( t), i_( i), sem_( 0)
+ {}
+
+ void run()
+ {
+ sem_.wait();
+ t_();
+ }
+
+ void set( shared_ptr< thread > & thrd)
+ {
+ i_.set( thrd);
+ sem_.post();
+ }
+ };
+
+ shared_ptr< impl > impl_;
+
+public:
+ template< typename R >
+ thread_callable(
+ task< R > const& t,
+ detail::interrupter const& i)
+ : impl_( new impl_wrapper< R >( t, i) )
+ {}
+
+ void operator()();
+
+ void set( shared_ptr< thread > &);
+};
+} } }
+
+#include <boost/config/abi_suffix.hpp>
+
+#endif // BOOST_TASK_DETAIL_THREAD_CALLABLE_H
+

Modified: sandbox/task/boost/task/detail/worker.hpp
==============================================================================
--- sandbox/task/boost/task/detail/worker.hpp (original)
+++ sandbox/task/boost/task/detail/worker.hpp 2009-04-25 08:13:44 EDT (Sat, 25 Apr 2009)
@@ -17,7 +17,7 @@
 #include <boost/thread.hpp>
 #include <boost/utility.hpp>
 
-#include <boost/task/detail/callable.hpp>
+#include <boost/task/detail/pool_callable.hpp>
 #include <boost/task/detail/config.hpp>
 #include <boost/task/detail/guard.hpp>
 #include <boost/task/detail/interrupter.hpp>
@@ -47,11 +47,11 @@
 
                 virtual void interrupt() const = 0;
 
- virtual void put( callable const&) = 0;
+ virtual void put( pool_callable const&) = 0;
 
- virtual bool try_take( callable &) = 0;
+ virtual bool try_take( pool_callable &) = 0;
 
- virtual bool try_steal( callable &) = 0;
+ virtual bool try_steal( pool_callable &) = 0;
 
                 virtual void signal_shutdown() = 0;
 
@@ -97,19 +97,19 @@
                 std::size_t scns_;
                 random_idx rnd_idx_;
 
- void execute_( callable & ca)
+ void execute_( pool_callable & ca)
                 {
                         BOOST_ASSERT( ! ca.empty() );
                         guard grd( get_pool().active_worker_);
                         {
- callable::scoped_guard lk( ca, thrd_);
+ pool_callable::scoped_guard lk( ca, thrd_);
                                 ca();
                         }
                         ca.clear();
                         BOOST_ASSERT( ca.empty() );
                 }
         
- void next_callable_( callable & ca)
+ void next_pool_callable_( pool_callable & ca)
                 {
                         if ( ! try_take( ca) )
                         {
@@ -144,7 +144,7 @@
                         }
                 }
         
- void next_local_callable_( callable & ca)
+ void next_local_pool_callable_( pool_callable & ca)
                 {
                         if ( ! try_take( ca) )
                         {
@@ -216,24 +216,24 @@
                 void signal_shutdown_now()
                 { shtdwn_now_sem_.post(); }
 
- void put( callable const& ca)
+ void put( pool_callable const& ca)
                 {
                         BOOST_ASSERT( ! ca.empty() );
                         wsq_.put( ca);
                 }
 
- bool try_take( callable & ca)
+ bool try_take( pool_callable & ca)
                 {
- callable tmp;
+ pool_callable tmp;
                         bool result( wsq_.try_take( tmp) );
                         if ( result)
                                 ca = tmp;
                         return result;
                 }
                 
- bool try_steal( callable & ca)
+ bool try_steal( pool_callable & ca)
                 {
- callable tmp;
+ pool_callable tmp;
                         bool result( wsq_.try_steal( tmp) );
                         if ( result)
                                 ca = tmp;
@@ -247,10 +247,10 @@
                 {
                         BOOST_ASSERT( get_id() == this_thread::get_id() );
 
- callable ca;
+ pool_callable ca;
                         while ( ! shutdown_() )
                         {
- next_callable_( ca);
+ next_pool_callable_( ca);
                                 if( ! ca.empty() )
                                 {
                                         execute_( ca);
@@ -261,10 +261,10 @@
 
                 void reschedule_until( function< bool() > const& pred)
                 {
- callable ca;
+ pool_callable ca;
                         while ( ! pred() )
                         {
- next_local_callable_( ca);
+ next_local_pool_callable_( ca);
                                 if( ! ca.empty() )
                                 {
                                         execute_( ca);
@@ -301,9 +301,9 @@
         void signal_shutdown();
         void signal_shutdown_now();
 
- void put( callable const&);
- bool try_take( callable &);
- bool try_steal( callable &);
+ void put( pool_callable const&);
+ bool try_take( pool_callable &);
+ bool try_steal( pool_callable &);
 
         void reschedule_until( function< bool() > const&);
 

Modified: sandbox/task/boost/task/detail/wsq.hpp
==============================================================================
--- sandbox/task/boost/task/detail/wsq.hpp (original)
+++ sandbox/task/boost/task/detail/wsq.hpp 2009-04-25 08:13:44 EDT (Sat, 25 Apr 2009)
@@ -13,7 +13,7 @@
 #include <boost/utility.hpp>
 
 #include <boost/task/detail/config.hpp>
-#include <boost/task/detail/callable.hpp>
+#include <boost/task/detail/pool_callable.hpp>
 
 #include <boost/config/abi_prefix.hpp>
 
@@ -25,7 +25,7 @@
 {
 private:
         const int initial_size_;
- shared_array< callable > array_;
+ shared_array< pool_callable > array_;
         int capacity_;
         int mask_;
         volatile uint32_t head_idx_;
@@ -39,11 +39,11 @@
 
         std::size_t size() const;
 
- void put( callable const&);
+ void put( pool_callable const&);
 
- bool try_take( callable &);
+ bool try_take( pool_callable &);
 
- bool try_steal( callable &);
+ bool try_steal( pool_callable &);
 };
 }}}
 

Modified: sandbox/task/boost/task/fifo.hpp
==============================================================================
--- sandbox/task/boost/task/fifo.hpp (original)
+++ sandbox/task/boost/task/fifo.hpp 2009-04-25 08:13:44 EDT (Sat, 25 Apr 2009)
@@ -10,7 +10,7 @@
 #include <cstddef>
 #include <list>
 
-#include <boost/task/detail/callable.hpp>
+#include <boost/task/detail/pool_callable.hpp>
 #include <boost/task/detail/info.hpp>
 
 namespace boost { namespace task
@@ -22,7 +22,7 @@
         class impl
         {
         public:
- typedef detail::callable item;
+ typedef detail::pool_callable item;
                 typedef std::list< item >::iterator iterator;
                 typedef std::list< item >::const_iterator const_iterator;
         

Modified: sandbox/task/boost/task/handle.hpp
==============================================================================
--- sandbox/task/boost/task/handle.hpp (original)
+++ sandbox/task/boost/task/handle.hpp 2009-04-25 08:13:44 EDT (Sat, 25 Apr 2009)
@@ -17,15 +17,27 @@
 
 namespace boost { namespace task
 {
-template< typename T >
+
+template< typename R >
+class handle;
+
+template< typename R >
 class task;
 
+template< typename Channel >
+class pool;
+
+template< typename R >
+handle< R > launch_in_thread( task< R >);
+
 template< typename R >
 class handle
 {
 private:
+ template< typename Channel >
+ friend class pool;
         template< typename T >
- friend class task;
+ friend handle< T > launch_in_thread( task< T >);
         template< typename Iterator >
         friend void waitfor_all( Iterator begin, Iterator end);
         template< typename T1, typename T2 >
@@ -52,9 +64,9 @@
         id id_;
 
         handle(
+ id const& id__,
                 shared_future< R > const& fut,
- detail::interrupter const& intr,
- id const& id__)
+ detail::interrupter const& intr)
         :
         fut_( fut),
         intr_( intr),
@@ -125,7 +137,9 @@
 {
 private:
         template< typename Channel >
- friend class task;
+ friend class pool;
+ template< typename T >
+ friend handle< T > launch_in_thread( task< T >);
         template< typename Iterator >
         friend void waitfor_all( Iterator begin, Iterator end);
         template< typename T1, typename T2 >

Modified: sandbox/task/boost/task/launch.hpp
==============================================================================
--- sandbox/task/boost/task/launch.hpp (original)
+++ sandbox/task/boost/task/launch.hpp 2009-04-25 08:13:44 EDT (Sat, 25 Apr 2009)
@@ -7,7 +7,12 @@
 #ifndef BOOST_TASK_LAUNCH_H
 #define BOOST_TASK_LAUNCH_H
 
+#include <boost/shared_ptr.hpp>
+#include <boost/thread.hpp>
+
 #include <boost/task/default_pool.hpp>
+#include <boost/task/detail/interrupter.hpp>
+#include <boost/task/detail/thread_callable.hpp>
 #include <boost/task/handle.hpp>
 #include <boost/task/pool.hpp>
 #include <boost/task/task.hpp>
@@ -46,6 +51,19 @@
         task< R > t,
         Attr const& attr)
 { return pool.submit( t, attr); }
+
+
+template< typename R >
+handle< R > launch_in_thread( task< R > t)
+{
+ detail::interrupter intr;
+ detail::thread_callable ca( t, intr);
+
+ shared_ptr< thread > thrd( new thread( ca) );
+ ca.set( thrd);
+
+ return handle< R >( t.get_id(), t.get_future(), intr);
+}
 } }
 
 #endif // BOOST_TASK_LAUNCH_H

Modified: sandbox/task/boost/task/lifo.hpp
==============================================================================
--- sandbox/task/boost/task/lifo.hpp (original)
+++ sandbox/task/boost/task/lifo.hpp 2009-04-25 08:13:44 EDT (Sat, 25 Apr 2009)
@@ -10,7 +10,7 @@
 #include <cstddef>
 #include <list>
 
-#include <boost/task/detail/callable.hpp>
+#include <boost/task/detail/pool_callable.hpp>
 #include <boost/task/detail/info.hpp>
 
 namespace boost { namespace task
@@ -22,7 +22,7 @@
         class impl
         {
         public:
- typedef detail::callable item;
+ typedef detail::pool_callable item;
                 typedef std::list< item >::iterator iterator;
                 typedef std::list< item >::const_iterator const_iterator;
         

Modified: sandbox/task/boost/task/pool.hpp
==============================================================================
--- sandbox/task/boost/task/pool.hpp (original)
+++ sandbox/task/boost/task/pool.hpp 2009-04-25 08:13:44 EDT (Sat, 25 Apr 2009)
@@ -21,7 +21,8 @@
 
 #include <boost/task/detail/atomic.hpp>
 #include <boost/task/detail/bind_processor.hpp>
-#include <boost/task/detail/callable.hpp>
+#include <boost/task/detail/interrupter.hpp>
+#include <boost/task/detail/pool_callable.hpp>
 #include <boost/task/detail/worker.hpp>
 #include <boost/task/detail/worker_group.hpp>
 #include <boost/task/exceptions.hpp>
@@ -34,7 +35,7 @@
 
 namespace boost { namespace task
 {
-typedef detail::callable callable;
+typedef detail::pool_callable pool_callable;
 
 template< typename Channel >
 class pool : private noncopyable
@@ -243,10 +244,10 @@
                 lk.unlock();
         }
 
- const std::vector< callable > shutdown_now()
+ const std::vector< pool_callable > shutdown_now()
         {
                 if ( closed_() || close_() > 1)
- return std::vector< callable >();
+ return std::vector< pool_callable >();
 
                 channel_.deactivate_now();
                 shared_lock< shared_mutex > lk( mtx_wg_);
@@ -254,7 +255,7 @@
                 wg_.interrupt_all();
                 wg_.join_all();
                 lk.unlock();
- std::vector< callable > drain( channel_.drain() );
+ std::vector< pool_callable > drain( channel_.drain() );
 
                 return drain;
         }
@@ -292,7 +293,8 @@
         template< typename R >
         handle< R > submit( task< R > t)
         {
- shared_future< R > fut( t.impl_->fut);
+ detail::interrupter intr;
+ shared_future< R > fut( t.get_future() );
                 detail::worker * w( detail::worker::tss_get() );
                 if ( w)
                 {
@@ -305,16 +307,16 @@
                                         ( void ( detail::worker::*)( function< bool() > const&) ) & detail::worker::reschedule_until,
                                         w,
                                         wcb) );
- w->put( detail::callable( t) );
- return t.get_handle();
+ w->put( detail::pool_callable( t, intr) );
+ return handle< R >( t.get_id(), fut, intr);
                 }
                 else
                 {
                         if ( closed_() )
                                 throw task_rejected("pool is closed");
 
- channel_.put( detail::callable( t) );
- return t.get_handle();
+ channel_.put( detail::pool_callable( t, intr) );
+ return handle< R >( t.get_id(), fut, intr);
                 }
         }
 
@@ -324,7 +326,8 @@
>
         handle< R > submit( task< R > t, Attr const& attr)
         {
- shared_future< R > fut( t.impl_->fut);
+ detail::interrupter intr;
+ shared_future< R > fut( t.get_future() );
                 detail::worker * w( detail::worker::tss_get() );
                 if ( w)
                 {
@@ -337,16 +340,16 @@
                                         ( void ( detail::worker::*)( function< bool() > const&) ) & detail::worker::reschedule_until,
                                         w,
                                         wcb) );
- w->put( detail::callable( t) );
- return t.get_handle();
+ w->put( detail::pool_callable( t, intr) );
+ return handle< R >( t.get_id(), fut, intr);
                 }
                 else
                 {
                         if ( closed_() )
                                 throw task_rejected("pool is closed");
 
- channel_.put( channel_item( detail::callable( t), attr) );
- return t.get_handle();
+ channel_.put( channel_item( detail::pool_callable( t, intr), attr) );
+ return handle< R >( t.get_id(), fut, intr);
                 }
         }
 };

Modified: sandbox/task/boost/task/priority.hpp
==============================================================================
--- sandbox/task/boost/task/priority.hpp (original)
+++ sandbox/task/boost/task/priority.hpp 2009-04-25 08:13:44 EDT (Sat, 25 Apr 2009)
@@ -15,7 +15,7 @@
 #include <boost/multi_index/mem_fun.hpp>
 #include <boost/multi_index/ordered_index.hpp>
 
-#include <boost/task/detail/callable.hpp>
+#include <boost/task/detail/pool_callable.hpp>
 #include <boost/task/detail/info.hpp>
 
 namespace boost { namespace task
@@ -39,17 +39,17 @@
                 class item
                 {
                 private:
- detail::callable ca_;
+ detail::pool_callable ca_;
                         attribute attr_;
         
                 public:
                         item(
- detail::callable const& ca,
+ detail::pool_callable const& ca,
                                 attribute const& attr)
                         : ca_( ca), attr_( attr)
                         { BOOST_ASSERT( ! ca_.empty() ); }
         
- const detail::callable ca() const
+ const detail::pool_callable ca() const
                         { return ca_; }
         
                         const attribute attr() const
@@ -88,7 +88,7 @@
                 void push( item const& itm)
                 { idx_.insert( itm); }
         
- const detail::callable pop()
+ const detail::pool_callable pop()
                 {
                         iterator i( lst_.begin() );
                         BOOST_ASSERT( i != lst_.end() );

Modified: sandbox/task/boost/task/smart.hpp
==============================================================================
--- sandbox/task/boost/task/smart.hpp (original)
+++ sandbox/task/boost/task/smart.hpp 2009-04-25 08:13:44 EDT (Sat, 25 Apr 2009)
@@ -14,7 +14,7 @@
 #include <boost/multi_index/mem_fun.hpp>
 #include <boost/multi_index/ordered_index.hpp>
 
-#include <boost/task/detail/callable.hpp>
+#include <boost/task/detail/pool_callable.hpp>
 #include <boost/task/detail/info.hpp>
 
 namespace boost { namespace task
@@ -42,7 +42,7 @@
                 class item
                 {
                 private:
- detail::callable ca_;
+ detail::pool_callable ca_;
                         attribute attr_;
         
                 public:
@@ -51,12 +51,12 @@
                         {}
 
                         item(
- detail::callable const& ca,
+ detail::pool_callable const& ca,
                                 attribute const& attr)
                         : ca_( ca), attr_( attr)
                         { BOOST_ASSERT( ! ca_.empty() ); }
         
- const detail::callable ca() const
+ const detail::pool_callable ca() const
                         { return ca_; }
         
                         const attribute attr() const
@@ -101,7 +101,7 @@
                 void push( item const& itm)
                 { enq_op_( idx_, itm); }
         
- const detail::callable pop()
+ const detail::pool_callable pop()
                 {
                         item itm;
                         deq_op_( idx_, itm);

Modified: sandbox/task/boost/task/task.hpp
==============================================================================
--- sandbox/task/boost/task/task.hpp (original)
+++ sandbox/task/boost/task/task.hpp 2009-04-25 08:13:44 EDT (Sat, 25 Apr 2009)
@@ -20,7 +20,6 @@
 #include <boost/thread/thread_time.hpp>
 #include <boost/utility/result_of.hpp>
 
-#include <boost/task/detail/interrupter.hpp>
 #include <boost/task/future.hpp>
 #include <boost/task/exceptions.hpp>
 #include <boost/task/handle.hpp>
@@ -28,37 +27,24 @@
 
 namespace boost { namespace task
 {
-namespace detail
-{
-class callable;
-}
-
-template< typename Channel >
-class pool;
 
 template< typename R >
 class task
 {
 private:
- template< typename Channel >
- friend class pool;
- friend class detail::callable;
-
         struct impl
         {
                 promise< R > prom;
                 shared_future< R > fut;
- detail::interrupter intr;
 
                 impl()
                 :
                 prom(),
- fut( prom.get_future() ),
- intr()
+ fut( prom.get_future() )
                 {}
 
                 virtual ~impl()
- { intr.reset(); }
+ {}
 
                 virtual void operator()() = 0;
         };
@@ -126,8 +112,8 @@
         const id get_id() const
         { return id( lexical_cast< std::string >( impl_.get() ) ); }
 
- const handle< R > get_handle()
- { return handle< R >( impl_->fut, impl_->intr, get_id() ); }
+ shared_future< R > & get_future()
+ { return impl_->fut; }
 
         void swap( task< R > & other) // throw()
         { impl_.swap( other.impl_); }
@@ -144,25 +130,19 @@
 class task< void >
 {
 private:
- template< typename Channel >
- friend class pool;
- friend class detail::callable;
-
         struct impl
         {
                 promise< void > prom;
                 shared_future< void > fut;
- detail::interrupter intr;
 
                 impl()
                 :
                 prom(),
- fut( prom.get_future() ),
- intr()
+ fut( prom.get_future() )
                 {}
 
                 virtual ~impl()
- { intr.reset(); }
+ {}
 
                 virtual void operator()() = 0;
         };
@@ -233,8 +213,8 @@
         const id get_id() const
         { return id( lexical_cast< std::string >( impl_.get() ) ); }
 
- const handle< void > get_handle()
- { return handle< void >( impl_->fut, impl_->intr, get_id() ); }
+ shared_future< void > & get_future()
+ { return impl_->fut; }
 
         void swap( task< void > & other) // throw()
         { impl_.swap( other.impl_); }

Modified: sandbox/task/boost/task/unbounded_channel.hpp
==============================================================================
--- sandbox/task/boost/task/unbounded_channel.hpp (original)
+++ sandbox/task/boost/task/unbounded_channel.hpp 2009-04-25 08:13:44 EDT (Sat, 25 Apr 2009)
@@ -18,7 +18,7 @@
 #include <boost/thread/locks.hpp>
 #include <boost/thread/shared_mutex.hpp>
 
-#include <boost/task/detail/callable.hpp>
+#include <boost/task/detail/pool_callable.hpp>
 #include <boost/task/exceptions.hpp>
 
 namespace boost { namespace task
@@ -86,12 +86,12 @@
                 BOOST_ASSERT( deactive_now_() );
         }
 
- const std::vector< detail::callable > drain_()
+ const std::vector< detail::pool_callable > drain_()
         {
                 BOOST_ASSERT( deactive_now_() );
- std::vector< detail::callable > unprocessed;
+ std::vector< detail::pool_callable > unprocessed;
                 unprocessed.reserve( queue_.size() );
- BOOST_FOREACH( detail::callable ca, queue_)
+ BOOST_FOREACH( detail::pool_callable ca, queue_)
                 { unprocessed.push_back( ca); }
                 clear_();
                 BOOST_ASSERT( empty_() );
@@ -115,7 +115,7 @@
         }
 
         bool take_(
- detail::callable & ca,
+ detail::pool_callable & ca,
                 unique_lock< shared_mutex > & lk)
         {
                 if ( deactive_now_() || ( deactive_() && empty_() ) )
@@ -138,7 +138,7 @@
 
         template< typename Duration >
         bool take_(
- detail::callable & ca,
+ detail::pool_callable & ca,
                 Duration const& rel_time,
                 unique_lock< shared_mutex > & lk)
         {
@@ -162,7 +162,7 @@
                 return ! ca.empty();
         }
 
- bool try_take_( detail::callable & ca)
+ bool try_take_( detail::pool_callable & ca)
         {
                 if ( deactive_now_() || empty_() )
                         return false;
@@ -215,7 +215,7 @@
                 deactivate_now_();
         }
 
- const std::vector< detail::callable > drain()
+ const std::vector< detail::pool_callable > drain()
         {
                 unique_lock< shared_mutex > lk( mtx_);
                 return drain_();
@@ -251,7 +251,7 @@
                 put_( itm, lk);
         }
 
- bool take( detail::callable & ca)
+ bool take( detail::pool_callable & ca)
         {
                 unique_lock< shared_mutex > lk( mtx_);
                 return take_( ca, lk);
@@ -259,14 +259,14 @@
 
         template< typename Duration >
         bool take(
- detail::callable & ca,
+ detail::pool_callable & ca,
                 Duration const& rel_time)
         {
                 unique_lock< shared_mutex > lk( mtx_);
                 return take_( ca, rel_time, lk);
         }
 
- bool try_take( detail::callable & ca)
+ bool try_take( detail::pool_callable & ca)
         {
                 unique_lock< shared_mutex > lk( mtx_);
                 return try_take_( ca);

Deleted: sandbox/task/libs/task/src/callable.cpp
==============================================================================
--- sandbox/task/libs/task/src/callable.cpp 2009-04-25 08:13:44 EDT (Sat, 25 Apr 2009)
+++ (empty file)
@@ -1,36 +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 "boost/task/detail/callable.hpp"
-
-namespace boost { namespace task
-{
-namespace detail
-{
-callable::callable()
-: impl_()
-{}
-
-void
-callable::operator()()
-{ impl_->run(); }
-
-bool
-callable::empty() const
-{ return ! impl_; }
-
-void
-callable::clear()
-{ impl_.reset(); }
-
-callable::scoped_guard::scoped_guard( callable & ca, shared_ptr< thread > & thrd)
-: ca_( ca)
-{ ca_.impl_->set( thrd); }
-
-callable::scoped_guard::~scoped_guard()
-{ ca_.impl_->reset(); }
-} } }
-

Added: sandbox/task/libs/task/src/pool_callable.cpp
==============================================================================
--- (empty file)
+++ sandbox/task/libs/task/src/pool_callable.cpp 2009-04-25 08:13:44 EDT (Sat, 25 Apr 2009)
@@ -0,0 +1,36 @@
+
+// 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 "boost/task/detail/pool_callable.hpp"
+
+namespace boost { namespace task
+{
+namespace detail
+{
+pool_callable::pool_callable()
+: impl_()
+{}
+
+void
+pool_callable::operator()()
+{ impl_->run(); }
+
+bool
+pool_callable::empty() const
+{ return ! impl_; }
+
+void
+pool_callable::clear()
+{ impl_.reset(); }
+
+pool_callable::scoped_guard::scoped_guard( pool_callable & ca, shared_ptr< thread > & thrd)
+: ca_( ca)
+{ ca_.impl_->set( thrd); }
+
+pool_callable::scoped_guard::~scoped_guard()
+{ ca_.impl_->reset(); }
+} } }
+

Added: sandbox/task/libs/task/src/thread_callable.cpp
==============================================================================
--- (empty file)
+++ sandbox/task/libs/task/src/thread_callable.cpp 2009-04-25 08:13:44 EDT (Sat, 25 Apr 2009)
@@ -0,0 +1,24 @@
+
+// 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 "boost/task/detail/thread_callable.hpp"
+
+namespace boost { namespace task
+{
+namespace detail
+{
+void
+thread_callable::operator()()
+{
+ impl_->run();
+ impl_.reset();
+}
+
+void
+thread_callable::set( shared_ptr< thread > & thrd)
+{ impl_->set( thrd); }
+} } }
+

Modified: sandbox/task/libs/task/src/worker.cpp
==============================================================================
--- sandbox/task/libs/task/src/worker.cpp (original)
+++ sandbox/task/libs/task/src/worker.cpp 2009-04-25 08:13:44 EDT (Sat, 25 Apr 2009)
@@ -33,15 +33,15 @@
 { impl_->signal_shutdown_now(); }
 
 void
-worker::put( callable const& ca)
+worker::put( pool_callable const& ca)
 { impl_->put( ca); }
 
 bool
-worker::try_take( callable & ca)
+worker::try_take( pool_callable & ca)
 { return impl_->try_take( ca); }
 
 bool
-worker::try_steal( callable & ca)
+worker::try_steal( pool_callable & ca)
 { return impl_->try_steal( ca); }
 
 void

Modified: sandbox/task/libs/task/src/wsq.cpp
==============================================================================
--- sandbox/task/libs/task/src/wsq.cpp (original)
+++ sandbox/task/libs/task/src/wsq.cpp 2009-04-25 08:13:44 EDT (Sat, 25 Apr 2009)
@@ -17,7 +17,7 @@
 wsq::wsq()
 :
 initial_size_( 32),
-array_( new callable[ initial_size_]),
+array_( new pool_callable[ initial_size_]),
 capacity_( initial_size_),
 mask_( initial_size_ - 1),
 head_idx_( 0),
@@ -34,7 +34,7 @@
 { return tail_idx_ - head_idx_; }
 
 void
-wsq::put( callable const& ca)
+wsq::put( pool_callable const& ca)
 {
         uint32_t tail( tail_idx_);
         if ( tail <= head_idx_ + mask_)
@@ -51,7 +51,7 @@
                 if ( count >= mask_)
                 {
                         capacity_ <<= 1;
- shared_array< callable > array( new callable[capacity_]);
+ shared_array< pool_callable > array( new pool_callable[capacity_]);
                         for ( int i( 0); i != count; ++i)
                                 array[i] = array_[(i + head) & mask_];
                         array_.swap( array);
@@ -65,7 +65,7 @@
 }
 
 bool
-wsq::try_take( callable & ca)
+wsq::try_take( pool_callable & ca)
 {
         uint32_t tail( tail_idx_);
         if ( tail == 0)
@@ -94,7 +94,7 @@
 }
 
 bool
-wsq::try_steal( callable & ca)
+wsq::try_steal( pool_callable & ca)
 {
         recursive_mutex::scoped_try_lock lk( mtx_);
         if ( lk.owns_lock() )


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