$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r54715 - in sandbox/task: boost boost/task boost/task/detail libs/task/src
From: oliver.kowalke_at_[hidden]
Date: 2009-07-06 13:11:40
Author: olli
Date: 2009-07-06 13:11:38 EDT (Mon, 06 Jul 2009)
New Revision: 54715
URL: http://svn.boost.org/trac/boost/changeset/54715
Log:
* callable in manin namespace
* new class context
* user-defined execution-policies supported
Added:
   sandbox/task/boost/task/callable.hpp   (contents, props changed)
   sandbox/task/boost/task/context.hpp   (contents, props changed)
Removed:
   sandbox/task/boost/task/detail/callable.hpp
   sandbox/task/boost/task/detail/move.hpp
Text files modified: 
   sandbox/task/boost/task.hpp                    |     2                                         
   sandbox/task/boost/task/as_sub_task.hpp        |    17 ++++--                                  
   sandbox/task/boost/task/bounded_channel.hpp    |    99 ++++++++++++++++++++++----------------- 
   sandbox/task/boost/task/detail/interrupter.hpp |    28 +++--------                             
   sandbox/task/boost/task/detail/worker.hpp      |     4                                         
   sandbox/task/boost/task/detail/wsq.hpp         |    14 ++--                                    
   sandbox/task/boost/task/fifo.hpp               |     4                                         
   sandbox/task/boost/task/handle.hpp             |    23 ++++-----                               
   sandbox/task/boost/task/new_thread.hpp         |    42 ++++++++++------                        
   sandbox/task/boost/task/own_thread.hpp         |    15 ++++--                                  
   sandbox/task/boost/task/priority.hpp           |    12 ++--                                    
   sandbox/task/boost/task/smart.hpp              |    12 ++--                                    
   sandbox/task/boost/task/static_pool.hpp        |    44 ++++++++--------                        
   sandbox/task/boost/task/task.hpp               |    21 ++------                                
   sandbox/task/boost/task/unbounded_channel.hpp  |    81 +++++++++++++++-----------------        
   sandbox/task/libs/task/src/callable.cpp        |    17 ++++--                                  
   sandbox/task/libs/task/src/interrupter.cpp     |    35 ++++++-------                           
   17 files changed, 236 insertions(+), 234 deletions(-)
Modified: sandbox/task/boost/task.hpp
==============================================================================
--- sandbox/task/boost/task.hpp	(original)
+++ sandbox/task/boost/task.hpp	2009-07-06 13:11:38 EDT (Mon, 06 Jul 2009)
@@ -10,6 +10,8 @@
 #include <boost/task/as_sub_task.hpp>
 #include <boost/task/async.hpp>
 #include <boost/task/bounded_channel.hpp>
+#include <boost/task/callable.hpp>
+#include <boost/task/context.hpp>
 #include <boost/task/exceptions.hpp>
 #include <boost/task/fifo.hpp>
 #include <boost/task/future.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-07-06 13:11:38 EDT (Mon, 06 Jul 2009)
@@ -12,7 +12,7 @@
 #include <boost/function.hpp>
 #include <boost/thread/detail/move.hpp>
 
-#include <boost/task/detail/interrupter.hpp>
+#include <boost/task/context.hpp>
 #include <boost/task/detail/worker.hpp>
 #include <boost/task/future.hpp>
 #include <boost/task/handle.hpp>
@@ -23,6 +23,7 @@
 
 namespace boost { namespace task
 {
+
 struct as_sub_task
 {
         template< typename R >
@@ -31,25 +32,27 @@
                 detail::worker * w( detail::worker::tss_get() );
                 if ( w)
                 {
-			shared_future< R > fut( t.get_future() );
-			detail::interrupter intr;
+			shared_future< R > f( t.get_future() );
                         function< bool() > wcb(
                                 bind(
                                         & shared_future< R >::is_ready,
-					fut) );
+					f) );
                         t.set_wait_callback(
                                 bind(
                                         ( void ( detail::worker::*)( function< bool() > const&) ) & detail::worker::reschedule_until,
                                         w,
                                         wcb) );
-			w->put( detail::callable( boost::move( t), intr) );
-			return handle< R >( fut, intr);
+			context ctx;
+			handle< R > h( ctx.get_handle( f) );
+			w->put( ctx.get_callable( boost::move( t) ) );
+			return h;
                 }
                 else
                         return new_thread()( boost::move( t) );
         }
 };
-} }
+
+}}
 
 #include <boost/config/abi_suffix.hpp>
 
Modified: sandbox/task/boost/task/bounded_channel.hpp
==============================================================================
--- sandbox/task/boost/task/bounded_channel.hpp	(original)
+++ sandbox/task/boost/task/bounded_channel.hpp	2009-07-06 13:11:38 EDT (Mon, 06 Jul 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/callable.hpp>
 #include <boost/task/exceptions.hpp>
 #include <boost/task/watermark.hpp>
 
@@ -92,12 +92,12 @@
                 BOOST_ASSERT( deactive_now_() );
         }
 
