$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r51799 - sandbox/threadpool/boost/tp
From: oliver.kowalke_at_[hidden]
Date: 2009-03-16 15:36:08
Author: olli
Date: 2009-03-16 15:36:07 EDT (Mon, 16 Mar 2009)
New Revision: 51799
URL: http://svn.boost.org/trac/boost/changeset/51799
Log:
* pool::shutdown and pool::shutdown_now fixed
Text files modified: 
   sandbox/threadpool/boost/tp/lockfree_channel.hpp |     6 +++++-                                  
   sandbox/threadpool/boost/tp/pool.hpp             |    11 +++++------                             
   2 files changed, 10 insertions(+), 7 deletions(-)
Modified: sandbox/threadpool/boost/tp/lockfree_channel.hpp
==============================================================================
--- sandbox/threadpool/boost/tp/lockfree_channel.hpp	(original)
+++ sandbox/threadpool/boost/tp/lockfree_channel.hpp	2009-03-16 15:36:07 EDT (Mon, 16 Mar 2009)
@@ -9,6 +9,7 @@
 #include <boost/tp/detail/atomic.hpp>
 #include <boost/tp/detail/callable.hpp>
 #include <boost/tp/detail/interrupter.hpp>
+#include <boost/tp/exceptions.hpp>
 
 namespace boost {
 namespace tp
@@ -140,9 +141,12 @@
 
         void put( item const& itm)
         {
+		if ( ! active_() )
+			throw task_rejected("channel is not active");
+
                 pointer_t tail;
                 node_t * node( new node_t( itm) );
-		for (;;)
+		for ( active() )
                 {
                         tail = pointer_t( tail_);
                         node->next = pointer_t( tail.ptr, tail.tag + 1);
Modified: sandbox/threadpool/boost/tp/pool.hpp
==============================================================================
--- sandbox/threadpool/boost/tp/pool.hpp	(original)
+++ sandbox/threadpool/boost/tp/pool.hpp	2009-03-16 15:36:07 EDT (Mon, 16 Mar 2009)
@@ -316,8 +316,8 @@
         bool closed_() const
         { return state_ > 0; }
 
-	void close_()
-	{ detail::atomic_fetch_add( & state_, 1); }
+	unsigned int close_()
+	{ return detail::atomic_fetch_add( & state_, 1); }
 
 public:
         explicit pool(
@@ -445,8 +445,7 @@
 
         void shutdown()
         {
-		if ( closed_() ) return;
-		close_();
+		if ( closed_() || close_() > 1) return;
 
                 channel_.deactivate();
                 shared_lock< shared_mutex > lk( mtx_worker_);
@@ -459,8 +458,8 @@
 
         const std::vector< detail::callable > shutdown_now()
         {
-		if ( closed_() ) return std::vector< detail::callable >();
-		close_();
+		if ( closed_() || close_() > 1)
+			return std::vector< detail::callable >();
 
                 channel_.deactivate_now();
                 shared_lock< shared_mutex > lk( mtx_worker_);