-	const std::vector< detail::callable > drain_()
+	const std::vector< callable > drain_()
         {
                 BOOST_ASSERT( deactive_now_() );
-		std::vector< detail::callable > unprocessed;
+		std::vector< callable > unprocessed;
                 unprocessed.reserve( queue_.size() );
-		BOOST_FOREACH( detail::callable ca, queue_)
+		BOOST_FOREACH( callable ca, queue_)
                 { unprocessed.push_back( ca); }
                 clear_();
                 BOOST_ASSERT( empty_() );
@@ -135,11 +135,14 @@
                 item const& itm,
                 unique_lock< shared_mutex > & lk)
         {
-		not_full_cond_.wait(
-			lk,
-			bind(
-				& bounded_channel::producers_activate_,
-				this) );
+		if ( full_() )
+		{
+			not_full_cond_.wait(
+				lk,
+				bind(
+					& bounded_channel::producers_activate_,
+					this) );
+		}
                 if ( ! active_() )
                         throw task_rejected("channel is not active");
                 queue_.push( itm);
@@ -152,13 +155,16 @@
                 Duration const& rel_time,
                 unique_lock< shared_mutex > & lk)
         {
-		if ( ! not_full_cond_.timed_wait(
-			lk,
-			rel_time,
-			bind(
-				& bounded_channel::producers_activate_,
-				this) ) )
-			throw task_rejected("timed out");
+		if ( full_() )
+		{
+			if ( ! not_full_cond_.timed_wait(
+				lk,
+				rel_time,
+				bind(
+					& bounded_channel::producers_activate_,
+					this) ) )
+				throw task_rejected("timed out");
+		}
                 if ( ! active_() )
                         throw task_rejected("channel is not active");
                 queue_.push( itm);
@@ -166,21 +172,24 @@
         }
 
         bool take_(
-		detail::callable & ca,
+		callable & ca,
                 unique_lock< shared_mutex > & lk)
         {
                 if ( deactive_now_() || ( deactive_() && empty_() ) )
                         return false;
-		try
+		if ( empty_() )
                 {
-			not_empty_cond_.wait(
-				lk,
-				bind(
-					& bounded_channel::consumers_activate_,
-					this) );
+			try
+			{
+				not_empty_cond_.wait(
+					lk,
+					bind(
+						& bounded_channel::consumers_activate_,
+						this) );
+			}
+			catch ( thread_interrupted const&)
+			{ return false; }
                 }
-		catch ( thread_interrupted const&)
-		{ return false; }
                 if ( deactive_now_() || ( deactive_() && empty_() ) )
                         return false;
                 ca = queue_.pop();
@@ -198,24 +207,27 @@
 
         template< typename Duration >
         bool take_(
-		detail::callable & ca,
+		callable & ca,
                 Duration const& rel_time,
                 unique_lock< shared_mutex > & lk)
         {
                 if ( deactive_now_() || ( deactive_() && empty_() ) )
                         return false;
-		try
+		if ( empty_() )
                 {
-			if ( ! not_empty_cond_.timed_wait(
-				lk,
-				rel_time,
-				bind(
-					& bounded_channel::consumers_activate_,
-					this) ) )
-				return false;
+			try
+			{
+				if ( ! not_empty_cond_.timed_wait(
+					lk,
+					rel_time,
+					bind(
+						& bounded_channel::consumers_activate_,
+						this) ) )
+					return false;
+			}
+			catch ( thread_interrupted const&)
+			{ return false; }
                 }
-		catch ( thread_interrupted const&)
-		{ return false; }
                 if ( deactive_now_() || ( deactive_() && empty_() ) )
                         return false;
                 ca = queue_.pop();
@@ -231,12 +243,13 @@
                 return ! ca.empty();
         }
 
-	bool try_take_( detail::callable & ca)
+	bool try_take_( callable & ca)
         {
                 if ( deactive_now_() || empty_() )
                         return false;
                 ca = queue_.pop();
-		if ( size_() <= lwm_)
+		bool valid = ! ca.empty();
+		if ( valid && size_() <= lwm_)
                 {
                         if ( lwm_ == hwm_)
                                 not_full_cond_.notify_one();
@@ -245,7 +258,7 @@
                                 // in order to submit an task
                                 not_full_cond_.notify_all();
                 }
-		return ! ca.empty();
+		return valid;
         }
 
         bool producers_activate_() const
@@ -304,7 +317,7 @@
                 deactivate_now_();
         }
 
-	const std::vector< detail::callable > drain()
+	const std::vector< callable > drain()
         {
                 lock_guard< shared_mutex > lk( mtx_);
                 return drain_();
@@ -367,7 +380,7 @@
                 put_( itm, rel_time, lk);
         }
 
-	bool take( detail::callable & ca)
+	bool take( callable & ca)
         {
                 unique_lock< shared_mutex > lk( mtx_);
                 return take_( ca, lk);
@@ -375,14 +388,14 @@
 
         template< typename Duration >
         bool take(
-		detail::callable & ca,
+		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( callable & ca)
         {
                 lock_guard< shared_mutex > lk( mtx_);
                 return try_take_( ca);
Added: sandbox/task/boost/task/callable.hpp
==============================================================================
--- (empty file)
+++ sandbox/task/boost/task/callable.hpp	2009-07-06 13:11:38 EDT (Mon, 06 Jul 2009)
@@ -0,0 +1,113 @@
+
+//          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_CALLABLE_H
+#define BOOST_TASK_CALLABLE_H
+
+#include <boost/config.hpp>
+#include <boost/shared_ptr.hpp>
+#include <boost/thread.hpp>
+
+#include <boost/task/detail/config.hpp>
+#include <boost/task/detail/interrupter.hpp>
+#include <boost/task/task.hpp>
+
+#include <boost/config/abi_prefix.hpp>
+
+# if defined(BOOST_MSVC)
+# pragma warning(push)
+# pragma warning(disable:4251 4275)
+# endif
+
+namespace boost { namespace task
+{
+
+class context;
+
+class BOOST_TASK_DECL callable
+{
+private:
+	friend class context;
+
+	struct impl
+	{
+		virtual ~impl() {}
+		virtual void run() = 0;
+		virtual void reset() = 0;
+		virtual void reset( shared_ptr< thread > const&) = 0;
+	};
+
+	template< typename R >
+	class impl_wrapper : public impl
+	{
+	private:
+		task< R >			t_;
+		detail::interrupter	intr_;
+
+	public:
+		impl_wrapper(
+			task< R > t,
+			detail::interrupter const& intr)
+		: t_( boost::move( t) ), intr_( intr)
+		{}
+
+		void run()
+		{ t_(); }
+
+		void reset()
+		{ intr_.reset(); }
+
+		void reset( shared_ptr< thread > const& thrd)
+		{ intr_.reset( thrd); }
+	};
+
+	shared_ptr< impl >	impl_;
+
+	template< typename R >
+	callable(
+		task< R > t,
+		detail::interrupter const& intr)
+	: impl_( new impl_wrapper<  R >( boost::move( t), intr) )
+	{}
+
+public:
+	class context_guard : private noncopyable
+	{
+	private:
+		callable	&	ca_;
+
+	public:
+		context_guard( callable & ca, shared_ptr< thread > const& thrd)
+		: ca_( ca)
+		{ ca_.reset( thrd); }
+
+		~context_guard()
+		{ ca_.reset(); }
+	};
+
+	callable();
+
+	void operator()();
+
+	bool empty() const;
+
+	void clear();
+
+	void reset();
+
+	void reset( shared_ptr< thread > const&);
+};
+
+}}
+
+# if defined(BOOST_MSVC)
+# pragma warning(pop)
+# endif
+
+#include <boost/config/abi_suffix.hpp>
+
+#endif // BOOST_TASK_CALLABLE_H
+
Added: sandbox/task/boost/task/context.hpp
==============================================================================
--- (empty file)
+++ sandbox/task/boost/task/context.hpp	2009-07-06 13:11:38 EDT (Mon, 06 Jul 2009)
@@ -0,0 +1,43 @@
+
+//          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_CONTEXT_H
+#define BOOST_TASK_CONTEXT_H
+
+#include <boost/shared_ptr.hpp>
+#include <boost/thread/detail/move.hpp>
+
+#include <boost/task/callable.hpp>
+#include <boost/task/detail/interrupter.hpp>
+#include <boost/task/future.hpp>
+#include <boost/task/handle.hpp>
+#include <boost/task/task.hpp>
+
+#include <boost/config/abi_prefix.hpp>
+
+namespace boost { namespace task
+{
+
+class context
+{
+private:
+	detail::interrupter	intr_;
+
+public:
+	template< typename R >
+	callable get_callable( task< R > t)
+	{ return callable( boost::move( t), intr_); }
+
+	template< typename R >
+	handle< R > get_handle( shared_future< R > f)
+	{ return handle< R >( f, intr_); }
+};
+
+}}
+
+#include <boost/config/abi_suffix.hpp>
+
+#endif // BOOST_TASK_CONTEXT_H
Deleted: sandbox/task/boost/task/detail/callable.hpp
==============================================================================
--- sandbox/task/boost/task/detail/callable.hpp	2009-07-06 13:11:38 EDT (Mon, 06 Jul 2009)
+++ (empty file)
@@ -1,89 +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/config.hpp>
-#include <boost/shared_ptr.hpp>
-#include <boost/thread.hpp>
-
-#include <boost/task/detail/config.hpp>
-#include <boost/task/detail/interrupter.hpp>
-#include <boost/task/task.hpp>
-
-#include <boost/config/abi_prefix.hpp>
-
-# if defined(BOOST_MSVC)
-# pragma warning(push)
-# pragma warning(disable:4251 4275)
-# endif
-
-namespace boost { namespace task
-{
-namespace detail
-{
-class BOOST_TASK_DECL callable
-{
-private:
-	struct impl
-	{
-		virtual ~impl() {}
-		virtual void run() = 0;
-		virtual interrupter & get_interrupter() = 0;
-	};
-
-	template< typename R >
-	class impl_wrapper : public impl
-	{
-	private:
-		task< R >	t_;
-		interrupter	i_;
-
-	public:
-		impl_wrapper(
-			task< R > t,
-			interrupter const& i)
-		: t_( boost::move( t) ), i_( i)
-		{}
-
-		void run()
-		{ t_(); }
-		
-		interrupter & get_interrupter()
-		{ return i_; }
-	};
-
-	shared_ptr< impl >	impl_;
-
-public:
-	callable();
-
-	template< typename R >
-	callable(
-		task< R > t,
-		interrupter const& i)
-	: impl_( new impl_wrapper<  R >( boost::move( t), i) )
-	{}
-
-	void operator()();
-
-	bool empty() const;
-
-	void clear();
-	
-	interrupter & get_interrupter();
-};
-}}}
-
-# if defined(BOOST_MSVC)
-# pragma warning(pop)
-# endif
-
-#include <boost/config/abi_suffix.hpp>
-
-#endif // BOOST_TASK_DETAIL_CALLABLE_H
-
Modified: sandbox/task/boost/task/detail/interrupter.hpp
==============================================================================
--- sandbox/task/boost/task/detail/interrupter.hpp	(original)
+++ sandbox/task/boost/task/detail/interrupter.hpp	2009-07-06 13:11:38 EDT (Mon, 06 Jul 2009)
@@ -34,23 +34,23 @@
         class impl : private noncopyable
         {
         private:
-		bool					interruption_requested_;
+		bool					requested_;
                 mutex					mtx_;
                 shared_ptr< thread >	thrd_;
 
-		void set_( shared_ptr< thread > const& thrd);
-
                 void reset_();
 
+		void reset_( shared_ptr< thread > const& thrd);
+
                 void interrupt_();
 
         public:
                 impl();
 
-		void set( shared_ptr< thread > const& thrd);
-
                 void reset();
 
+		void reset( shared_ptr< thread > const& thrd);
+
                 void interrupt();
 
                 bool interruption_requested();
@@ -59,29 +59,17 @@
         shared_ptr< impl >	impl_;
 
 public:
-	class scoped_guard : public noncopyable
-	{
-	private:
-		interrupter	&	intr_;
-	
-	public:
-		scoped_guard( interrupter &, shared_ptr< thread > &);
-	
-		~scoped_guard();
-	};
-
         interrupter();
 
-	void set( shared_ptr< thread > const& thrd);
-
         void reset();
 
+	void reset( shared_ptr< thread > const& thrd);
+
         void interrupt();
 
         bool interruption_requested();
 
-	void swap( interrupter & other)
-	{ impl_.swap( other.impl_); }
+	void swap( interrupter & other);
 };
 }}}
 
Deleted: sandbox/task/boost/task/detail/move.hpp
==============================================================================
--- sandbox/task/boost/task/detail/move.hpp	2009-07-06 13:11:38 EDT (Mon, 06 Jul 2009)
+++ (empty file)
@@ -1,52 +0,0 @@
-// 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/worker.hpp
==============================================================================
--- sandbox/task/boost/task/detail/worker.hpp	(original)
+++ sandbox/task/boost/task/detail/worker.hpp	2009-07-06 13:11:38 EDT (Mon, 06 Jul 2009)
@@ -17,8 +17,8 @@
 #include <boost/thread.hpp>
 #include <boost/utility.hpp>
 
+#include <boost/task/callable.hpp>
 #include <boost/task/detail/config.hpp>
-#include <boost/task/detail/callable.hpp>
 #include <boost/task/detail/guard.hpp>
 #include <boost/task/detail/interrupter.hpp>
 #include <boost/task/detail/wsq.hpp>
@@ -107,7 +107,7 @@
                         BOOST_ASSERT( ! ca.empty() );
                         guard grd( get_pool().active_worker_);
                         {
-				interrupter::scoped_guard lk( ca.get_interrupter(), thrd_);
+				callable::context_guard lk( ca, thrd_);
                                 ca();
                         }
                         ca.clear();
Modified: sandbox/task/boost/task/detail/wsq.hpp
==============================================================================
--- sandbox/task/boost/task/detail/wsq.hpp	(original)
+++ sandbox/task/boost/task/detail/wsq.hpp	2009-07-06 13:11:38 EDT (Mon, 06 Jul 2009)
@@ -12,8 +12,8 @@
 #include <boost/thread/mutex.hpp>
 #include <boost/utility.hpp>
 
+#include <boost/task/callable.hpp>
 #include <boost/task/detail/config.hpp>
-#include <boost/task/detail/callable.hpp>
 
 #include <boost/config/abi_prefix.hpp>
 
@@ -29,13 +29,13 @@
 class BOOST_TASK_DECL wsq : private noncopyable
 {
 private:
-	const int						initial_size_;
+	const int					initial_size_;
         shared_array< callable >	array_;
-	int								capacity_;
-	int								mask_;
-	volatile uint32_t				head_idx_;
-	volatile uint32_t				tail_idx_;
-	recursive_mutex					mtx_;
+	int							capacity_;
+	int							mask_;
+	volatile uint32_t			head_idx_;
+	volatile uint32_t			tail_idx_;
+	recursive_mutex				mtx_;
 
 public:
         wsq();
Modified: sandbox/task/boost/task/fifo.hpp
==============================================================================
--- sandbox/task/boost/task/fifo.hpp	(original)
+++ sandbox/task/boost/task/fifo.hpp	2009-07-06 13:11:38 EDT (Mon, 06 Jul 2009)
@@ -10,7 +10,7 @@
 #include <cstddef>
 #include <list>
 
-#include <boost/task/detail/callable.hpp>
+#include <boost/task/callable.hpp>
 #include <boost/task/detail/meta.hpp>
 
 #include <boost/config/abi_prefix.hpp>
@@ -24,7 +24,7 @@
         class impl
         {
         public:
-		typedef detail::callable					item;
+		typedef 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-07-06 13:11:38 EDT (Mon, 06 Jul 2009)
@@ -19,24 +19,17 @@
 namespace boost { namespace task
 {
 
+class context;
+
 template< typename R >
 class handle
 {
 private:
+	friend class context;
+
         shared_future< R >		fut_;
         detail::interrupter		intr_;
 
-public:
-	handle()
-	: fut_(), intr_()
-	{}
-
-	handle( shared_future< R > fut)
-	:
-	fut_( fut),
-	intr_()
-	{}
-
         handle(
                 shared_future< R > fut,
                 detail::interrupter const& intr)
@@ -45,6 +38,11 @@
         intr_( intr)
         {}
 
+public:
+	handle()
+	: fut_(), intr_()
+	{}
+
         void interrupt()
         { intr_.interrupt(); }
 
@@ -134,7 +132,7 @@
         void swap( handle< R > & other)
         {
                 fut_.swap( other.fut_);
-		intr_.swap( other.intr_);
+// 		intr_.swap( other.intr_);
         }
 };
 
@@ -235,7 +233,6 @@
         catch ( thread_interrupted const&)
         { throw task_interrupted(); }
 }
-
 }}
 
 #include <boost/config/abi_suffix.hpp>
Modified: sandbox/task/boost/task/new_thread.hpp
==============================================================================
--- sandbox/task/boost/task/new_thread.hpp	(original)
+++ sandbox/task/boost/task/new_thread.hpp	2009-07-06 13:11:38 EDT (Mon, 06 Jul 2009)
@@ -7,13 +7,13 @@
 #ifndef BOOST_TASK_NEW_THREAD_H
 #define BOOST_TASK_NEW_THREAD_H
 
+#include <boost/assert.hpp>
 #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/callable.hpp>
+#include <boost/task/context.hpp>
 #include <boost/task/future.hpp>
 #include <boost/task/handle.hpp>
 #include <boost/task/task.hpp>
@@ -24,18 +24,30 @@
 {
 namespace detail
 {
-struct joiner
+class joiner
 {
+private:
+	callable	ca_;
+
+public:
+	joiner( callable const& ca)
+	: ca_( ca)
+	{}
+
         void operator()( thread * thrd)
         {
                 try
-		{ thrd->join(); }
+		{
+			ca_.reset();
+			BOOST_ASSERT( thrd);
+			BOOST_ASSERT( thrd->joinable() );
+			thrd->join();
+		}
                 catch (...)
                 {}
                 delete thrd;
         }
 };
-
 }
 
 struct new_thread
@@ -43,21 +55,19 @@
         template< typename R >
         handle< R > operator()( task< R > t)
         {
-		shared_future< R > fut( t.get_future() );
-
-		detail::interrupter intr;
+		shared_future< R > f( t.get_future() );
+		context ctx;
+		handle< R > h( ctx.get_handle( f) );
+		callable ca( ctx.get_callable( boost::move( t) ) );
                 shared_ptr< thread > thrd(
-			new thread(
-				detail::callable(
-					boost::move( t),
-					intr) ),
-			detail::joiner() );
-		intr.set( thrd);
+			new thread( ca),
+			detail::joiner( ca) );
+		ca.reset( thrd);
 
-		return handle< R >( fut, intr);
+		return h;
         }
 };
-} }
+}}
 
 #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-07-06 13:11:38 EDT (Mon, 06 Jul 2009)
@@ -10,7 +10,9 @@
 #include <boost/config.hpp>
 #include <boost/thread/detail/move.hpp>
 
-#include <boost/task/detail/interrupter.hpp>
+#include <boost/task/callable.hpp>
+#include <boost/task/context.hpp>
+#include <boost/task/future.hpp>
 #include <boost/task/handle.hpp>
 #include <boost/task/task.hpp>
 
@@ -23,12 +25,15 @@
         template< typename R >
         handle< R > operator()( task< R > t)
         {
-		shared_future< R > fut( t.get_future() );
-		t();
-		return handle< R >( fut);
+		shared_future< R > f( t.get_future() );
+		context ctx;
+		handle< R > h( ctx.get_handle( f) );
+		callable ca( ctx.get_callable( boost::move( t) ) );
+		ca();
+		return h;
         }
 };
-} }
+}}
 
 #include <boost/config/abi_suffix.hpp>
 
Modified: sandbox/task/boost/task/priority.hpp
==============================================================================
--- sandbox/task/boost/task/priority.hpp	(original)
+++ sandbox/task/boost/task/priority.hpp	2009-07-06 13:11:38 EDT (Mon, 06 Jul 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/callable.hpp>
 #include <boost/task/detail/meta.hpp>
 
 #include <boost/config/abi_prefix.hpp>
@@ -41,17 +41,17 @@
                 class item
                 {
                 private:
-			detail::callable	ca_;
-			attribute			attr_;
+			callable	ca_;
+			attribute	attr_;
         
                 public:
                         item(
-				detail::callable const& ca,
+				callable const& ca,
                                 attribute const& attr)
                         : ca_( ca), attr_( attr)
                         { BOOST_ASSERT( ! ca_.empty() ); }
         
-			const detail::callable ca() const
+			const callable ca() const
                         { return ca_; }
         
                         const attribute attr() const
@@ -90,7 +90,7 @@
                 void push( item const& itm)
                 { idx_.insert( itm); }
         
-		const detail::callable pop()
+		const 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-07-06 13:11:38 EDT (Mon, 06 Jul 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/callable.hpp>
 #include <boost/task/detail/meta.hpp>
 
 #include <boost/config/abi_prefix.hpp>
@@ -44,8 +44,8 @@
                 class item
                 {
                 private:
-			detail::callable	ca_;
-			attribute			attr_;
+			callable	ca_;
+			attribute	attr_;
         
                 public:
                         item()
@@ -53,12 +53,12 @@
                         {}
 
                         item(
-				detail::callable const& ca,
+				callable const& ca,
                                 attribute const& attr)
                         : ca_( ca), attr_( attr)
                         { BOOST_ASSERT( ! ca_.empty() ); }
         
-			const detail::callable ca() const
+			const callable ca() const
                         { return ca_; }
         
                         const attribute attr() const
@@ -103,7 +103,7 @@
                 void push( item const& itm)
                 { enq_op_( idx_, itm); }
         
-		const detail::callable pop()
+		const callable pop()
                 {
                         item itm;
                         deq_op_( idx_, itm);
Modified: sandbox/task/boost/task/static_pool.hpp
==============================================================================
--- sandbox/task/boost/task/static_pool.hpp	(original)
+++ sandbox/task/boost/task/static_pool.hpp	2009-07-06 13:11:38 EDT (Mon, 06 Jul 2009)
@@ -20,10 +20,10 @@
 #include <boost/thread.hpp>
 #include <boost/thread/detail/move.hpp>
 
+#include <boost/task/callable.hpp>
+#include <boost/task/context.hpp>
 #include <boost/task/detail/atomic.hpp>
 #include <boost/task/detail/bind_processor.hpp>
-#include <boost/task/detail/interrupter.hpp>
-#include <boost/task/detail/callable.hpp>
 #include <boost/task/detail/worker.hpp>
 #include <boost/task/detail/worker_group.hpp>
 #include <boost/task/exceptions.hpp>
@@ -73,11 +73,11 @@
                 template< typename Pool >
                 friend class detail::worker::impl_pool;
 # endif
-	
-		detail::worker_group		wg_;
+
+		detail::worker_group	wg_;
                 shared_mutex			mtx_wg_;
                 volatile uint32_t		state_;
-		channel		 		channel_;
+		channel			 		channel_;
                 volatile uint32_t		active_worker_;
                 volatile uint32_t		idle_worker_;
 
@@ -91,7 +91,7 @@
                         detail::worker w( * i);
                         w.run();
                 }
-		
+
                 void create_worker_(
                         poolsize const& psize,
                         posix_time::time_duration const& asleep,
@@ -322,25 +322,28 @@
                         if ( closed_() )
                                 throw task_rejected("pool is closed");
 
-			shared_future< R > fut( t.get_future() );
-			detail::interrupter intr;
-			channel_.put( detail::callable( boost::move( t), intr) );
-			return handle< R >( fut, intr);
+			shared_future< R > f( t.get_future() );
+			context ctx;
+			handle< R > h( ctx.get_handle( f) );
+			channel_.put(
+					ctx.get_callable( boost::move( t) ) );
+			return h;
                 }
 
-		template<
-			typename R,
-			typename Attr
-		>
+		template< typename R, typename Attr >
                 handle< R > submit( task< R > t, Attr const& attr)
                 {
                         if ( closed_() )
                                 throw task_rejected("pool is closed");
 
-			shared_future< R > fut( t.get_future() );
-			detail::interrupter intr;
-			channel_.put( channel_item( detail::callable( boost::move( t), intr), attr) );
-			return handle< R >( fut, intr);
+			shared_future< R > f( t.get_future() );
+			context ctx;
+			handle< R > h( ctx.get_handle( f) );
+			channel_.put(
+					channel_item(
+						ctx.get_callable( boost::move( t) ),
+						attr) );
+			return h;
                 }
         };
         
@@ -533,10 +536,7 @@
                 return pool_->submit( boost::move( t) );
         }
 
-	template<
-		typename R,
-		typename Attr
-	>
+	template< typename R, typename Attr >
         handle< R > submit( task< R > t, Attr const& attr)
         {
                 if ( ! pool_)
Modified: sandbox/task/boost/task/task.hpp
==============================================================================
--- sandbox/task/boost/task/task.hpp	(original)
+++ sandbox/task/boost/task/task.hpp	2009-07-06 13:11:38 EDT (Mon, 06 Jul 2009)
@@ -14,18 +14,13 @@
 #include <boost/utility/enable_if.hpp>
 #include <boost/utility/result_of.hpp>
 
-#include <boost/task/future.hpp>
 #include <boost/task/exceptions.hpp>
+#include <boost/task/future.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 >
@@ -177,11 +172,6 @@
 class task
 {
 private:
-	template< typename Channel >
-	friend class static_pool;
-
-	friend struct as_sub_task;
-
         struct dummy;
 
         shared_ptr< detail::task_base< R > >	task_;
@@ -278,18 +268,18 @@
 
 # undef BOOST_TASK_CTOR
 
-	unique_future< R > get_future()
+	void operator()()
         {
                 if ( ! task_)
                         throw task_moved();
-		return task_->get_future();
+		task_->run();
         }
 
-	void operator()()
+	unique_future< R > get_future()
         {
                 if ( ! task_)
                         throw task_moved();
-		task_->run();
+		return task_->get_future();	
         }
 
         template< typename Cb >
@@ -347,7 +337,6 @@
 task::task< R > move( boost::detail::thread_move_t< task::task< R > > t)
 { return task::task< R >( t); }
 # endif
-
 }
 
 #include <boost/config/abi_suffix.hpp>
Modified: sandbox/task/boost/task/unbounded_channel.hpp
==============================================================================
--- sandbox/task/boost/task/unbounded_channel.hpp	(original)
+++ sandbox/task/boost/task/unbounded_channel.hpp	2009-07-06 13:11:38 EDT (Mon, 06 Jul 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/callable.hpp>
 #include <boost/task/exceptions.hpp>
 
 #include <boost/config/abi_prefix.hpp>
@@ -88,12 +88,12 @@
                 BOOST_ASSERT( deactive_now_() );
         }
 
-	const std::vector< detail::callable > drain_()
+	const std::vector< callable > drain_()
         {
                 BOOST_ASSERT( deactive_now_() );
-		std::vector< detail::callable > unprocessed;
+		std::vector< callable > unprocessed;
                 unprocessed.reserve( queue_.size() );
-		BOOST_FOREACH( detail::callable ca, queue_)
+		BOOST_FOREACH( callable ca, queue_)
                 { unprocessed.push_back( ca); }
                 clear_();
                 BOOST_ASSERT( empty_() );
@@ -106,9 +106,7 @@
         std::size_t size_() const
         { return queue_.size(); }
 
-	void put_(
-		item const& itm,
-		unique_lock< shared_mutex > & lk)
+	void put_( item const& itm)
         {
                 if ( ! active_() )
                         throw task_rejected("channel is not active");
@@ -117,21 +115,24 @@
         }
 
         bool take_(
-		detail::callable & ca,
+		callable & ca,
                 unique_lock< shared_mutex > & lk)
         {
                 if ( deactive_now_() || ( deactive_() && empty_() ) )
                         return false;
-		try
+		if ( empty_() )
                 {
-			not_empty_cond_.wait(
-				lk,
-				bind(
-					& unbounded_channel::consumers_activate_,
-					this) );
+			try
+			{
+				not_empty_cond_.wait(
+					lk,
+					bind(
+						& unbounded_channel::consumers_activate_,
+						this) );
+			}
+			catch ( thread_interrupted const&)
+			{ return false; }
                 }
-		catch ( thread_interrupted const&)
-		{ return false; }
                 if ( deactive_now_() || ( deactive_() && empty_() ) )
                         return false;
                 ca = queue_.pop();
@@ -140,31 +141,34 @@
 
         template< typename Duration >
         bool take_(
-		detail::callable & ca,
+		callable & ca,
                 Duration const& rel_time,
                 unique_lock< shared_mutex > & lk)
         {
                 if ( deactive_now_() || ( deactive_() && empty_() ) )
                         return false;
-		try
+		if ( empty_() )
                 {
-			if ( ! not_empty_cond_.timed_wait(
-				lk,
-				rel_time,
-				bind(
-					& unbounded_channel::consumers_activate_,
-					this) ) )
-				return false;
+			try
+			{
+				if ( ! not_empty_cond_.timed_wait(
+					lk,
+					rel_time,
+					bind(
+						& unbounded_channel::consumers_activate_,
+						this) ) )
+					return false;
+			}
+			catch ( thread_interrupted const&)
+			{ return false; }
                 }
-		catch ( thread_interrupted const&)
-		{ return false; }
                 if ( deactive_now_() || ( deactive_() && empty_() ) )
                         return false;
                 ca = queue_.pop();
                 return ! ca.empty();
         }
 
-	bool try_take_( detail::callable & ca)
+	bool try_take_( callable & ca)
         {
                 if ( deactive_now_() || empty_() )
                         return false;
@@ -217,7 +221,7 @@
                 deactivate_now_();
         }
 
-	const std::vector< detail::callable > drain()
+	const std::vector< callable > drain()
         {
                 lock_guard< shared_mutex > lk( mtx_);
                 return drain_();
@@ -240,20 +244,11 @@
 
         void put( item const& itm)
         {
-		unique_lock< shared_mutex > lk( mtx_);
-		put_( itm, lk);
-	}
-
-	template< typename Duration >
-	void put(
-		item & itm,
-		Duration const&)
-	{
-		unique_lock< shared_mutex > lk( mtx_);
-		put_( itm, lk);
+		lock_guard< shared_mutex > lk( mtx_);
+		put_( itm);
         }
 
-	bool take( detail::callable & ca)
+	bool take( callable & ca)
         {
                 unique_lock< shared_mutex > lk( mtx_);
                 return take_( ca, lk);
@@ -261,14 +256,14 @@
 
         template< typename Duration >
         bool take(
-		detail::callable & ca,
+		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( callable & ca)
         {
                 lock_guard< shared_mutex > lk( mtx_);
                 return try_take_( ca);
Modified: sandbox/task/libs/task/src/callable.cpp
==============================================================================
--- sandbox/task/libs/task/src/callable.cpp	(original)
+++ sandbox/task/libs/task/src/callable.cpp	2009-07-06 13:11:38 EDT (Mon, 06 Jul 2009)
@@ -4,12 +4,11 @@
 //    (See accompanying file LICENSE_1_0.txt or copy at
 //          http://www.boost.org/LICENSE_1_0.txt)
 
-#include "boost/task/detail/callable.hpp"
+#include "boost/task/callable.hpp"
 
 namespace boost { namespace task
 {
-namespace detail
-{
+
 callable::callable()
 : impl_()
 {}
@@ -26,8 +25,12 @@
 callable::clear()
 { impl_.reset(); }
 
-interrupter &
-callable::get_interrupter()
-{ return impl_->get_interrupter(); }
-} } }
+void
+callable::reset()
+{ impl_->reset(); }
+
+void
+callable::reset( shared_ptr< thread > const& thrd)
+{ impl_->reset( thrd); }
 
+}}
Modified: sandbox/task/libs/task/src/interrupter.cpp
==============================================================================
--- sandbox/task/libs/task/src/interrupter.cpp	(original)
+++ sandbox/task/libs/task/src/interrupter.cpp	2009-07-06 13:11:38 EDT (Mon, 06 Jul 2009)
@@ -12,48 +12,49 @@
 {
 namespace detail
 {
+
 void
-interrupter::impl::set_( shared_ptr< thread > const& thrd)
+interrupter::impl::reset_( shared_ptr< thread > const& thrd)
 {
         thrd_ = thrd;
         BOOST_ASSERT( thrd_);
-	if ( interruption_requested_)
+	if ( requested_)
                 if ( thrd_) thrd_->interrupt();
 }
 
 void
 interrupter::impl::reset_()
 {
+	thrd_.reset();
         try
         { this_thread::interruption_point(); }
         catch ( thread_interrupted const&)
         {}
-	thrd_.reset();
         BOOST_ASSERT( ! this_thread::interruption_requested() );
 }
 
 void
 interrupter::impl::interrupt_()
 {
-	if ( ! interruption_requested_)
+	if ( ! requested_)
         {
-		interruption_requested_ = true;
+		requested_ = true;
                 if ( thrd_) thrd_->interrupt();
         }
 }
 
 interrupter::impl::impl()
 :
-interruption_requested_( false),
+requested_( false),
 mtx_(),
 thrd_()
 {}
 
 void
-interrupter::impl::set( shared_ptr< thread > const& thrd)
+interrupter::impl::reset( shared_ptr< thread > const& thrd)
 {
         lock_guard< mutex > lk( mtx_);
-	set_( thrd);
+	reset_( thrd);
 }
 
 void
@@ -74,7 +75,7 @@
 interrupter::impl::interruption_requested()
 {
         lock_guard< mutex > lk( mtx_);
-	return interruption_requested_;
+	return requested_;
 }
 
 interrupter::interrupter()
@@ -82,8 +83,8 @@
 {}
 
 void
-interrupter::set( shared_ptr< thread > const& thrd)
-{ impl_->set( thrd); }
+interrupter::reset( shared_ptr< thread > const& thrd)
+{ impl_->reset( thrd); }
 
 void
 interrupter::reset()
@@ -97,12 +98,8 @@
 interrupter::interruption_requested()
 { return impl_->interruption_requested(); }
 
-interrupter::scoped_guard::scoped_guard( interrupter & intr, shared_ptr< thread > & thrd)
-: intr_( intr)
-{ intr_.set( thrd); }
-
-interrupter::scoped_guard::~scoped_guard()
-{ intr_.reset(); }
-}
-} }
+void
+interrupter::swap( interrupter & other)
+{ impl_.swap( other.impl_); }
 
+}}}