Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r56935 - in sandbox/task: boost boost/task boost/task/detail libs/task/src libs/task/test
From: oliver.kowalke_at_[hidden]
Date: 2009-10-16 17:38:59


Author: olli
Date: 2009-10-16 17:38:53 EDT (Fri, 16 Oct 2009)
New Revision: 56935
URL: http://svn.boost.org/trac/boost/changeset/56935

Log:
- reformating the code
- tests for unbounded/bounded_buffer
- distributes round-robin UMS

Added:
   sandbox/task/boost/task/distrib_rr_ums.hpp (contents, props changed)
   sandbox/task/libs/task/test/test_bounded_buffer.cpp (contents, props changed)
   sandbox/task/libs/task/test/test_unbounded_buffer.cpp (contents, props changed)
   sandbox/task/libs/task/test/test_unbounded_onelock_pool_distrib.cpp (contents, props changed)
Text files modified:
   sandbox/task/boost/task.hpp | 1
   sandbox/task/boost/task/as_sub_task.hpp | 4
   sandbox/task/boost/task/async.hpp | 8 ++-
   sandbox/task/boost/task/bounded_buffer.hpp | 53 ++++++++++++--------
   sandbox/task/boost/task/bounded_onelock_fifo.hpp | 27 +++++-----
   sandbox/task/boost/task/bounded_onelock_prio_queue.hpp | 33 ++++++------
   sandbox/task/boost/task/bounded_onelock_smart_queue.hpp | 39 ++++++++-------
   sandbox/task/boost/task/bounded_twolock_fifo.hpp | 36 +++++++------
   sandbox/task/boost/task/callable.hpp | 20 ++++----
   sandbox/task/boost/task/context.hpp | 6 +
   sandbox/task/boost/task/detail/atomic_gcc.hpp | 10 ++--
   sandbox/task/boost/task/detail/bind_processor_aix.hpp | 49 ++++++++++---------
   sandbox/task/boost/task/detail/bind_processor_freebsd.hpp | 70 ++++++++++++++-------------
   sandbox/task/boost/task/detail/bind_processor_hpux.hpp | 76 +++++++++++++++--------------
   sandbox/task/boost/task/detail/bind_processor_linux.hpp | 76 +++++++++++++++--------------
   sandbox/task/boost/task/detail/bind_processor_solaris.hpp | 48 ++++++++++---------
   sandbox/task/boost/task/detail/bind_processor_windows.hpp | 56 +++++++++++----------
   sandbox/task/boost/task/detail/fiber_posix.hpp | 27 +++++-----
   sandbox/task/boost/task/detail/fiber_windows.hpp | 39 ++++++++-------
   sandbox/task/boost/task/detail/guard.hpp | 11 ++--
   sandbox/task/boost/task/detail/meta.hpp | 11 ++--
   sandbox/task/boost/task/detail/pool_base.hpp | 99 ++++++++++++++++++---------------------
   sandbox/task/boost/task/detail/smart.hpp | 12 ++--
   sandbox/task/boost/task/detail/worker.hpp | 89 +++++++++++++++++------------------
   sandbox/task/boost/task/detail/worker_group.hpp | 13 ++--
   sandbox/task/boost/task/detail/wsq.hpp | 9 ++-
   sandbox/task/boost/task/exceptions.hpp | 48 +++++++++---------
   sandbox/task/boost/task/handle.hpp | 18 +++---
   sandbox/task/boost/task/local_rr_ums.hpp | 12 ++--
   sandbox/task/boost/task/meta.hpp | 8 ++-
   sandbox/task/boost/task/new_thread.hpp | 6 +-
   sandbox/task/boost/task/own_thread.hpp | 6 +
   sandbox/task/boost/task/poolsize.hpp | 8 ++-
   sandbox/task/boost/task/scanns.hpp | 8 ++-
   sandbox/task/boost/task/semaphore.hpp | 6 +
   sandbox/task/boost/task/stacksize.hpp | 8 ++-
   sandbox/task/boost/task/static_pool.hpp | 77 ++++++++++++++++--------------
   sandbox/task/boost/task/task.hpp | 66 +++++++++++++------------
   sandbox/task/boost/task/unbounded_buffer.hpp | 25 +++++----
   sandbox/task/boost/task/unbounded_onelock_fifo.hpp | 19 ++++---
   sandbox/task/boost/task/unbounded_onelock_prio_queue.hpp | 25 +++++----
   sandbox/task/boost/task/unbounded_onelock_smart_queue.hpp | 33 ++++++------
   sandbox/task/boost/task/unbounded_twolock_fifo.hpp | 26 +++++----
   sandbox/task/boost/task/utility.hpp | 6 +
   sandbox/task/boost/task/watermark.hpp | 6 +
   sandbox/task/libs/task/src/callable.cpp | 8 +-
   sandbox/task/libs/task/src/context.cpp | 17 +++---
   sandbox/task/libs/task/src/guard.cpp | 10 ++--
   sandbox/task/libs/task/src/poolsize.cpp | 10 ++--
   sandbox/task/libs/task/src/scanns.cpp | 8 +-
   sandbox/task/libs/task/src/semaphore_posix.cpp | 8 +-
   sandbox/task/libs/task/src/semaphore_windows.cpp | 8 +-
   sandbox/task/libs/task/src/spin_auto_reset_event.cpp | 4
   sandbox/task/libs/task/src/spin_condition.cpp | 11 ++--
   sandbox/task/libs/task/src/spin_count_down_event.cpp | 7 +-
   sandbox/task/libs/task/src/spin_manual_reset_event.cpp | 15 ++---
   sandbox/task/libs/task/src/spin_mutex.cpp | 4
   sandbox/task/libs/task/src/stacksize.cpp | 8 +-
   sandbox/task/libs/task/src/watermark.cpp | 8 +-
   sandbox/task/libs/task/src/worker.cpp | 6 +-
   sandbox/task/libs/task/src/worker_group.cpp | 17 +++---
   sandbox/task/libs/task/src/wsq.cpp | 25 ++++-----
   sandbox/task/libs/task/test/Jamfile.v2 | 3 +
   63 files changed, 786 insertions(+), 724 deletions(-)

Modified: sandbox/task/boost/task.hpp
==============================================================================
--- sandbox/task/boost/task.hpp (original)
+++ sandbox/task/boost/task.hpp 2009-10-16 17:38:53 EDT (Fri, 16 Oct 2009)
@@ -16,6 +16,7 @@
 #include <boost/task/bounded_twolock_fifo.hpp>
 #include <boost/task/callable.hpp>
 #include <boost/task/context.hpp>
+#include <boost/task/distrib_rr_ums.hpp>
 #include <boost/task/exceptions.hpp>
 #include <boost/task/future.hpp>
 #include <boost/task/handle.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-10-16 17:38:53 EDT (Fri, 16 Oct 2009)
@@ -22,8 +22,8 @@
 
 #include <boost/config/abi_prefix.hpp>
 
-namespace boost { namespace task
-{
+namespace boost {
+namespace task {
 
 struct as_sub_task
 {

Modified: sandbox/task/boost/task/async.hpp
==============================================================================
--- sandbox/task/boost/task/async.hpp (original)
+++ sandbox/task/boost/task/async.hpp 2009-10-16 17:38:53 EDT (Fri, 16 Oct 2009)
@@ -17,8 +17,9 @@
 
 #include <boost/config/abi_prefix.hpp>
 
-namespace boost { namespace task
-{
+namespace boost {
+namespace task {
+
 template< typename R >
 handle< R > async( task< R > t)
 { return as_sub_task()( boost::move( t) ); }
@@ -34,7 +35,8 @@
 template< typename R, typename Queue, typename Attr >
 handle< R > async( task< R > t, Attr attr, static_pool< Queue > & pool)
 { return pool.submit( boost::move( t), attr); }
-} }
+
+}}
 
 #include <boost/config/abi_suffix.hpp>
 

Modified: sandbox/task/boost/task/bounded_buffer.hpp
==============================================================================
--- sandbox/task/boost/task/bounded_buffer.hpp (original)
+++ sandbox/task/boost/task/bounded_buffer.hpp 2009-10-16 17:38:53 EDT (Fri, 16 Oct 2009)
@@ -12,6 +12,7 @@
 
 #include <boost/assert.hpp>
 #include <boost/bind.hpp>
+#include <boost/cstdint.hpp>
 #include <boost/optional.hpp>
 #include <boost/shared_ptr.hpp>
 #include <boost/utility.hpp>
@@ -25,8 +26,9 @@
 
 #include <boost/config/abi_prefix.hpp>
 
-namespace boost { namespace task
-{
+namespace boost {
+namespace task {
+
 template< typename T >
 class bounded_buffer
 {
@@ -45,6 +47,7 @@
                 std::size_t lwm_;
 
                 base( base &);
+
                 base & operator=( base const&);
 
                 bool active_() const
@@ -61,7 +64,7 @@
                 
                 std::size_t size_() const
                 { return queue_.size(); }
-
+
                 void upper_bound_( std::size_t hwm)
                 {
                         if ( lwm_ > hwm )
@@ -70,7 +73,7 @@
                         hwm_ = hwm;
                         if ( hwm_ > tmp) not_full_cond_.notify_one();
                 }
-
+
                 void lower_bound_( std::size_t lwm)
                 {
                         if ( lwm > hwm_ )
@@ -223,18 +226,20 @@
 
         public:
                 base(
- high_watermark const& hwm,
- low_watermark const& lwm)
- :
- state_( 0),
- queue_(),
- mtx_(),
- not_empty_cond_(),
- not_full_cond_(),
- hwm_( hwm),
- lwm_( lwm)
+ high_watermark const& hwm,
+ low_watermark const& lwm) :
+ state_( 0),
+ queue_(),
+ mtx_(),
+ not_empty_cond_(),
+ not_full_cond_(),
+ hwm_( hwm),
+ lwm_( lwm)
                 {}
 
+ bool active()
+ { return active_(); }
+
                 void deactivate()
                 { deactivate_(); }
 
@@ -249,19 +254,19 @@
                         spin_unique_lock< spin_mutex > lk( mtx_);
                         return hwm_;
                 }
-
+
                 void upper_bound( std::size_t hwm)
                 {
                         spin_unique_lock< spin_mutex > lk( mtx_);
                         upper_bound_( hwm);
                 }
-
+
                 std::size_t lower_bound()
                 {
                         spin_unique_lock< spin_mutex > lk( mtx_);
                         return lwm_;
                 }
-
+
                 void lower_bound( std::size_t lwm)
                 {
                         spin_unique_lock< spin_mutex > lk( mtx_);
@@ -271,7 +276,7 @@
                 void put( value_type const& va)
                 {
                         spin_unique_lock< spin_mutex > lk( mtx_);
- put_( va);
+ put_( va, lk);
                 }
 
                 template< typename TimeDuration >
@@ -308,10 +313,15 @@
         shared_ptr< base > impl_;
 
 public:
- bounded_buffer()
- : impl_( new base)
+ bounded_buffer(
+ high_watermark const& hwm,
+ low_watermark const& lwm) :
+ impl_( new base( hwm, lwm) )
         {}
 
+ bool active()
+ { return impl_->active(); }
+
         void deactivate()
         { impl_->deactivate(); }
 
@@ -349,8 +359,9 @@
         { return impl_->take( t, rel_time); }
 
         bool try_take( optional< T > & t)
- { return impl_->try_take_( t); }
+ { return impl_->try_take( t); }
 };
+
 }}
 
 #include <boost/config/abi_suffix.hpp>

Modified: sandbox/task/boost/task/bounded_onelock_fifo.hpp
==============================================================================
--- sandbox/task/boost/task/bounded_onelock_fifo.hpp (original)
+++ sandbox/task/boost/task/bounded_onelock_fifo.hpp 2009-10-16 17:38:53 EDT (Fri, 16 Oct 2009)
@@ -25,8 +25,9 @@
 
 #include <boost/config/abi_prefix.hpp>
 
-namespace boost { namespace task
-{
+namespace boost {
+namespace task {
+
 class bounded_onelock_fifo
 {
 public:
@@ -220,16 +221,15 @@
 
 public:
         bounded_onelock_fifo(
- high_watermark const& hwm,
- low_watermark const& lwm)
- :
- state_( 0),
- queue_(),
- mtx_(),
- not_empty_cond_(),
- not_full_cond_(),
- hwm_( hwm),
- lwm_( lwm)
+ high_watermark const& hwm,
+ low_watermark const& lwm) :
+ state_( 0),
+ queue_(),
+ mtx_(),
+ not_empty_cond_(),
+ not_full_cond_(),
+ hwm_( hwm),
+ lwm_( lwm)
         {
                 if ( lwm_ > hwm_ )
                         throw invalid_watermark("low watermark must be less than or equal to high watermark");
@@ -304,7 +304,8 @@
                 return try_take_( va);
         }
 };
-} }
+
+}}
 
 #include <boost/config/abi_suffix.hpp>
 

Modified: sandbox/task/boost/task/bounded_onelock_prio_queue.hpp
==============================================================================
--- sandbox/task/boost/task/bounded_onelock_prio_queue.hpp (original)
+++ sandbox/task/boost/task/bounded_onelock_prio_queue.hpp 2009-10-16 17:38:53 EDT (Fri, 16 Oct 2009)
@@ -27,8 +27,9 @@
 
 #include <boost/config/abi_prefix.hpp>
 
-namespace boost { namespace task
-{
+namespace boost {
+namespace task {
+
 template<
         typename Attr,
         typename Comp = std::less< Attr >
@@ -45,9 +46,9 @@
                 attribute_type attr;
 
                 value_type(
- callable const& ca_,
- attribute_type const& attr_)
- : ca( ca_), attr( attr_)
+ callable const& ca_,
+ attribute_type const& attr_) :
+ ca( ca_), attr( attr_)
                 { BOOST_ASSERT( ! ca.empty() ); }
 
                 void swap( value_type & other)
@@ -257,16 +258,15 @@
 
 public:
         bounded_onelock_prio_queue(
- high_watermark const& hwm,
- low_watermark const& lwm)
- :
- state_( 0),
- queue_(),
- mtx_(),
- not_empty_cond_(),
- not_full_cond_(),
- hwm_( hwm),
- lwm_( lwm)
+ high_watermark const& hwm,
+ low_watermark const& lwm) :
+ state_( 0),
+ queue_(),
+ mtx_(),
+ not_empty_cond_(),
+ not_full_cond_(),
+ hwm_( hwm),
+ lwm_( lwm)
         {
                 if ( lwm_ > hwm_ )
                         throw invalid_watermark("low watermark must be less than or equal to high watermark");
@@ -341,7 +341,8 @@
                 return try_take_( ca);
         }
 };
-} }
+
+}}
 
 #include <boost/config/abi_suffix.hpp>
 

Modified: sandbox/task/boost/task/bounded_onelock_smart_queue.hpp
==============================================================================
--- sandbox/task/boost/task/bounded_onelock_smart_queue.hpp (original)
+++ sandbox/task/boost/task/bounded_onelock_smart_queue.hpp 2009-10-16 17:38:53 EDT (Fri, 16 Oct 2009)
@@ -29,8 +29,9 @@
 
 #include <boost/config/abi_prefix.hpp>
 
-namespace boost { namespace task
-{
+namespace boost {
+namespace task {
+
 template<
         typename Attr,
         typename Comp,
@@ -49,9 +50,9 @@
                 attribute_type attr;
 
                 value_type(
- callable const& ca_,
- attribute_type const& attr_)
- : ca( ca_), attr( attr_)
+ callable const& ca_,
+ attribute_type const& attr_) :
+ ca( ca_), attr( attr_)
                 { BOOST_ASSERT( ! ca.empty() ); }
 
                 void swap( value_type & other)
@@ -261,19 +262,18 @@
 
 public:
         bounded_onelock_smart_queue(
- high_watermark const& hwm,
- low_watermark const& lwm)
- :
- state_( 0),
- queue_(),
- idx_( queue_.get< 0 >() ),
- mtx_(),
- not_empty_cond_(),
- not_full_cond_(),
- enq_op_(),
- deq_op_(),
- hwm_( hwm),
- lwm_( lwm)
+ high_watermark const& hwm,
+ low_watermark const& lwm) :
+ state_( 0),
+ queue_(),
+ idx_( queue_.get< 0 >() ),
+ mtx_(),
+ not_empty_cond_(),
+ not_full_cond_(),
+ enq_op_(),
+ deq_op_(),
+ hwm_( hwm),
+ lwm_( lwm)
         {
                 if ( lwm_ > hwm_ )
                         throw invalid_watermark("low watermark must be less than or equal to high watermark");
@@ -348,7 +348,8 @@
                 return try_take_( ca);
         }
 };
-} }
+
+}}
 
 #include <boost/config/abi_suffix.hpp>
 

Modified: sandbox/task/boost/task/bounded_twolock_fifo.hpp
==============================================================================
--- sandbox/task/boost/task/bounded_twolock_fifo.hpp (original)
+++ sandbox/task/boost/task/bounded_twolock_fifo.hpp 2009-10-16 17:38:53 EDT (Fri, 16 Oct 2009)
@@ -11,6 +11,7 @@
 
 #include <boost/assert.hpp>
 #include <boost/bind.hpp>
+#include <boost/cstdint.hpp>
 #include <boost/foreach.hpp>
 #include <boost/thread/condition.hpp>
 #include <boost/thread/locks.hpp>
@@ -24,8 +25,9 @@
 
 #include <boost/config/abi_prefix.hpp>
 
-namespace boost { namespace task
-{
+namespace boost {
+namespace task {
+
 class bounded_twolock_fifo
 {
 public:
@@ -84,19 +86,18 @@
 
 public:
         bounded_twolock_fifo(
- high_watermark const& hwm,
- low_watermark const& lwm)
- :
- state_( 0),
- count_( 0),
- head_( new node),
- head_mtx_(),
- tail_( head_),
- tail_mtx_(),
- not_empty_cond_(),
- not_full_cond_(),
- hwm_( hwm),
- lwm_( lwm)
+ high_watermark const& hwm,
+ low_watermark const& lwm) :
+ state_( 0),
+ count_( 0),
+ head_( new node),
+ head_mtx_(),
+ tail_( head_),
+ tail_mtx_(),
+ not_empty_cond_(),
+ not_full_cond_(),
+ hwm_( hwm),
+ lwm_( lwm)
         {}
 
         void upper_bound_( std::size_t hwm)
@@ -129,7 +130,7 @@
         bool empty()
         {
                 unique_lock< mutex > lk( head_mtx_);
- return empty_();
+ return empty_();
         }
 
         void put( value_type const& va)
@@ -268,7 +269,8 @@
                 return valid;
         }
 };
-} }
+
+}}
 
 #include <boost/config/abi_suffix.hpp>
 

Modified: sandbox/task/boost/task/callable.hpp
==============================================================================
--- sandbox/task/boost/task/callable.hpp (original)
+++ sandbox/task/boost/task/callable.hpp 2009-10-16 17:38:53 EDT (Fri, 16 Oct 2009)
@@ -22,8 +22,8 @@
 # pragma warning(disable:4251 4275)
 # endif
 
-namespace boost { namespace task
-{
+namespace boost {
+namespace task {
 
 class BOOST_TASK_DECL callable
 {
@@ -44,9 +44,9 @@
 
         public:
                 impl_wrapper(
- task< R > t,
- context const& ctx)
- : t_( boost::move( t) ), ctx_( ctx)
+ task< R > t,
+ context const& ctx) :
+ t_( boost::move( t) ), ctx_( ctx)
                 {}
 
                 void run()
@@ -63,9 +63,9 @@
 
         template< typename R >
         callable(
- task< R > t,
- context const& ctx)
- : impl_( new impl_wrapper< R >( boost::move( t), ctx) )
+ task< R > t,
+ context const& ctx) :
+ impl_( new impl_wrapper< R >( boost::move( t), ctx) )
         {}
 
         void operator()();
@@ -85,8 +85,8 @@
         callable & ca_;
 
 public:
- context_guard( callable & ca, shared_ptr< thread > const& thrd)
- : ca_( ca)
+ context_guard( callable & ca, shared_ptr< thread > const& thrd) :
+ ca_( ca)
         { ca_.reset( thrd); }
 
         ~context_guard()

Modified: sandbox/task/boost/task/context.hpp
==============================================================================
--- sandbox/task/boost/task/context.hpp (original)
+++ sandbox/task/boost/task/context.hpp 2009-10-16 17:38:53 EDT (Fri, 16 Oct 2009)
@@ -24,8 +24,9 @@
 # pragma warning(disable:4251 4275)
 # endif
 
-namespace boost { namespace task
-{
+namespace boost {
+namespace task {
+
 class BOOST_TASK_DECL context
 {
 private:
@@ -63,6 +64,7 @@
 
         void swap( context & other);
 };
+
 }}
 
 # if defined(BOOST_MSVC)

Modified: sandbox/task/boost/task/detail/atomic_gcc.hpp
==============================================================================
--- sandbox/task/boost/task/detail/atomic_gcc.hpp (original)
+++ sandbox/task/boost/task/detail/atomic_gcc.hpp 2009-10-16 17:38:53 EDT (Fri, 16 Oct 2009)
@@ -21,10 +21,9 @@
 
 #include <boost/config/abi_prefix.hpp>
 
-namespace boost { namespace task
-{
-namespace detail
-{
+namespace boost {
+namespace task {
+namespace detail {
 
 #if defined(__GLIBCXX__) // g++ 3.4+
 
@@ -69,7 +68,8 @@
         BOOST_ASSERT( operand == 1);
         return __exchange_and_add( ( _Atomic_word volatile *) object, -1) - 1;
 }
-} } }
+
+}}}
 
 #include <boost/config/abi_suffix.hpp>
 

Modified: sandbox/task/boost/task/detail/bind_processor_aix.hpp
==============================================================================
--- sandbox/task/boost/task/detail/bind_processor_aix.hpp (original)
+++ sandbox/task/boost/task/detail/bind_processor_aix.hpp 2009-10-16 17:38:53 EDT (Fri, 16 Oct 2009)
@@ -19,31 +19,32 @@
 
 #include <boost/config/abi_prefix.hpp>
 
-namespace boost { namespace this_thread
+namespace boost {
+namespace this_thread {
+
+inline
+void bind_to_processor( unsigned int n)
 {
- inline
- void bind_to_processor( unsigned int n)
- {
- BOOST_ASSERT( n >= 0);
- BOOST_ASSERT( n < boost::thread::hardware_concurrency() );
-
- if ( ::bindprocessor( BINDTHREAD, ::thread_self(), static_cast< cpu_t >( n) ) == -1)
- throw boost::system::system_error(
- boost::system::error_code(
- errno,
- boost::system::system_category) );
- }
-
-
- inline
- void bind_to_any_processor()
- {
- if ( ::bindprocessor( BINDTHREAD, ::thread_self(), PROCESSOR_CLASS_ANY) == -1)
- throw boost::system::system_error(
- boost::system::error_code(
- errno,
- boost::system::system_category) );
- }
+ BOOST_ASSERT( n >= 0);
+ BOOST_ASSERT( n < boost::thread::hardware_concurrency() );
+
+ if ( ::bindprocessor( BINDTHREAD, ::thread_self(), static_cast< cpu_t >( n) ) == -1)
+ throw boost::system::system_error(
+ boost::system::error_code(
+ errno,
+ boost::system::system_category) );
+}
+
+inline
+void bind_to_any_processor()
+{
+ if ( ::bindprocessor( BINDTHREAD, ::thread_self(), PROCESSOR_CLASS_ANY) == -1)
+ throw boost::system::system_error(
+ boost::system::error_code(
+ errno,
+ boost::system::system_category) );
+}
+
 }}
 
 #include <boost/config/abi_suffix.hpp>

Modified: sandbox/task/boost/task/detail/bind_processor_freebsd.hpp
==============================================================================
--- sandbox/task/boost/task/detail/bind_processor_freebsd.hpp (original)
+++ sandbox/task/boost/task/detail/bind_processor_freebsd.hpp 2009-10-16 17:38:53 EDT (Fri, 16 Oct 2009)
@@ -19,41 +19,43 @@
 
 #include <boost/config/abi_prefix.hpp>
 
-namespace boost { namespace this_thread
+namespace boost {
+namespace this_thread {
+
+inline
+void bind_to_processor( unsigned int n)
+{
+ BOOST_ASSERT( n >= 0);
+ BOOST_ASSERT( n < boost::thread::hardware_concurrency() );
+
+ cpuset_t cpuset;
+ CPU_ZERO( & cpuset);
+ CPU_SET( n, & cpuset);
+
+ if ( ::cpuset_setaffinity( CPU_LEVEL_WHICH, CPU_WHICH_TID, -1, sizeof( cpuset), & cpuset) == -1)
+ throw boost::system::system_error(
+ boost::system::error_code(
+ errno,
+ boost::system::system_category) );
+}
+
+inline
+void bind_to_any_processor()
 {
- inline
- void bind_to_processor( unsigned int n)
- {
- BOOST_ASSERT( n >= 0);
- BOOST_ASSERT( n < boost::thread::hardware_concurrency() );
-
- cpuset_t cpuset;
- CPU_ZERO( & cpuset);
- CPU_SET( n, & cpuset);
-
- if ( ::cpuset_setaffinity( CPU_LEVEL_WHICH, CPU_WHICH_TID, -1, sizeof( cpuset), & cpuset) == -1)
- throw boost::system::system_error(
- boost::system::error_code(
- errno,
- boost::system::system_category) );
- }
-
- inline
- void bind_to_any_processor()
- {
- cpuset_t cpuset;
- CPU_ZERO( & cpuset);
-
- unsigned int max( boost::thread::hardware_concurrency() );
- for ( unsigned int i( 0); i < max; ++i)
- CPU_SET( i, & cpuset);
-
- if ( ::cpuset_setaffinity( CPU_LEVEL_WHICH, CPU_WHICH_TID, -1, sizeof( cpuset), & cpuset) == -1)
- throw boost::system::system_error(
- boost::system::error_code(
- errno,
- boost::system::system_category) );
- }
+ cpuset_t cpuset;
+ CPU_ZERO( & cpuset);
+
+ unsigned int max( boost::thread::hardware_concurrency() );
+ for ( unsigned int i( 0); i < max; ++i)
+ CPU_SET( i, & cpuset);
+
+ if ( ::cpuset_setaffinity( CPU_LEVEL_WHICH, CPU_WHICH_TID, -1, sizeof( cpuset), & cpuset) == -1)
+ throw boost::system::system_error(
+ boost::system::error_code(
+ errno,
+ boost::system::system_category) );
+}
+
 }}
 
 #include <boost/config/abi_suffix.hpp>

Modified: sandbox/task/boost/task/detail/bind_processor_hpux.hpp
==============================================================================
--- sandbox/task/boost/task/detail/bind_processor_hpux.hpp (original)
+++ sandbox/task/boost/task/detail/bind_processor_hpux.hpp 2009-10-16 17:38:53 EDT (Fri, 16 Oct 2009)
@@ -18,44 +18,46 @@
 
 #include <boost/config/abi_prefix.hpp>
 
-namespace boost { namespace this_thread
+namespace boost {
+namespace this_thread {
+
+inline
+void bind_to_processor( unsigned int n)
 {
- inline
- void bind_to_processor( unsigned int n)
- {
- BOOST_ASSERT( n >= 0);
- BOOST_ASSERT( n < boost::thread::hardware_concurrency() );
-
- ::pthread_spu_t spu;
- int errno_(
- ::pthread_processor_bind_np(
- PTHREAD_BIND_FORCED_NP,
- & spu,
- static_cast< pthread_spu_t >( n),
- PTHREAD_SELFTID_NP) );
- if ( errno_ != 0)
- throw boost::system::system_error(
- boost::system::error_code(
- errno_,
- boost::system::system_category) );
- }
-
- inline
- void bind_to_any_processor()
- {
- ::pthread_spu_t spu;
- int errno_(
- ::pthread_processor_bind_np(
- PTHREAD_BIND_FORCED_NP,
- & spu,
- PTHREAD_SPUFLOAT_NP,
- PTHREAD_SELFTID_NP) );
- if ( errno_ != 0)
- throw boost::system::system_error(
- boost::system::error_code(
- errno_,
- boost::system::system_category) );
- }
+ BOOST_ASSERT( n >= 0);
+ BOOST_ASSERT( n < boost::thread::hardware_concurrency() );
+
+ ::pthread_spu_t spu;
+ int errno_(
+ ::pthread_processor_bind_np(
+ PTHREAD_BIND_FORCED_NP,
+ & spu,
+ static_cast< pthread_spu_t >( n),
+ PTHREAD_SELFTID_NP) );
+ if ( errno_ != 0)
+ throw boost::system::system_error(
+ boost::system::error_code(
+ errno_,
+ boost::system::system_category) );
+}
+
+inline
+void bind_to_any_processor()
+{
+ ::pthread_spu_t spu;
+ int errno_(
+ ::pthread_processor_bind_np(
+ PTHREAD_BIND_FORCED_NP,
+ & spu,
+ PTHREAD_SPUFLOAT_NP,
+ PTHREAD_SELFTID_NP) );
+ if ( errno_ != 0)
+ throw boost::system::system_error(
+ boost::system::error_code(
+ errno_,
+ boost::system::system_category) );
+}
+
 }}
 
 #include <boost/config/abi_suffix.hpp>

Modified: sandbox/task/boost/task/detail/bind_processor_linux.hpp
==============================================================================
--- sandbox/task/boost/task/detail/bind_processor_linux.hpp (original)
+++ sandbox/task/boost/task/detail/bind_processor_linux.hpp 2009-10-16 17:38:53 EDT (Fri, 16 Oct 2009)
@@ -19,44 +19,46 @@
 
 #include <boost/config/abi_prefix.hpp>
 
-namespace boost { namespace this_thread
+namespace boost {
+namespace this_thread {
+
+inline
+void bind_to_processor( unsigned int n)
+{
+ BOOST_ASSERT( n >= 0);
+ BOOST_ASSERT( n < CPU_SETSIZE);
+ BOOST_ASSERT( n < boost::thread::hardware_concurrency() );
+
+ cpu_set_t cpuset;
+ CPU_ZERO( & cpuset);
+ CPU_SET( n, & cpuset);
+
+ int errno_( ::pthread_setaffinity_np( ::pthread_self(), sizeof( cpuset), & cpuset) );
+ if ( errno_ != 0)
+ throw boost::system::system_error(
+ boost::system::error_code(
+ errno_,
+ boost::system::system_category) );
+}
+
+inline
+void bind_to_any_processor()
 {
- inline
- void bind_to_processor( unsigned int n)
- {
- BOOST_ASSERT( n >= 0);
- BOOST_ASSERT( n < CPU_SETSIZE);
- BOOST_ASSERT( n < boost::thread::hardware_concurrency() );
-
- cpu_set_t cpuset;
- CPU_ZERO( & cpuset);
- CPU_SET( n, & cpuset);
-
- int errno_( ::pthread_setaffinity_np( ::pthread_self(), sizeof( cpuset), & cpuset) );
- if ( errno_ != 0)
- throw boost::system::system_error(
- boost::system::error_code(
- errno_,
- boost::system::system_category) );
- }
-
- inline
- void bind_to_any_processor()
- {
- cpu_set_t cpuset;
- CPU_ZERO( & cpuset);
-
- unsigned int max( boost::thread::hardware_concurrency() );
- for ( unsigned int i( 0); i < max; ++i)
- CPU_SET( i, & cpuset);
-
- int errno_( ::pthread_setaffinity_np( ::pthread_self(), sizeof( cpuset), & cpuset) );
- if ( errno_ != 0)
- throw boost::system::system_error(
- boost::system::error_code(
- errno_,
- boost::system::system_category) );
- }
+ cpu_set_t cpuset;
+ CPU_ZERO( & cpuset);
+
+ unsigned int max( boost::thread::hardware_concurrency() );
+ for ( unsigned int i( 0); i < max; ++i)
+ CPU_SET( i, & cpuset);
+
+ int errno_( ::pthread_setaffinity_np( ::pthread_self(), sizeof( cpuset), & cpuset) );
+ if ( errno_ != 0)
+ throw boost::system::system_error(
+ boost::system::error_code(
+ errno_,
+ boost::system::system_category) );
+}
+
 }}
 
 #include <boost/config/abi_suffix.hpp>

Modified: sandbox/task/boost/task/detail/bind_processor_solaris.hpp
==============================================================================
--- sandbox/task/boost/task/detail/bind_processor_solaris.hpp (original)
+++ sandbox/task/boost/task/detail/bind_processor_solaris.hpp 2009-10-16 17:38:53 EDT (Fri, 16 Oct 2009)
@@ -20,30 +20,32 @@
 
 #include <boost/config/abi_prefix.hpp>
 
-namespace boost { namespace this_thread
+namespace boost {
+namespace this_thread {
+
+inline
+void bind_to_processor( unsigned int n)
 {
- inline
- void bind_to_processor( unsigned int n)
- {
- BOOST_ASSERT( n >= 0);
- BOOST_ASSERT( n < boost::thread::hardware_concurrency() );
-
- if ( ::processor_bind( P_LWPID, P_MYID, static_cast< processorid_t >( n), 0) == -1)
- throw boost::system::system_error(
- boost::system::error_code(
- errno,
- boost::system::system_category) );
- }
-
- inline
- void bind_to_any_processor()
- {
- if ( ::processor_bind( P_LWPID, P_MYID, PBIND_NONE, 0) == -1)
- throw boost::system::system_error(
- boost::system::error_code(
- errno,
- boost::system::system_category) );
- }
+ BOOST_ASSERT( n >= 0);
+ BOOST_ASSERT( n < boost::thread::hardware_concurrency() );
+
+ if ( ::processor_bind( P_LWPID, P_MYID, static_cast< processorid_t >( n), 0) == -1)
+ throw boost::system::system_error(
+ boost::system::error_code(
+ errno,
+ boost::system::system_category) );
+}
+
+inline
+void bind_to_any_processor()
+{
+ if ( ::processor_bind( P_LWPID, P_MYID, PBIND_NONE, 0) == -1)
+ throw boost::system::system_error(
+ boost::system::error_code(
+ errno,
+ boost::system::system_category) );
+}
+
 }}
 
 #include <boost/config/abi_suffix.hpp>

Modified: sandbox/task/boost/task/detail/bind_processor_windows.hpp
==============================================================================
--- sandbox/task/boost/task/detail/bind_processor_windows.hpp (original)
+++ sandbox/task/boost/task/detail/bind_processor_windows.hpp 2009-10-16 17:38:53 EDT (Fri, 16 Oct 2009)
@@ -18,34 +18,36 @@
 
 #include <boost/config/abi_prefix.hpp>
 
-namespace boost { namespace this_thread
+namespace boost {
+namespace this_thread {
+
+inline
+void bind_to_processor( unsigned int n)
 {
- inline
- void bind_to_processor( unsigned int n)
- {
- BOOST_ASSERT( n >= 0);
- BOOST_ASSERT( n < boost::thread::hardware_concurrency() );
-
- if ( ::SetThreadAffinityMask( ::GetCurrentThread(), ( DWORD_PTR)1 << n) == 0)
- throw boost::system::system_error(
- boost::system::error_code(
- ::GetLastError(),
- boost::system::system_category) );
- }
-
- inline
- void bind_to_any_processor()
- {
- DWORD_PTR ptr( 1);
- for ( unsigned int i( 0); i < boost::thread::hardware_concurrency(); ++i)
- ptr = ptr << i;
-
- if ( ::SetThreadAffinityMask( ::GetCurrentThread(), ptr) == 0)
- throw boost::system::system_error(
- boost::system::error_code(
- ::GetLastError(),
- boost::system::system_category) );
- }
+ BOOST_ASSERT( n >= 0);
+ BOOST_ASSERT( n < boost::thread::hardware_concurrency() );
+
+ if ( ::SetThreadAffinityMask( ::GetCurrentThread(), ( DWORD_PTR)1 << n) == 0)
+ throw boost::system::system_error(
+ boost::system::error_code(
+ ::GetLastError(),
+ boost::system::system_category) );
+}
+
+inline
+void bind_to_any_processor()
+{
+ DWORD_PTR ptr( 1);
+ for ( unsigned int i( 0); i < boost::thread::hardware_concurrency(); ++i)
+ ptr = ptr << i;
+
+ if ( ::SetThreadAffinityMask( ::GetCurrentThread(), ptr) == 0)
+ throw boost::system::system_error(
+ boost::system::error_code(
+ ::GetLastError(),
+ boost::system::system_category) );
+}
+
 }}
 
 #include <boost/config/abi_suffix.hpp>

Modified: sandbox/task/boost/task/detail/fiber_posix.hpp
==============================================================================
--- sandbox/task/boost/task/detail/fiber_posix.hpp (original)
+++ sandbox/task/boost/task/detail/fiber_posix.hpp 2009-10-16 17:38:53 EDT (Fri, 16 Oct 2009)
@@ -21,9 +21,10 @@
 #include <boost/shared_ptr.hpp>
 #include <boost/system/system_error.hpp>
 
-namespace boost { namespace task {
-namespace detail
-{
+namespace boost {
+namespace task {
+namespace detail {
+
 template< typename Fiber >
 void trampoline( Fiber * fib)
 {
@@ -56,15 +57,14 @@
         st_state state_;
 
         fiber(
- function< void() > fn,
- std::size_t stack_size)
- :
- fn_( fn),
- stack_size_( stack_size),
- caller_(),
- callee_(),
- stack_( new char[stack_size]),
- state_( st_uninitialized)
+ function< void() > fn,
+ std::size_t stack_size) :
+ fn_( fn),
+ stack_size_( stack_size),
+ caller_(),
+ callee_(),
+ stack_( new char[stack_size]),
+ state_( st_uninitialized)
         { BOOST_ASSERT( stack_size_ > 0); }
 
         bool uninitialized_() const
@@ -173,7 +173,8 @@
                 BOOST_ASSERT(!"should never be reached");
         }
 };
-} } }
+
+}}}
 
 #endif // BOOST_TASK_DETAIL_FIBER_POSIX_H
 

Modified: sandbox/task/boost/task/detail/fiber_windows.hpp
==============================================================================
--- sandbox/task/boost/task/detail/fiber_windows.hpp (original)
+++ sandbox/task/boost/task/detail/fiber_windows.hpp 2009-10-16 17:38:53 EDT (Fri, 16 Oct 2009)
@@ -20,9 +20,10 @@
 #include <boost/shared_ptr.hpp>
 #include <boost/system/system_error.hpp>
 
-namespace boost { namespace task {
-namespace detail
-{
+namespace boost {
+namespace task {
+namespace detail {
+
 template< typename Fiber >
 VOID CALLBACK trampoline( LPVOID vp)
 {
@@ -55,14 +56,13 @@
         st_state state_;
 
         fiber(
- function< void() > fn,
- std::size_t stack_size)
- :
- fn_( fn),
- stack_size_( stack_size),
- caller_( 0),
- callee_( 0),
- state_( st_uninitialized)
+ function< void() > fn,
+ std::size_t stack_size) :
+ fn_( fn),
+ stack_size_( stack_size),
+ caller_( 0),
+ callee_( 0),
+ state_( st_uninitialized)
         { BOOST_ASSERT( stack_size_ > 0); }
 
         bool uninitialized_() const
@@ -118,11 +118,11 @@
 
         static void convert_thread_to_fiber()
         {
- if ( ! ::ConvertThreadToFiber( 0) )
- throw system::system_error(
- system::error_code(
- ::GetLastError(),
- system::system_category) );
+ if ( ! ::ConvertThreadToFiber( 0) )
+ throw system::system_error(
+ system::error_code(
+ ::GetLastError(),
+ system::system_category) );
         }
 
         static sptr_t create(
@@ -139,10 +139,10 @@
         bool ready() const
         { return uninitialized_() || ready_(); }
 
- bool running() const
+ bool running() const
         { return running_(); }
 
- bool exited() const
+ bool exited() const
         { return exited_(); }
 
         void switch_to( sptr_t & to)
@@ -172,7 +172,8 @@
                 BOOST_ASSERT(!"should never be reached");
         }
 };
-} } }
+
+}}}
 
 #endif // BOOST_TASK_DETAIL_FIBER_WINDOWS_H
 

Modified: sandbox/task/boost/task/detail/guard.hpp
==============================================================================
--- sandbox/task/boost/task/detail/guard.hpp (original)
+++ sandbox/task/boost/task/detail/guard.hpp 2009-10-16 17:38:53 EDT (Fri, 16 Oct 2009)
@@ -19,10 +19,10 @@
 # pragma warning(disable:4251 4275)
 # endif
 
-namespace boost { namespace task
-{
-namespace detail
-{
+namespace boost {
+namespace task {
+namespace detail {
+
 class BOOST_TASK_DECL guard : private noncopyable
 {
 private:
@@ -33,7 +33,8 @@
 
         ~guard();
 };
-} } }
+
+}}}
 
 # if defined(BOOST_MSVC)
 # pragma warning(pop)

Modified: sandbox/task/boost/task/detail/meta.hpp
==============================================================================
--- sandbox/task/boost/task/detail/meta.hpp (original)
+++ sandbox/task/boost/task/detail/meta.hpp 2009-10-16 17:38:53 EDT (Fri, 16 Oct 2009)
@@ -9,16 +9,17 @@
 
 #include <boost/config/abi_prefix.hpp>
 
-namespace boost { namespace task
-{
-namespace detail
-{
+namespace boost {
+namespace task {
+namespace detail {
+
 struct has_attribute
 {};
 
 struct has_no_attribute
 {};
-} } }
+
+}}}
 
 #include <boost/config/abi_suffix.hpp>
 

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 2009-10-16 17:38:53 EDT (Fri, 16 Oct 2009)
@@ -35,11 +35,14 @@
 
 #include <boost/config/abi_prefix.hpp>
 
-namespace boost { namespace task {
-namespace detail
-{
-
-template< typename Queue, typename UMS >
+namespace boost {
+namespace task {
+namespace detail {
+
+template<
+ typename Queue,
+ typename UMS
+>
 class pool_base
 {
 private:
@@ -128,17 +131,16 @@
 
 public:
         explicit pool_base(
- poolsize const& psize,
- posix_time::time_duration const& asleep,
- scanns const& max_scns,
- stacksize const& stack_size)
- :
- ums_(),
- wg_(),
- mtx_wg_(),
- state_( 0),
- queue_(),
- idle_worker_( 0)
+ poolsize const& psize,
+ posix_time::time_duration const& asleep,
+ scanns const& max_scns,
+ stacksize const& stack_size) :
+ ums_(),
+ wg_(),
+ mtx_wg_(),
+ state_( 0),
+ queue_(),
+ idle_worker_( 0)
         {
                 if ( asleep.is_special() || asleep.is_negative() )
                         throw invalid_timeduration();
@@ -148,20 +150,17 @@
         }
 
         explicit pool_base(
- poolsize const& psize,
- high_watermark const& hwm,
- low_watermark const& lwm,
- posix_time::time_duration const& asleep,
- scanns const& max_scns,
- stacksize const& stack_size)
- :
- wg_(),
- mtx_wg_(),
- state_( 0),
- queue_(
- hwm,
- lwm),
- idle_worker_( 0)
+ poolsize const& psize,
+ high_watermark const& hwm,
+ low_watermark const& lwm,
+ posix_time::time_duration const& asleep,
+ scanns const& max_scns,
+ stacksize const& stack_size) :
+ wg_(),
+ mtx_wg_(),
+ state_( 0),
+ queue_( hwm, lwm),
+ idle_worker_( 0)
         {
                 if ( asleep.is_special() || asleep.is_negative() )
                         throw invalid_timeduration();
@@ -172,15 +171,14 @@
 
 # if defined(BOOST_HAS_PROCESSOR_BINDINGS)
         explicit pool_base(
- posix_time::time_duration const& asleep,
- scanns const& max_scns,
- stacksize const& stack_size)
- :
- wg_(),
- mtx_wg_(),
- state_( 0),
- queue_(),
- idle_worker_( 0)
+ posix_time::time_duration const& asleep,
+ scanns const& max_scns,
+ stacksize const& stack_size) :
+ wg_(),
+ mtx_wg_(),
+ state_( 0),
+ queue_(),
+ idle_worker_( 0)
         {
                 if ( asleep.is_special() || asleep.is_negative() )
                         throw invalid_timeduration();
@@ -192,19 +190,16 @@
         }
 
         explicit pool_base(
- high_watermark const& hwm,
- low_watermark const& lwm,
- posix_time::time_duration const& asleep,
- scanns const& max_scns,
- stacksize const& stack_size)
- :
- wg_(),
- mtx_wg_(),
- state_( 0),
- queue_(
- hwm,
- lwm),
- idle_worker_( 0)
+ high_watermark const& hwm,
+ low_watermark const& lwm,
+ posix_time::time_duration const& asleep,
+ scanns const& max_scns,
+ stacksize const& stack_size) :
+ wg_(),
+ mtx_wg_(),
+ state_( 0),
+ queue_( hwm, lwm),
+ idle_worker_( 0)
         {
                 if ( asleep.is_special() || asleep.is_negative() )
                         throw invalid_timeduration();

Modified: sandbox/task/boost/task/detail/smart.hpp
==============================================================================
--- sandbox/task/boost/task/detail/smart.hpp (original)
+++ sandbox/task/boost/task/detail/smart.hpp 2009-10-16 17:38:53 EDT (Fri, 16 Oct 2009)
@@ -11,9 +11,10 @@
 
 #include <boost/config/abi_prefix.hpp>
 
-namespace boost { namespace task {
-namespace detail
-{
+namespace boost {
+namespace task {
+namespace detail {
+
 struct replace_oldest
 {
         template<
@@ -39,8 +40,8 @@
                 callable & ca_;
 
         public:
- swapper( callable & ca)
- : ca_( ca)
+ swapper( callable & ca) :
+ ca_( ca)
                 {}
 
                 template< typename Value >
@@ -58,6 +59,7 @@
                 idx.erase( i);
         }
 };
+
 }}}
 
 #include <boost/config/abi_suffix.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-10-16 17:38:53 EDT (Fri, 16 Oct 2009)
@@ -34,9 +34,9 @@
 # pragma warning(disable:4251 4275)
 # endif
 
-namespace boost { namespace task {
-namespace detail
-{
+namespace boost {
+namespace task {
+namespace detail {
 
 struct worker_base
 {
@@ -80,11 +80,10 @@
                 variate_generator< rand48 &, uniform_int<> > die_;
 
         public:
- random_idx( std::size_t size)
- :
- rng_(),
- six_( 0, size - 1),
- die_( rng_, six_)
+ random_idx( std::size_t size) :
+ rng_(),
+ six_( 0, size - 1),
+ die_( rng_, six_)
                 {}
 
                 std::size_t operator()()
@@ -261,27 +260,26 @@
 
 public:
         worker_object(
- Pool & pool,
- UMS & ums,
- poolsize const& psize,
- posix_time::time_duration const& asleep,
- scanns const& max_scns,
- stacksize const& stack_size,
- function< void() > const& fn)
- :
- pool_( pool),
- ums_( ums),
- thrd_( new thread( fn) ),
- fib_(),
- wsq_(),
- shtdwn_sem_( 0),
- shtdwn_now_sem_( 0),
- shtdwn_( false),
- asleep_( asleep),
- max_scns_( max_scns),
- scns_( 0),
- stack_size_( stack_size),
- rnd_idx_( psize)
+ Pool & pool,
+ UMS & ums,
+ poolsize const& psize,
+ posix_time::time_duration const& asleep,
+ scanns const& max_scns,
+ stacksize const& stack_size,
+ function< void() > const& fn) :
+ pool_( pool),
+ ums_( ums),
+ thrd_( new thread( fn) ),
+ fib_(),
+ wsq_(),
+ shtdwn_sem_( 0),
+ shtdwn_now_sem_( 0),
+ shtdwn_( false),
+ asleep_( asleep),
+ max_scns_( max_scns),
+ scns_( 0),
+ stack_size_( stack_size),
+ rnd_idx_( psize)
         { BOOST_ASSERT( ! fn.empty() ); }
 
         const thread::id get_id() const
@@ -360,23 +358,22 @@
 public:
         template< typename Pool, typename UMS >
         worker(
- Pool & pool,
- UMS & ums,
- poolsize const& psize,
- posix_time::time_duration const& asleep,
- scanns const& max_scns,
- stacksize const& stack_size,
- function< void() > const& fn)
- :
- impl_(
- new worker_object< Pool, UMS, worker >(
- pool,
- ums,
- psize,
- asleep,
- max_scns,
- stack_size,
- fn) )
+ Pool & pool,
+ UMS & ums,
+ poolsize const& psize,
+ posix_time::time_duration const& asleep,
+ scanns const& max_scns,
+ stacksize const& stack_size,
+ function< void() > const& fn) :
+ impl_(
+ new worker_object< Pool, UMS, worker >(
+ pool,
+ ums,
+ psize,
+ asleep,
+ max_scns,
+ stack_size,
+ fn) )
         {}
 
         const thread::id get_id() const;

Modified: sandbox/task/boost/task/detail/worker_group.hpp
==============================================================================
--- sandbox/task/boost/task/detail/worker_group.hpp (original)
+++ sandbox/task/boost/task/detail/worker_group.hpp 2009-10-16 17:38:53 EDT (Fri, 16 Oct 2009)
@@ -25,10 +25,10 @@
 # pragma warning(disable:4251 4275)
 # endif
 
-namespace boost { namespace task
-{
-namespace detail
-{
+namespace boost {
+namespace task {
+namespace detail {
+
 class BOOST_TASK_DECL worker_group
 {
 private:
@@ -80,7 +80,7 @@
         const const_iterator find( thread::id const& id) const;
 
         void insert( worker const& w);
-
+
         iterator erase( iterator const& i);
 
         void join_all();
@@ -91,7 +91,8 @@
 
         void signal_shutdown_now_all();
 };
-} } }
+
+}}}
 
 # if defined(BOOST_MSVC)
 # pragma warning(pop)

Modified: sandbox/task/boost/task/detail/wsq.hpp
==============================================================================
--- sandbox/task/boost/task/detail/wsq.hpp (original)
+++ sandbox/task/boost/task/detail/wsq.hpp 2009-10-16 17:38:53 EDT (Fri, 16 Oct 2009)
@@ -22,10 +22,10 @@
 # pragma warning(disable:4251 4275)
 # endif
 
-namespace boost { namespace task
-{
-namespace detail
-{
+namespace boost {
+namespace task {
+namespace detail {
+
 class BOOST_TASK_DECL wsq : private noncopyable
 {
 private:
@@ -50,6 +50,7 @@
 
         bool try_steal( callable &);
 };
+
 }}}
 
 # if defined(BOOST_MSVC)

Added: sandbox/task/boost/task/distrib_rr_ums.hpp
==============================================================================
--- (empty file)
+++ sandbox/task/boost/task/distrib_rr_ums.hpp 2009-10-16 17:38:53 EDT (Fri, 16 Oct 2009)
@@ -0,0 +1,129 @@
+
+// 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_DISTRIB_RR_UMS_H
+#define BOOST_TASK_DISTRIB_RR_UMS_H
+
+#include <boost/assert.hpp>
+#include <boost/cstdint.hpp>
+#include <boost/shared_ptr.hpp>
+#include <boost/thread.hpp>
+
+#include <boost/task/detail/atomic.hpp>
+#include <boost/task/detail/fiber.hpp>
+
+#include <boost/config/abi_prefix.hpp>
+
+namespace boost {
+namespace task {
+
+class distrib_rr_ums
+{
+private:
+ class twolock_fifo
+ {
+ struct node
+ {
+ typedef shared_ptr< node > sptr_t;
+
+ detail::fiber::sptr_t fib;
+ sptr_t next;
+ };
+
+ node::sptr_t head_;
+ mutex head_mtx_;
+ node::sptr_t tail_;
+ mutex tail_mtx_;
+
+ bool empty_()
+ { return head_ == get_tail_(); }
+
+ node::sptr_t get_tail_()
+ {
+ lock_guard< mutex > lk( tail_mtx_);
+ node::sptr_t tmp = tail_;
+ return tmp;
+ }
+
+ node::sptr_t pop_head_()
+ {
+ node::sptr_t old_head = head_;
+ head_ = old_head->next;
+ return old_head;
+ }
+
+ public:
+ twolock_fifo() :
+ head_( new node),
+ head_mtx_(),
+ tail_( head_),
+ tail_mtx_()
+ {}
+
+ bool empty()
+ {
+ unique_lock< mutex > lk( head_mtx_);
+ return empty_();
+ }
+
+ void put( detail::fiber::sptr_t const& fib)
+ {
+ node::sptr_t new_node( new node);
+ {
+ unique_lock< mutex > lk( tail_mtx_);
+ tail_->fib = fib;
+ tail_->next = new_node;
+ tail_ = new_node;
+ }
+ }
+
+ bool try_take( detail::fiber::sptr_t & fib)
+ {
+ unique_lock< mutex > lk( head_mtx_);
+ if ( empty_() )
+ return false;
+ fib.swap( head_->fib);
+ pop_head_();
+ return fib;
+ }
+ };
+
+ twolock_fifo runnable_;
+ twolock_fifo blocked_;
+
+public:
+ distrib_rr_ums() :
+ runnable_(), blocked_()
+ {}
+
+ void attach()
+ {}
+
+ bool has_runnable()
+ { return ! runnable_.empty(); }
+
+ bool has_blocked()
+ { return ! blocked_.empty(); }
+
+ void put_runnable( detail::fiber::sptr_t const& fib)
+ { runnable_.put( fib); }
+
+ void put_blocked( detail::fiber::sptr_t const& fib)
+ { blocked_.put( fib); }
+
+ bool try_take_runnable( detail::fiber::sptr_t & fib)
+ { return runnable_.try_take( fib); }
+
+ bool try_take_blocked( detail::fiber::sptr_t & fib)
+ { return blocked_.try_take( fib); }
+};
+
+}}
+
+#include <boost/config/abi_suffix.hpp>
+
+#endif // BOOST_TASK_DISTRIB_RR_UMS_H
+

Modified: sandbox/task/boost/task/exceptions.hpp
==============================================================================
--- sandbox/task/boost/task/exceptions.hpp (original)
+++ sandbox/task/boost/task/exceptions.hpp 2009-10-16 17:38:53 EDT (Fri, 16 Oct 2009)
@@ -18,72 +18,72 @@
 class invalid_poolsize : public std::invalid_argument
 {
 public:
- invalid_poolsize()
- : std::invalid_argument("core poolsize must be greater than zero")
+ invalid_poolsize() :
+ std::invalid_argument("core poolsize must be greater than zero")
         {}
 };
 
 class invalid_scanns : public std::invalid_argument
 {
 public:
- invalid_scanns()
- : std::invalid_argument("scanns must be greater than or equal to zero")
+ invalid_scanns() :
+ std::invalid_argument("scanns must be greater than or equal to zero")
         {}
 };
 
 class invalid_stacksize : public std::invalid_argument
 {
 public:
- invalid_stacksize()
- : std::invalid_argument("stacksize must be greater than zero")
+ invalid_stacksize() :
+ std::invalid_argument("stacksize must be greater than zero")
         {}
 };
 
 class invalid_timeduration : public std::invalid_argument
 {
 public:
- invalid_timeduration()
- : std::invalid_argument("argument asleep is not valid")
+ invalid_timeduration() :
+ std::invalid_argument("argument asleep is not valid")
         {}
 };
 
 class invalid_watermark : public std::invalid_argument
 {
 public:
- invalid_watermark( std::string const& msg)
- : std::invalid_argument( msg)
+ invalid_watermark( std::string const& msg) :
+ std::invalid_argument( msg)
         {}
 };
 
 class task_uninitialized : public std::logic_error
 {
 public:
- task_uninitialized()
- : std::logic_error("task uninitialized")
+ task_uninitialized() :
+ std::logic_error("task uninitialized")
         {}
 };
 
 class task_already_executed : public std::logic_error
 {
 public:
- task_already_executed()
- : std::logic_error("task already executed")
+ task_already_executed() :
+ std::logic_error("task already executed")
         {}
 };
 
 class task_moved : public std::logic_error
 {
 public:
- task_moved()
- : std::logic_error("task moved")
+ task_moved() :
+ std::logic_error("task moved")
         {}
 };
 
 class broken_task : public std::logic_error
 {
 public:
- broken_task()
- : std::logic_error("broken task")
+ broken_task() :
+ std::logic_error("broken task")
         {}
 };
 
@@ -93,24 +93,24 @@
 class task_rejected : public std::runtime_error
 {
 public:
- task_rejected( std::string const& msg)
- : std::runtime_error( msg)
+ task_rejected( std::string const& msg) :
+ std::runtime_error( msg)
         {}
 };
 
 class pool_moved : public std::logic_error
 {
 public:
- pool_moved()
- : std::logic_error("pool moved")
+ pool_moved() :
+ std::logic_error("pool moved")
         {}
 };
 
 class lock_error : public std::logic_error
 {
 public:
- lock_error()
- : std::logic_error("lock invalid")
+ lock_error() :
+ std::logic_error("lock invalid")
         {}
 };
 

Modified: sandbox/task/boost/task/handle.hpp
==============================================================================
--- sandbox/task/boost/task/handle.hpp (original)
+++ sandbox/task/boost/task/handle.hpp 2009-10-16 17:38:53 EDT (Fri, 16 Oct 2009)
@@ -16,8 +16,8 @@
 
 #include <boost/config/abi_prefix.hpp>
 
-namespace boost { namespace task
-{
+namespace boost {
+namespace task {
 
 template< typename R >
 class handle
@@ -27,16 +27,15 @@
         context ctx_;
 
 public:
- handle()
- : fut_(), ctx_()
+ handle() :
+ fut_(), ctx_()
         {}
 
         handle(
- shared_future< R > fut,
- context const& ctx)
- :
- fut_( fut),
- ctx_( ctx)
+ shared_future< R > fut,
+ context const& ctx) :
+ fut_( fut),
+ ctx_( ctx)
         {}
 
         void interrupt()
@@ -229,6 +228,7 @@
         catch ( thread_interrupted const&)
         { throw task_interrupted(); }
 }
+
 }}
 
 #include <boost/config/abi_suffix.hpp>

Modified: sandbox/task/boost/task/local_rr_ums.hpp
==============================================================================
--- sandbox/task/boost/task/local_rr_ums.hpp (original)
+++ sandbox/task/boost/task/local_rr_ums.hpp 2009-10-16 17:38:53 EDT (Fri, 16 Oct 2009)
@@ -17,8 +17,9 @@
 
 #include <boost/config/abi_prefix.hpp>
 
-namespace boost { namespace task
-{
+namespace boost {
+namespace task {
+
 class local_rr_ums
 {
 private:
@@ -26,8 +27,8 @@
         thread_specific_ptr< std::list< detail::fiber::sptr_t > > blocked_;
 
 public:
- local_rr_ums()
- : runnable_(), blocked_()
+ local_rr_ums() :
+ runnable_(), blocked_()
         {}
 
         void attach()
@@ -64,7 +65,8 @@
                 return true;
         }
 };
-} }
+
+}}
 
 #include <boost/config/abi_suffix.hpp>
 

Modified: sandbox/task/boost/task/meta.hpp
==============================================================================
--- sandbox/task/boost/task/meta.hpp (original)
+++ sandbox/task/boost/task/meta.hpp 2009-10-16 17:38:53 EDT (Fri, 16 Oct 2009)
@@ -14,8 +14,9 @@
 
 #include <boost/config/abi_prefix.hpp>
 
-namespace boost { namespace task
-{
+namespace boost {
+namespace task {
+
 template< typename Pool >
 struct has_attribute : public mpl::bool_<
         is_same<
@@ -30,7 +31,8 @@
 {
         typedef typename Pool::queue_type::attribute_type type;
 };
-} }
+
+}}
 
 #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-10-16 17:38:53 EDT (Fri, 16 Oct 2009)
@@ -50,8 +50,8 @@
         {
                 callable ca;
                 
- wrapper( callable const& ca_)
- : ca( ca_)
+ wrapper( callable const& ca_) :
+ ca( ca_)
                 {}
                 
                 void operator()()
@@ -60,7 +60,7 @@
                         ca.clear();
                 }
         };
-
+
 public:
         template< typename R >
         handle< R > operator()( task< R > t)

Modified: sandbox/task/boost/task/own_thread.hpp
==============================================================================
--- sandbox/task/boost/task/own_thread.hpp (original)
+++ sandbox/task/boost/task/own_thread.hpp 2009-10-16 17:38:53 EDT (Fri, 16 Oct 2009)
@@ -18,8 +18,9 @@
 
 #include <boost/config/abi_prefix.hpp>
 
-namespace boost { namespace task
-{
+namespace boost {
+namespace task {
+
 struct own_thread
 {
         template< typename R >
@@ -33,6 +34,7 @@
                 return h;
         }
 };
+
 }}
 
 #include <boost/config/abi_suffix.hpp>

Modified: sandbox/task/boost/task/poolsize.hpp
==============================================================================
--- sandbox/task/boost/task/poolsize.hpp (original)
+++ sandbox/task/boost/task/poolsize.hpp 2009-10-16 17:38:53 EDT (Fri, 16 Oct 2009)
@@ -18,8 +18,9 @@
 # pragma warning(disable:4251 4275)
 # endif
 
-namespace boost { namespace task
-{
+namespace boost {
+namespace task {
+
 class BOOST_TASK_DECL poolsize
 {
 private:
@@ -30,7 +31,8 @@
 
         operator std::size_t () const;
 };
-} }
+
+}}
 
 # if defined(BOOST_MSVC)
 # pragma warning(pop)

Modified: sandbox/task/boost/task/scanns.hpp
==============================================================================
--- sandbox/task/boost/task/scanns.hpp (original)
+++ sandbox/task/boost/task/scanns.hpp 2009-10-16 17:38:53 EDT (Fri, 16 Oct 2009)
@@ -18,8 +18,9 @@
 # pragma warning(disable:4251 4275)
 # endif
 
-namespace boost { namespace task
-{
+namespace boost {
+namespace task {
+
 class BOOST_TASK_DECL scanns
 {
 private:
@@ -30,7 +31,8 @@
 
         operator std::size_t () const;
 };
-} }
+
+}}
 
 # if defined(BOOST_MSVC)
 # pragma warning(pop)

Modified: sandbox/task/boost/task/semaphore.hpp
==============================================================================
--- sandbox/task/boost/task/semaphore.hpp (original)
+++ sandbox/task/boost/task/semaphore.hpp 2009-10-16 17:38:53 EDT (Fri, 16 Oct 2009)
@@ -29,8 +29,9 @@
 # pragma warning(disable:4251 4275)
 # endif
 
-namespace boost { namespace task
-{
+namespace boost {
+namespace task {
+
 class BOOST_TASK_DECL semaphore : private boost::noncopyable
 {
 private:
@@ -51,6 +52,7 @@
 
         int value();
 };
+
 }}
 
 # if defined(BOOST_MSVC)

Modified: sandbox/task/boost/task/stacksize.hpp
==============================================================================
--- sandbox/task/boost/task/stacksize.hpp (original)
+++ sandbox/task/boost/task/stacksize.hpp 2009-10-16 17:38:53 EDT (Fri, 16 Oct 2009)
@@ -18,8 +18,9 @@
 # pragma warning(disable:4251 4275)
 # endif
 
-namespace boost { namespace task
-{
+namespace boost {
+namespace task {
+
 class BOOST_TASK_DECL stacksize
 {
 private:
@@ -30,7 +31,8 @@
 
         operator std::size_t () const;
 };
-} }
+
+}}
 
 # if defined(BOOST_MSVC)
 # pragma warning(pop)

Modified: sandbox/task/boost/task/static_pool.hpp
==============================================================================
--- sandbox/task/boost/task/static_pool.hpp (original)
+++ sandbox/task/boost/task/static_pool.hpp 2009-10-16 17:38:53 EDT (Fri, 16 Oct 2009)
@@ -28,9 +28,13 @@
 
 #include <boost/config/abi_prefix.hpp>
 
-namespace boost { namespace task
-{
-template< typename Queue, typename UMS = local_rr_ums >
+namespace boost {
+namespace task {
+
+template<
+ typename Queue,
+ typename UMS = local_rr_ums
+>
 class static_pool
 {
 public:
@@ -53,45 +57,45 @@
         static_pool & operator=( static_pool &);
 
 public:
- static_pool()
- : pool_()
+ static_pool() :
+ pool_()
         {}
         
         explicit static_pool(
- poolsize const& psize,
- posix_time::time_duration const& asleep = posix_time::microseconds( 10),
- scanns const& max_scns = scanns( 20),
- stacksize const& stack_size = stacksize( 64000) )
- : pool_( new base_type( psize, asleep, max_scns, stack_size) )
+ poolsize const& psize,
+ posix_time::time_duration const& asleep = posix_time::microseconds( 10),
+ scanns const& max_scns = scanns( 20),
+ stacksize const& stack_size = stacksize( 64000) ) :
+ pool_( new base_type( psize, asleep, max_scns, stack_size) )
         {}
 
         explicit static_pool(
- poolsize const& psize,
- high_watermark const& hwm,
- low_watermark const& lwm,
- posix_time::time_duration const& asleep = posix_time::microseconds( 100),
- scanns const& max_scns = scanns( 20),
- stacksize const& stack_size = stacksize( 64000) )
- : pool_( new base_type( psize, hwm, lwm, asleep, max_scns, stack_size) )
+ poolsize const& psize,
+ high_watermark const& hwm,
+ low_watermark const& lwm,
+ posix_time::time_duration const& asleep = posix_time::microseconds( 100),
+ scanns const& max_scns = scanns( 20),
+ stacksize const& stack_size = stacksize( 64000) ) :
+ pool_( new base_type( psize, hwm, lwm, asleep, max_scns, stack_size) )
         {}
 
 # if defined(BOOST_HAS_PROCESSOR_BINDINGS)
         explicit static_pool(
- tag_bind_to_processors,
- posix_time::time_duration const& asleep = posix_time::microseconds( 10),
- scanns const& max_scns = scanns( 20),
- stacksize const& stack_size = stacksize( 64000) )
- : pool_( new base_type( asleep, max_scns, stack_size) )
+ tag_bind_to_processors,
+ posix_time::time_duration const& asleep = posix_time::microseconds( 10),
+ scanns const& max_scns = scanns( 20),
+ stacksize const& stack_size = stacksize( 64000) ) :
+ pool_( new base_type( asleep, max_scns, stack_size) )
         {}
 
         explicit static_pool(
- tag_bind_to_processors,
- high_watermark const& hwm,
- low_watermark const& lwm,
- posix_time::time_duration const& asleep = posix_time::microseconds( 100),
- scanns const& max_scns = scanns( 20),
- stacksize const& stack_size = stacksize( 64000) )
- : pool_( new base_type( hwm, lwm, asleep, max_scns, stack_size) )
+ tag_bind_to_processors,
+ high_watermark const& hwm,
+ low_watermark const& lwm,
+ posix_time::time_duration const& asleep = posix_time::microseconds( 100),
+ scanns const& max_scns = scanns( 20),
+ stacksize const& stack_size = stacksize( 64000) ) :
+ pool_( new base_type( hwm, lwm, asleep, max_scns, stack_size) )
         {}
 
         static tag_bind_to_processors bind_to_processors()
@@ -99,8 +103,8 @@
 # endif
 
 # if defined(BOOST_HAS_RVALUE_REFS)
- static_pool( static_pool && other)
- : pool_()
+ static_pool( static_pool && other) :
+ pool_()
         { pool_.swap( other.pool_); }
 
         static_pool & operator=( static_pool && other)
@@ -113,15 +117,15 @@
         static_pool && move()
         { return static_cast< static_pool && >( * this); }
 # else
- static_pool( boost::detail::thread_move_t< static_pool > other)
- : pool_()
+ static_pool( boost::detail::thread_move_t< static_pool > other) :
+ pool_()
         { pool_.swap( other->pool_); }
 
         static_pool & operator=( boost::detail::thread_move_t< static_pool > other)
         {
- static_pool tmp( other);
- swap( tmp);
- return * this;
+ static_pool tmp( other);
+ swap( tmp);
+ return * this;
         }
 
         operator boost::detail::thread_move_t< static_pool >()
@@ -224,6 +228,7 @@
         void swap( static_pool & other) // throw()
         { pool_.swap( other.pool_); }
 };
+
 }
 
 template< typename Queue, typename UMS >

Modified: sandbox/task/boost/task/task.hpp
==============================================================================
--- sandbox/task/boost/task/task.hpp (original)
+++ sandbox/task/boost/task/task.hpp 2009-10-16 17:38:53 EDT (Fri, 16 Oct 2009)
@@ -19,10 +19,10 @@
 
 #include <boost/config/abi_prefix.hpp>
 
-namespace boost { namespace task
-{
-namespace detail
-{
+namespace boost {
+namespace task {
+namespace detail {
+
 template< typename R >
 class task_base
 {
@@ -35,8 +35,8 @@
         virtual void do_run() = 0;
 
 public:
- task_base()
- : done_( false), prom_()
+ task_base() :
+ done_( false), prom_()
         {}
 
         virtual ~task_base() {}
@@ -107,8 +107,8 @@
         }
 
 public:
- task_wrapper( Fn const& fn)
- : task_base< R >(), fn_( fn)
+ task_wrapper( Fn const& fn) :
+ task_base< R >(), fn_( fn)
         {}
 };
 
@@ -166,8 +166,8 @@
         }
 
 public:
- task_wrapper( Fn const& fn)
- : task_base< void >(), fn_( fn)
+ task_wrapper( Fn const& fn) :
+ task_base< void >(), fn_( fn)
         {}
 };
 }
@@ -184,29 +184,29 @@
         task & operator=( task &);
 
 public:
- task()
- : task_()
+ task() :
+ task_()
         {}
 
- explicit task( R( * fn)())
- : task_( new detail::task_wrapper< R, R( *)() >( fn) )
+ explicit task( R( * fn)()) :
+ task_( new detail::task_wrapper< R, R( *)() >( fn) )
         {}
 
 # if defined(BOOST_HAS_RVALUE_REFS)
         template< typename Fn >
- task( Fn && fn)
- : task_( new detail::task_wrapper< R, Fn >( fn) )
+ task( Fn && fn) :
+ task_( new detail::task_wrapper< R, Fn >( fn) )
         {}
 
- task( task && other)
- : task_()
+ task( task && other) :
+ task_()
         { task_.swap( other.task_); }
 
         task & operator=( task && other)
         {
- task tmp( static_cast< task && >( other) );
- swap( tmp);
- return * this;
+ task tmp( static_cast< task && >( other) );
+ swap( tmp);
+ return * this;
         }
 
         task && move()
@@ -214,29 +214,31 @@
 # else
 #ifdef BOOST_NO_SFINAE
         template< typename Fn >
- explicit task( Fn fn)
- : task_( new detail::task_wrapper< R, Fn >( fn) )
+ explicit task( Fn fn) :
+ task_( new detail::task_wrapper< R, Fn >( fn) )
         {}
 #else
         template< typename Fn >
- explicit task( Fn fn, typename disable_if< boost::is_convertible< Fn &, boost::detail::thread_move_t< Fn > >, dummy * >::type = 0)
- : task_( new detail::task_wrapper< R, Fn >( fn) )
+ explicit task(
+ Fn fn,
+ typename disable_if< boost::is_convertible< Fn &, boost::detail::thread_move_t< Fn > >, dummy * >::type = 0) :
+ task_( new detail::task_wrapper< R, Fn >( fn) )
         {}
 #endif
         template< typename Fn >
- explicit task( boost::detail::thread_move_t< Fn > fn)
- : task_( new detail::task_wrapper< R, Fn >( fn) )
+ explicit task( boost::detail::thread_move_t< Fn > fn) :
+ task_( new detail::task_wrapper< R, Fn >( fn) )
         {}
 
- task( boost::detail::thread_move_t< task > other)
- : task_()
+ task( boost::detail::thread_move_t< task > other) :
+ task_()
         { task_.swap( other->task_); }
 
         task & operator=( boost::detail::thread_move_t< task > other)
         {
- task tmp( other);
- swap( tmp);
- return * this;
+ task tmp( other);
+ swap( tmp);
+ return * this;
         }
 
         operator boost::detail::thread_move_t< task >()

Modified: sandbox/task/boost/task/unbounded_buffer.hpp
==============================================================================
--- sandbox/task/boost/task/unbounded_buffer.hpp (original)
+++ sandbox/task/boost/task/unbounded_buffer.hpp 2009-10-16 17:38:53 EDT (Fri, 16 Oct 2009)
@@ -11,6 +11,7 @@
 
 #include <boost/assert.hpp>
 #include <boost/bind.hpp>
+#include <boost/cstdint.hpp>
 #include <boost/optional.hpp>
 #include <boost/shared_ptr.hpp>
 #include <boost/utility.hpp>
@@ -24,8 +25,9 @@
 
 #include <boost/config/abi_prefix.hpp>
 
-namespace boost { namespace task
-{
+namespace boost {
+namespace task {
+
 template< typename T >
 class unbounded_buffer
 {
@@ -41,6 +43,7 @@
                 spin_condition not_empty_cond_;
 
                 base( base &);
+
                 base & operator=( base const&);
 
                 bool active_() const
@@ -131,12 +134,11 @@
                 { return ! active_() || ! empty_(); }
 
         public:
- base()
- :
- state_( 0),
- queue_(),
- mtx_(),
- not_empty_cond_()
+ base() :
+ state_( 0),
+ queue_(),
+ mtx_(),
+ not_empty_cond_()
                 {}
 
                 bool active()
@@ -182,8 +184,8 @@
         shared_ptr< base > impl_;
 
 public:
- unbounded_buffer()
- : impl_( new base)
+ unbounded_buffer() :
+ impl_( new base)
         {}
 
         bool active()
@@ -208,8 +210,9 @@
         { return impl_->take( t, rel_time); }
 
         bool try_take( optional< T > & t)
- { return impl_->try_take_( t); }
+ { return impl_->try_take( t); }
 };
+
 }}
 
 #include <boost/config/abi_suffix.hpp>

Modified: sandbox/task/boost/task/unbounded_onelock_fifo.hpp
==============================================================================
--- sandbox/task/boost/task/unbounded_onelock_fifo.hpp (original)
+++ sandbox/task/boost/task/unbounded_onelock_fifo.hpp 2009-10-16 17:38:53 EDT (Fri, 16 Oct 2009)
@@ -24,8 +24,9 @@
 
 #include <boost/config/abi_prefix.hpp>
 
-namespace boost { namespace task
-{
+namespace boost {
+namespace task {
+
 class unbounded_onelock_fifo
 {
 public:
@@ -128,12 +129,11 @@
         { return ! active_() || ! empty_(); }
 
 public:
- unbounded_onelock_fifo()
- :
- state_( 0),
- queue_(),
- mtx_(),
- not_empty_cond_()
+ unbounded_onelock_fifo() :
+ state_( 0),
+ queue_(),
+ mtx_(),
+ not_empty_cond_()
         {}
 
         void deactivate()
@@ -172,7 +172,8 @@
                 return try_take_( va);
         }
 };
-} }
+
+}}
 
 #include <boost/config/abi_suffix.hpp>
 

Modified: sandbox/task/boost/task/unbounded_onelock_prio_queue.hpp
==============================================================================
--- sandbox/task/boost/task/unbounded_onelock_prio_queue.hpp (original)
+++ sandbox/task/boost/task/unbounded_onelock_prio_queue.hpp 2009-10-16 17:38:53 EDT (Fri, 16 Oct 2009)
@@ -26,8 +26,9 @@
 
 #include <boost/config/abi_prefix.hpp>
 
-namespace boost { namespace task
-{
+namespace boost {
+namespace task {
+
 template<
         typename Attr,
         typename Comp = std::less< Attr >
@@ -44,9 +45,9 @@
                 attribute_type attr;
 
                 value_type(
- callable const& ca_,
- attribute_type const& attr_)
- : ca( ca_), attr( attr_)
+ callable const& ca_,
+ attribute_type const& attr_) :
+ ca( ca_), attr( attr_)
                 { BOOST_ASSERT( ! ca.empty() ); }
 
                 void swap( value_type & other)
@@ -165,12 +166,11 @@
         { return ! active_() || ! empty_(); }
 
 public:
- unbounded_onelock_prio_queue()
- :
- state_( 0),
- queue_(),
- mtx_(),
- not_empty_cond_()
+ unbounded_onelock_prio_queue() :
+ state_( 0),
+ queue_(),
+ mtx_(),
+ not_empty_cond_()
         {}
 
         void deactivate()
@@ -209,7 +209,8 @@
                 return try_take_( ca);
         }
 };
-} }
+
+}}
 
 #include <boost/config/abi_suffix.hpp>
 

Modified: sandbox/task/boost/task/unbounded_onelock_smart_queue.hpp
==============================================================================
--- sandbox/task/boost/task/unbounded_onelock_smart_queue.hpp (original)
+++ sandbox/task/boost/task/unbounded_onelock_smart_queue.hpp 2009-10-16 17:38:53 EDT (Fri, 16 Oct 2009)
@@ -28,8 +28,9 @@
 
 #include <boost/config/abi_prefix.hpp>
 
-namespace boost { namespace task
-{
+namespace boost {
+namespace task {
+
 template<
         typename Attr,
         typename Comp,
@@ -48,9 +49,9 @@
                 attribute_type attr;
 
                 value_type(
- callable const& ca_,
- attribute_type const& attr_)
- : ca( ca_), attr( attr_)
+ callable const& ca_,
+ attribute_type const& attr_) :
+ ca( ca_), attr( attr_)
                 { BOOST_ASSERT( ! ca.empty() ); }
 
                 void swap( value_type & other)
@@ -86,7 +87,7 @@
 
         bool active_() const
         { return 0 == state_; }
-
+
         void deactivate_()
         { detail::atomic_fetch_add( & state_, 1); }
 
@@ -169,15 +170,14 @@
         { return ! active_() || ! empty_(); }
 
 public:
- unbounded_onelock_smart_queue()
- :
- state_( 0),
- queue_(),
- idx_( queue_.get< 0 >() ),
- mtx_(),
- not_empty_cond_(),
- enq_op_(),
- deq_op_()
+ unbounded_onelock_smart_queue() :
+ state_( 0),
+ queue_(),
+ idx_( queue_.get< 0 >() ),
+ mtx_(),
+ not_empty_cond_(),
+ enq_op_(),
+ deq_op_()
         {}
 
         void deactivate()
@@ -216,7 +216,8 @@
                 return try_take_( ca);
         }
 };
-} }
+
+}}
 
 #include <boost/config/abi_suffix.hpp>
 

Modified: sandbox/task/boost/task/unbounded_twolock_fifo.hpp
==============================================================================
--- sandbox/task/boost/task/unbounded_twolock_fifo.hpp (original)
+++ sandbox/task/boost/task/unbounded_twolock_fifo.hpp 2009-10-16 17:38:53 EDT (Fri, 16 Oct 2009)
@@ -11,6 +11,7 @@
 
 #include <boost/assert.hpp>
 #include <boost/bind.hpp>
+#include <boost/cstdint.hpp>
 #include <boost/foreach.hpp>
 #include <boost/thread/condition.hpp>
 #include <boost/thread/locks.hpp>
@@ -23,8 +24,9 @@
 
 #include <boost/config/abi_prefix.hpp>
 
-namespace boost { namespace task
-{
+namespace boost {
+namespace task {
+
 class unbounded_twolock_fifo
 {
 public:
@@ -71,14 +73,13 @@
         }
 
 public:
- unbounded_twolock_fifo()
- :
- state_( 0),
- head_( new node),
- head_mtx_(),
- tail_( head_),
- tail_mtx_(),
- not_empty_cond_()
+ unbounded_twolock_fifo() :
+ state_( 0),
+ head_( new node),
+ head_mtx_(),
+ tail_( head_),
+ tail_mtx_(),
+ not_empty_cond_()
         {}
 
         void deactivate()
@@ -87,7 +88,7 @@
         bool empty()
         {
                 unique_lock< mutex > lk( head_mtx_);
- return empty_();
+ return empty_();
         }
 
         void put( value_type const& va)
@@ -162,7 +163,8 @@
                 return ! va.empty();
         }
 };
-} }
+
+}}
 
 #include <boost/config/abi_suffix.hpp>
 

Modified: sandbox/task/boost/task/utility.hpp
==============================================================================
--- sandbox/task/boost/task/utility.hpp (original)
+++ sandbox/task/boost/task/utility.hpp 2009-10-16 17:38:53 EDT (Fri, 16 Oct 2009)
@@ -14,8 +14,9 @@
 
 #include <boost/config/abi_prefix.hpp>
 
-namespace boost { namespace this_task
-{
+namespace boost {
+namespace this_task {
+
 inline
 void block()
 {
@@ -35,6 +36,7 @@
         BOOST_ASSERT( w);
         return w->get_id();
 }
+
 }}
 
 #include <boost/config/abi_suffix.hpp>

Modified: sandbox/task/boost/task/watermark.hpp
==============================================================================
--- sandbox/task/boost/task/watermark.hpp (original)
+++ sandbox/task/boost/task/watermark.hpp 2009-10-16 17:38:53 EDT (Fri, 16 Oct 2009)
@@ -18,8 +18,9 @@
 # pragma warning(disable:4251 4275)
 # endif
 
-namespace boost { namespace task
-{
+namespace boost {
+namespace task {
+
 class BOOST_TASK_DECL high_watermark
 {
 private:
@@ -41,6 +42,7 @@
 
         operator std::size_t () const;
 };
+
 }}
 
 # if defined(BOOST_MSVC)

Modified: sandbox/task/libs/task/src/callable.cpp
==============================================================================
--- sandbox/task/libs/task/src/callable.cpp (original)
+++ sandbox/task/libs/task/src/callable.cpp 2009-10-16 17:38:53 EDT (Fri, 16 Oct 2009)
@@ -6,11 +6,11 @@
 
 #include "boost/task/callable.hpp"
 
-namespace boost { namespace task
-{
+namespace boost {
+namespace task {
 
-callable::callable()
-: impl_()
+callable::callable() :
+ impl_()
 {}
 
 void

Modified: sandbox/task/libs/task/src/context.cpp
==============================================================================
--- sandbox/task/libs/task/src/context.cpp (original)
+++ sandbox/task/libs/task/src/context.cpp 2009-10-16 17:38:53 EDT (Fri, 16 Oct 2009)
@@ -8,8 +8,8 @@
 
 #include <boost/assert.hpp>
 
-namespace boost { namespace task
-{
+namespace boost {
+namespace task {
 
 void
 context::impl::reset_( shared_ptr< thread > const& thrd)
@@ -30,11 +30,10 @@
         }
 }
 
-context::impl::impl()
-:
-requested_( false),
-mtx_(),
-thrd_()
+context::impl::impl() :
+ requested_( false),
+ mtx_(),
+ thrd_()
 {}
 
 void
@@ -58,8 +57,8 @@
         return requested_;
 }
 
-context::context()
-: impl_( new impl() )
+context::context() :
+ impl_( new impl() )
 {}
 
 void

Modified: sandbox/task/libs/task/src/guard.cpp
==============================================================================
--- sandbox/task/libs/task/src/guard.cpp (original)
+++ sandbox/task/libs/task/src/guard.cpp 2009-10-16 17:38:53 EDT (Fri, 16 Oct 2009)
@@ -10,12 +10,12 @@
 
 #include <boost/task/detail/atomic.hpp>
 
-namespace boost { namespace task {
-namespace detail
-{
+namespace boost {
+namespace task {
+namespace detail {
 
-guard::guard( volatile uint32_t & active_worker)
-: active_worker_( active_worker)
+guard::guard( volatile uint32_t & active_worker) :
+ active_worker_( active_worker)
 {
         BOOST_ASSERT( active_worker_ >= 0);
         atomic_fetch_add( & active_worker_, 1);

Modified: sandbox/task/libs/task/src/poolsize.cpp
==============================================================================
--- sandbox/task/libs/task/src/poolsize.cpp (original)
+++ sandbox/task/libs/task/src/poolsize.cpp 2009-10-16 17:38:53 EDT (Fri, 16 Oct 2009)
@@ -8,15 +8,15 @@
 
 #include <boost/task/exceptions.hpp>
 
-namespace boost { namespace task
-{
+namespace boost {
+namespace task {
 
-poolsize::poolsize( std::size_t value)
-: value_( value)
+poolsize::poolsize( std::size_t value) :
+ value_( value)
 { if ( value <= 0) throw invalid_poolsize(); }
 
 poolsize::operator std::size_t () const
 { return value_; }
 
-} }
+}}
 

Modified: sandbox/task/libs/task/src/scanns.cpp
==============================================================================
--- sandbox/task/libs/task/src/scanns.cpp (original)
+++ sandbox/task/libs/task/src/scanns.cpp 2009-10-16 17:38:53 EDT (Fri, 16 Oct 2009)
@@ -8,11 +8,11 @@
 
 #include <boost/task/exceptions.hpp>
 
-namespace boost { namespace task
-{
+namespace boost {
+namespace task {
 
-scanns::scanns( std::size_t value)
-: value_( value)
+scanns::scanns( std::size_t value) :
+ value_( value)
 { if ( value < 0) throw invalid_scanns(); }
 
 scanns::operator std::size_t () const

Modified: sandbox/task/libs/task/src/semaphore_posix.cpp
==============================================================================
--- sandbox/task/libs/task/src/semaphore_posix.cpp (original)
+++ sandbox/task/libs/task/src/semaphore_posix.cpp 2009-10-16 17:38:53 EDT (Fri, 16 Oct 2009)
@@ -15,11 +15,11 @@
 #include "boost/task/exceptions.hpp"
 #include "boost/task/utility.hpp"
 
-namespace boost { namespace task
-{
+namespace boost {
+namespace task {
 
-semaphore::semaphore( int value)
-: handle_()
+semaphore::semaphore( int value) :
+ handle_()
 {
         if ( ::sem_init( & handle_, 0, value) == -1)
                 throw system::system_error( errno, system::system_category);

Modified: sandbox/task/libs/task/src/semaphore_windows.cpp
==============================================================================
--- sandbox/task/libs/task/src/semaphore_windows.cpp (original)
+++ sandbox/task/libs/task/src/semaphore_windows.cpp 2009-10-16 17:38:53 EDT (Fri, 16 Oct 2009)
@@ -15,11 +15,11 @@
 #include "boost/task/exceptions.hpp"
 #include "boost/task/utility.hpp"
 
-namespace boost { namespace task
-{
+namespace boost {
+namespace task {
 
-semaphore::semaphore( int value)
-: handle_()
+semaphore::semaphore( int value) :
+ handle_()
 {
         if ( ( handle_ = ::CreateSemaphore( 0, value, (std::numeric_limits< int >::max)(), 0) ) == 0)
                 throw system::system_error( ::GetLastError(), system::system_category);

Modified: sandbox/task/libs/task/src/spin_auto_reset_event.cpp
==============================================================================
--- sandbox/task/libs/task/src/spin_auto_reset_event.cpp (original)
+++ sandbox/task/libs/task/src/spin_auto_reset_event.cpp 2009-10-16 17:38:53 EDT (Fri, 16 Oct 2009)
@@ -14,8 +14,8 @@
 namespace boost {
 namespace task {
 
-spin_auto_reset_event::spin_auto_reset_event( bool isset)
-: state_(
+spin_auto_reset_event::spin_auto_reset_event( bool isset) :
+ state_(
                 isset ?
                 static_cast< uint32_t >( SET) :
                 static_cast< uint32_t >( RESET) )

Modified: sandbox/task/libs/task/src/spin_condition.cpp
==============================================================================
--- sandbox/task/libs/task/src/spin_condition.cpp (original)
+++ sandbox/task/libs/task/src/spin_condition.cpp 2009-10-16 17:38:53 EDT (Fri, 16 Oct 2009)
@@ -177,12 +177,11 @@
         return ! timed_out;
 }
 
-spin_condition::spin_condition()
-:
-cmd_( static_cast< uint32_t >( SLEEPING) ),
-waiters_( 0),
-enter_mtx_(),
-check_mtx_()
+spin_condition::spin_condition() :
+ cmd_( static_cast< uint32_t >( SLEEPING) ),
+ waiters_( 0),
+ enter_mtx_(),
+ check_mtx_()
 {}
 
 void

Modified: sandbox/task/libs/task/src/spin_count_down_event.cpp
==============================================================================
--- sandbox/task/libs/task/src/spin_count_down_event.cpp (original)
+++ sandbox/task/libs/task/src/spin_count_down_event.cpp 2009-10-16 17:38:53 EDT (Fri, 16 Oct 2009)
@@ -16,10 +16,9 @@
 namespace boost {
 namespace task {
 
-spin_count_down_event::spin_count_down_event( uint32_t initial)
-:
-initial_( initial),
-current_( initial_)
+spin_count_down_event::spin_count_down_event( uint32_t initial) :
+ initial_( initial),
+ current_( initial_)
 {}
 
 uint32_t

Modified: sandbox/task/libs/task/src/spin_manual_reset_event.cpp
==============================================================================
--- sandbox/task/libs/task/src/spin_manual_reset_event.cpp (original)
+++ sandbox/task/libs/task/src/spin_manual_reset_event.cpp 2009-10-16 17:38:53 EDT (Fri, 16 Oct 2009)
@@ -16,14 +16,13 @@
 namespace boost {
 namespace task {
 
-spin_manual_reset_event::spin_manual_reset_event( bool isset)
-:
-state_(
- isset ?
- static_cast< uint32_t >( SET) :
- static_cast< uint32_t >( RESET) ),
-waiters_( 0),
-enter_mtx_()
+spin_manual_reset_event::spin_manual_reset_event( bool isset) :
+ state_(
+ isset ?
+ static_cast< uint32_t >( SET) :
+ static_cast< uint32_t >( RESET) ),
+ waiters_( 0),
+ enter_mtx_()
 {}
 
 void

Modified: sandbox/task/libs/task/src/spin_mutex.cpp
==============================================================================
--- sandbox/task/libs/task/src/spin_mutex.cpp (original)
+++ sandbox/task/libs/task/src/spin_mutex.cpp 2009-10-16 17:38:53 EDT (Fri, 16 Oct 2009)
@@ -14,8 +14,8 @@
 namespace boost {
 namespace task {
 
-spin_mutex::spin_mutex()
-: state_( 0)
+spin_mutex::spin_mutex() :
+ state_( 0)
 {}
 
 void

Modified: sandbox/task/libs/task/src/stacksize.cpp
==============================================================================
--- sandbox/task/libs/task/src/stacksize.cpp (original)
+++ sandbox/task/libs/task/src/stacksize.cpp 2009-10-16 17:38:53 EDT (Fri, 16 Oct 2009)
@@ -8,11 +8,11 @@
 
 #include <boost/task/exceptions.hpp>
 
-namespace boost { namespace task
-{
+namespace boost {
+namespace task {
 
-stacksize::stacksize( std::size_t value)
-: value_( value)
+stacksize::stacksize( std::size_t value) :
+ value_( value)
 { if ( value <= 0) throw invalid_stacksize(); }
 
 stacksize::operator std::size_t () const

Modified: sandbox/task/libs/task/src/watermark.cpp
==============================================================================
--- sandbox/task/libs/task/src/watermark.cpp (original)
+++ sandbox/task/libs/task/src/watermark.cpp 2009-10-16 17:38:53 EDT (Fri, 16 Oct 2009)
@@ -8,11 +8,11 @@
 
 #include <boost/task/exceptions.hpp>
 
-namespace boost { namespace task
-{
+namespace boost {
+namespace task {
 
-high_watermark::high_watermark( std::size_t value)
-: value_( value)
+high_watermark::high_watermark( std::size_t value) :
+ value_( value)
 {
         if ( value <= 0)
                 throw invalid_watermark("high watermark must be greater than zero");

Modified: sandbox/task/libs/task/src/worker.cpp
==============================================================================
--- sandbox/task/libs/task/src/worker.cpp (original)
+++ sandbox/task/libs/task/src/worker.cpp 2009-10-16 17:38:53 EDT (Fri, 16 Oct 2009)
@@ -6,9 +6,9 @@
 
 #include "boost/task/detail/worker.hpp"
 
-namespace boost { namespace task {
-namespace detail
-{
+namespace boost {
+namespace task {
+namespace detail {
 
 thread_specific_ptr< worker > worker::tss_;
 

Modified: sandbox/task/libs/task/src/worker_group.cpp
==============================================================================
--- sandbox/task/libs/task/src/worker_group.cpp (original)
+++ sandbox/task/libs/task/src/worker_group.cpp 2009-10-16 17:38:53 EDT (Fri, 16 Oct 2009)
@@ -9,15 +9,14 @@
 #include <boost/foreach.hpp>
 #include <boost/utility.hpp>
 
-namespace boost { namespace task {
-namespace detail
-{
-
-worker_group::worker_group()
-:
-cont_(),
-id_idx_( cont_.get< id_idx_tag >() ),
-rnd_idx_( cont_.get< rnd_idx_tag >() )
+namespace boost {
+namespace task {
+namespace detail {
+
+worker_group::worker_group() :
+ cont_(),
+ id_idx_( cont_.get< id_idx_tag >() ),
+ rnd_idx_( cont_.get< rnd_idx_tag >() )
 {}
 
 worker_group::~worker_group()

Modified: sandbox/task/libs/task/src/wsq.cpp
==============================================================================
--- sandbox/task/libs/task/src/wsq.cpp (original)
+++ sandbox/task/libs/task/src/wsq.cpp 2009-10-16 17:38:53 EDT (Fri, 16 Oct 2009)
@@ -10,19 +10,18 @@
 
 #include <boost/task/detail/atomic.hpp>
 
-namespace boost { namespace task {
-namespace detail
-{
-
-wsq::wsq()
-:
-initial_size_( 32),
-array_( new callable[ initial_size_]),
-capacity_( initial_size_),
-mask_( initial_size_ - 1),
-head_idx_( 0),
-tail_idx_( 0),
-mtx_()
+namespace boost {
+namespace task {
+namespace detail {
+
+wsq::wsq() :
+ initial_size_( 32),
+ array_( new callable[ initial_size_]),
+ capacity_( initial_size_),
+ mask_( initial_size_ - 1),
+ head_idx_( 0),
+ tail_idx_( 0),
+ mtx_()
 {}
 
 bool

Modified: sandbox/task/libs/task/test/Jamfile.v2
==============================================================================
--- sandbox/task/libs/task/test/Jamfile.v2 (original)
+++ sandbox/task/libs/task/test/Jamfile.v2 2009-10-16 17:38:53 EDT (Fri, 16 Oct 2009)
@@ -31,6 +31,7 @@
     [ task-test test_new_thread ]
     [ task-test test_unbounded_twolock_pool ]
     [ task-test test_unbounded_onelock_pool ]
+ [ task-test test_unbounded_onelock_pool_distrib ]
     [ task-test test_bounded_twolock_pool ]
     [ task-test test_bounded_onelock_pool ]
     [ task-test test_as_sub_task ]
@@ -45,4 +46,6 @@
     [ task-test test_spin_count_down_event ]
     [ task-test test_spin_auto_reset_event ]
     [ task-test test_spin_manual_reset_event ]
+ [ task-test test_unbounded_buffer ]
+ [ task-test test_bounded_buffer ]
     ;

Added: sandbox/task/libs/task/test/test_bounded_buffer.cpp
==============================================================================
--- (empty file)
+++ sandbox/task/libs/task/test/test_bounded_buffer.cpp 2009-10-16 17:38:53 EDT (Fri, 16 Oct 2009)
@@ -0,0 +1,171 @@
+
+// Copyright Oliver Kowalke 2009.
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <cstdlib>
+#include <iostream>
+#include <map>
+#include <stdexcept>
+#include <vector>
+
+#include <boost/bind.hpp>
+#include <boost/date_time/posix_time/posix_time.hpp>
+#include <boost/function.hpp>
+#include <boost/optional.hpp>
+#include <boost/ref.hpp>
+#include <boost/test/unit_test.hpp>
+#include <boost/thread.hpp>
+#include <boost/utility.hpp>
+
+#include <boost/task.hpp>
+
+namespace pt = boost::posix_time;
+namespace tsk = boost::task;
+
+struct send_data
+{
+ tsk::bounded_buffer< int > & buf;
+
+ send_data( tsk::bounded_buffer< int > & buf_) :
+ buf( buf_)
+ {}
+
+ void operator()( int value)
+ { buf.put( value); }
+};
+
+struct recv_data
+{
+ tsk::bounded_buffer< int > & buf;
+ int value;
+
+ recv_data( tsk::bounded_buffer< int > & buf_) :
+ buf( buf_), value( 0)
+ {}
+
+ void operator()( )
+ {
+ boost::optional< int > res;
+ if ( buf.take( res) )
+ value = * res;
+ }
+};
+
+void test_case_1()
+{
+ tsk::bounded_buffer< int > buf( tsk::high_watermark( 10), tsk::low_watermark( 10) );
+ BOOST_CHECK_EQUAL( true, buf.empty() );
+ BOOST_CHECK_EQUAL( true, buf.active() );
+ int n = 1;
+ buf.put( n);
+ BOOST_CHECK_EQUAL( false, buf.empty() );
+ boost::optional< int > res;
+ BOOST_CHECK_EQUAL( true, buf.take( res) );
+ BOOST_CHECK( res);
+ BOOST_CHECK_EQUAL( n, res.get() );
+ buf.deactivate();
+ BOOST_CHECK_EQUAL( false, buf.active() );
+ BOOST_CHECK_THROW( buf.put( 1), tsk::task_rejected);
+}
+
+void test_case_2()
+{
+ tsk::bounded_buffer< int > buf( tsk::high_watermark( 10), tsk::low_watermark( 10) );
+ BOOST_CHECK_EQUAL( true, buf.empty() );
+ BOOST_CHECK_EQUAL( true, buf.active() );
+ int n = 1;
+ buf.put( n);
+ BOOST_CHECK_EQUAL( false, buf.empty() );
+ boost::optional< int > res;
+ BOOST_CHECK_EQUAL( true, buf.try_take( res) );
+ BOOST_CHECK( res);
+ BOOST_CHECK_EQUAL( n, res.get() );
+ BOOST_CHECK_EQUAL( false, buf.try_take( res) );
+ BOOST_CHECK_EQUAL( false, buf.take( res, pt::milliseconds( 10) ) );
+}
+
+void test_case_3()
+{
+ tsk::static_pool<
+ tsk::unbounded_onelock_fifo
+ > pool( tsk::poolsize( 2) );
+
+ tsk::bounded_buffer< int > buf( tsk::high_watermark( 10), tsk::low_watermark( 10) );
+
+ int n = 37;
+
+ recv_data receiver( buf);
+ BOOST_CHECK_EQUAL( 0, receiver.value);
+ tsk::handle< void > h =
+ tsk::async(
+ tsk::make_task(
+ & recv_data::operator(),
+ boost::ref( receiver) ),
+ pool);
+
+ boost::this_thread::sleep(
+ pt::milliseconds( 250) );
+
+ BOOST_CHECK_EQUAL( false, h.is_ready() );
+ buf.put( n);
+
+ h.wait();
+
+ BOOST_CHECK_EQUAL( n, receiver.value);
+}
+
+void test_case_4()
+{
+ tsk::static_pool<
+ tsk::unbounded_onelock_fifo
+ > pool( tsk::poolsize( 2) );
+
+ tsk::bounded_buffer< int > buf( tsk::high_watermark( 10), tsk::low_watermark( 10) );
+
+ int n = 37;
+
+ send_data sender( buf);
+ recv_data receiver( buf);
+ BOOST_CHECK_EQUAL( 0, receiver.value);
+
+ tsk::handle< void > h1 =
+ tsk::async(
+ tsk::make_task(
+ & recv_data::operator(),
+ boost::ref( receiver) ),
+ pool);
+
+ boost::this_thread::sleep(
+ pt::milliseconds( 250) );
+ BOOST_CHECK_EQUAL( false, h1.is_ready() );
+
+ tsk::handle< void > h2 =
+ tsk::async(
+ tsk::make_task(
+ & send_data::operator(),
+ boost::ref( sender),
+ n),
+ pool);
+
+ h2.wait();
+ BOOST_CHECK_EQUAL( true, h2.is_ready() );
+ h1.wait();
+ BOOST_CHECK_EQUAL( true, h1.is_ready() );
+
+ BOOST_CHECK_EQUAL( n, receiver.value);
+}
+
+boost::unit_test::test_suite * init_unit_test_suite( int, char* [])
+{
+ boost::unit_test::test_suite * test =
+ BOOST_TEST_SUITE("Boost.Task: bounded-buffer test suite");
+
+ test->add( BOOST_TEST_CASE( & test_case_1) );
+ test->add( BOOST_TEST_CASE( & test_case_2) );
+ test->add( BOOST_TEST_CASE( & test_case_3) );
+ test->add( BOOST_TEST_CASE( & test_case_4) );
+
+ return test;
+}

Added: sandbox/task/libs/task/test/test_unbounded_buffer.cpp
==============================================================================
--- (empty file)
+++ sandbox/task/libs/task/test/test_unbounded_buffer.cpp 2009-10-16 17:38:53 EDT (Fri, 16 Oct 2009)
@@ -0,0 +1,171 @@
+
+// Copyright Oliver Kowalke 2009.
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <cstdlib>
+#include <iostream>
+#include <map>
+#include <stdexcept>
+#include <vector>
+
+#include <boost/bind.hpp>
+#include <boost/date_time/posix_time/posix_time.hpp>
+#include <boost/function.hpp>
+#include <boost/optional.hpp>
+#include <boost/ref.hpp>
+#include <boost/test/unit_test.hpp>
+#include <boost/thread.hpp>
+#include <boost/utility.hpp>
+
+#include <boost/task.hpp>
+
+namespace pt = boost::posix_time;
+namespace tsk = boost::task;
+
+struct send_data
+{
+ tsk::unbounded_buffer< int > & buf;
+
+ send_data( tsk::unbounded_buffer< int > & buf_) :
+ buf( buf_)
+ {}
+
+ void operator()( int value)
+ { buf.put( value); }
+};
+
+struct recv_data
+{
+ tsk::unbounded_buffer< int > & buf;
+ int value;
+
+ recv_data( tsk::unbounded_buffer< int > & buf_) :
+ buf( buf_), value( 0)
+ {}
+
+ void operator()( )
+ {
+ boost::optional< int > res;
+ if ( buf.take( res) )
+ value = * res;
+ }
+};
+
+void test_case_1()
+{
+ tsk::unbounded_buffer< int > buf;
+ BOOST_CHECK_EQUAL( true, buf.empty() );
+ BOOST_CHECK_EQUAL( true, buf.active() );
+ int n = 1;
+ buf.put( n);
+ BOOST_CHECK_EQUAL( false, buf.empty() );
+ boost::optional< int > res;
+ BOOST_CHECK_EQUAL( true, buf.take( res) );
+ BOOST_CHECK( res);
+ BOOST_CHECK_EQUAL( n, res.get() );
+ buf.deactivate();
+ BOOST_CHECK_EQUAL( false, buf.active() );
+ BOOST_CHECK_THROW( buf.put( 1), tsk::task_rejected);
+}
+
+void test_case_2()
+{
+ tsk::unbounded_buffer< int > buf;
+ BOOST_CHECK_EQUAL( true, buf.empty() );
+ BOOST_CHECK_EQUAL( true, buf.active() );
+ int n = 1;
+ buf.put( n);
+ BOOST_CHECK_EQUAL( false, buf.empty() );
+ boost::optional< int > res;
+ BOOST_CHECK_EQUAL( true, buf.try_take( res) );
+ BOOST_CHECK( res);
+ BOOST_CHECK_EQUAL( n, res.get() );
+ BOOST_CHECK_EQUAL( false, buf.try_take( res) );
+ BOOST_CHECK_EQUAL( false, buf.take( res, pt::milliseconds( 10) ) );
+}
+
+void test_case_3()
+{
+ tsk::static_pool<
+ tsk::unbounded_onelock_fifo
+ > pool( tsk::poolsize( 2) );
+
+ tsk::unbounded_buffer< int > buf;
+
+ int n = 37;
+
+ recv_data receiver( buf);
+ BOOST_CHECK_EQUAL( 0, receiver.value);
+ tsk::handle< void > h =
+ tsk::async(
+ tsk::make_task(
+ & recv_data::operator(),
+ boost::ref( receiver) ),
+ pool);
+
+ boost::this_thread::sleep(
+ pt::milliseconds( 250) );
+
+ BOOST_CHECK_EQUAL( false, h.is_ready() );
+ buf.put( n);
+
+ h.wait();
+
+ BOOST_CHECK_EQUAL( n, receiver.value);
+}
+
+void test_case_4()
+{
+ tsk::static_pool<
+ tsk::unbounded_onelock_fifo
+ > pool( tsk::poolsize( 2) );
+
+ tsk::unbounded_buffer< int > buf;
+
+ int n = 37;
+
+ send_data sender( buf);
+ recv_data receiver( buf);
+ BOOST_CHECK_EQUAL( 0, receiver.value);
+
+ tsk::handle< void > h1 =
+ tsk::async(
+ tsk::make_task(
+ & recv_data::operator(),
+ boost::ref( receiver) ),
+ pool);
+
+ boost::this_thread::sleep(
+ pt::milliseconds( 250) );
+ BOOST_CHECK_EQUAL( false, h1.is_ready() );
+
+ tsk::handle< void > h2 =
+ tsk::async(
+ tsk::make_task(
+ & send_data::operator(),
+ boost::ref( sender),
+ n),
+ pool);
+
+ h2.wait();
+ BOOST_CHECK_EQUAL( true, h2.is_ready() );
+ h1.wait();
+ BOOST_CHECK_EQUAL( true, h1.is_ready() );
+
+ BOOST_CHECK_EQUAL( n, receiver.value);
+}
+
+boost::unit_test::test_suite * init_unit_test_suite( int, char* [])
+{
+ boost::unit_test::test_suite * test =
+ BOOST_TEST_SUITE("Boost.Task: unbounded-buffer test suite");
+
+ test->add( BOOST_TEST_CASE( & test_case_1) );
+ test->add( BOOST_TEST_CASE( & test_case_2) );
+ test->add( BOOST_TEST_CASE( & test_case_3) );
+ test->add( BOOST_TEST_CASE( & test_case_4) );
+
+ return test;
+}

Added: sandbox/task/libs/task/test/test_unbounded_onelock_pool_distrib.cpp
==============================================================================
--- (empty file)
+++ sandbox/task/libs/task/test/test_unbounded_onelock_pool_distrib.cpp 2009-10-16 17:38:53 EDT (Fri, 16 Oct 2009)
@@ -0,0 +1,540 @@
+
+// Copyright Oliver Kowalke 2009.
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <cstdlib>
+#include <iostream>
+#include <map>
+#include <stdexcept>
+#include <vector>
+
+#include <boost/bind.hpp>
+#include <boost/date_time/posix_time/posix_time.hpp>
+#include <boost/function.hpp>
+#include <boost/ref.hpp>
+#include <boost/test/unit_test.hpp>
+#include <boost/thread.hpp>
+#include <boost/thread/barrier.hpp>
+#include <boost/type_traits/is_same.hpp>
+#include <boost/utility.hpp>
+
+#include <boost/task.hpp>
+
+#include "test_functions.hpp"
+
+namespace pt = boost::posix_time;
+namespace tsk = boost::task;
+
+namespace {
+
+// check size and move op
+void test_case_1()
+{
+ tsk::static_pool<
+ tsk::unbounded_onelock_fifo,
+ tsk::distrib_rr_ums
+ > pool1( tsk::poolsize( 3) );
+ BOOST_CHECK( pool1);
+ BOOST_CHECK_EQUAL( pool1.size(), std::size_t( 3) );
+
+ tsk::static_pool<
+ tsk::unbounded_onelock_fifo,
+ tsk::distrib_rr_ums
+ > pool2;
+ BOOST_CHECK( ! pool2);
+ BOOST_CHECK_THROW( pool2.size(), tsk::pool_moved);
+
+ pool2 = boost::move( pool1);
+
+ BOOST_CHECK( ! pool1);
+ BOOST_CHECK_THROW( pool1.size(), tsk::pool_moved);
+
+ BOOST_CHECK( pool2);
+ BOOST_CHECK_EQUAL( pool2.size(), std::size_t( 3) );
+
+ tsk::task< int > t( fibonacci_fn, 10);
+ tsk::handle< int > h(
+ tsk::async( boost::move( t), pool2) );
+ BOOST_CHECK_EQUAL( h.get(), 55);
+}
+
+// check submit
+void test_case_2()
+{
+ tsk::static_pool<
+ tsk::unbounded_onelock_fifo,
+ tsk::distrib_rr_ums
+ > pool( tsk::poolsize( 3) );
+ tsk::task< int > t( fibonacci_fn, 10);
+ tsk::handle< int > h(
+ tsk::async( boost::move( t), pool) );
+ BOOST_CHECK_EQUAL( h.get(), 55);
+}
+
+// check assignment
+void test_case_3()
+{
+ tsk::static_pool<
+ tsk::unbounded_onelock_fifo,
+ tsk::distrib_rr_ums
+ > pool( tsk::poolsize( 3) );
+ tsk::task< int > t( fibonacci_fn, 10);
+ tsk::handle< int > h1;
+ tsk::handle< int > h2(
+ tsk::async( boost::move( t), pool) );
+ h1 = h2;
+ BOOST_CHECK_EQUAL( h1.get(), 55);
+ BOOST_CHECK_EQUAL( h2.get(), 55);
+}
+
+// check swap
+void test_case_4()
+{
+ tsk::static_pool<
+ tsk::unbounded_onelock_fifo,
+ tsk::distrib_rr_ums
+ > pool( tsk::poolsize( 3) );
+ tsk::task< int > t1( fibonacci_fn, 5);
+ tsk::task< int > t2( fibonacci_fn, 10);
+ tsk::handle< int > h1(
+ tsk::async( boost::move( t1), pool) );
+ tsk::handle< int > h2(
+ tsk::async( boost::move( t2), pool) );
+ BOOST_CHECK_EQUAL( h1.get(), 5);
+ BOOST_CHECK_EQUAL( h2.get(), 55);
+ BOOST_CHECK_NO_THROW( h1.swap( h2) );
+ BOOST_CHECK_EQUAL( h1.get(), 55);
+ BOOST_CHECK_EQUAL( h2.get(), 5);
+}
+
+// check runs in pool
+void test_case_5()
+{
+ tsk::static_pool<
+ tsk::unbounded_onelock_fifo,
+ tsk::distrib_rr_ums
+ > pool( tsk::poolsize( 1) );
+ tsk::task< bool > t( runs_in_pool_fn);
+ tsk::handle< bool > h(
+ tsk::async( boost::move( t), pool) );
+ BOOST_CHECK_EQUAL( h.get(), true);
+}
+
+// check shutdown
+void test_case_6()
+{
+ tsk::static_pool<
+ tsk::unbounded_onelock_fifo,
+ tsk::distrib_rr_ums
+ > pool( tsk::poolsize( 1) );
+ tsk::task< int > t( fibonacci_fn, 10);
+ tsk::handle< int > h(
+ tsk::async( boost::move( t), pool) );
+ pool.shutdown();
+ BOOST_CHECK( pool.closed() );
+ BOOST_CHECK_EQUAL( h.get(), 55);
+}
+
+// check runtime_error throw inside task
+void test_case_7()
+{
+ tsk::static_pool<
+ tsk::unbounded_onelock_fifo,
+ tsk::distrib_rr_ums
+ > pool( tsk::poolsize( 1) );
+ tsk::task< void > t( throwing_fn);
+ tsk::handle< void > h(
+ tsk::async( boost::move( t), pool) );
+ pool.shutdown();
+ BOOST_CHECK_THROW( h.get(), std::runtime_error);
+}
+
+// check shutdown with task_rejected exception
+void test_case_8()
+{
+ tsk::static_pool<
+ tsk::unbounded_onelock_fifo,
+ tsk::distrib_rr_ums
+ > pool( tsk::poolsize( 1) );
+ tsk::task< int > t( fibonacci_fn, 10);
+ pool.shutdown();
+ BOOST_CHECK( pool.closed() );
+ BOOST_CHECK_THROW(
+ tsk::async( boost::move( t), pool),
+ tsk::task_rejected);
+}
+
+// check shutdown_now with thread_interrupted exception
+void test_case_9()
+{
+ tsk::static_pool<
+ tsk::unbounded_onelock_fifo,
+ tsk::distrib_rr_ums
+ > pool( tsk::poolsize( 1) );
+ tsk::task< void > t( delay_fn, pt::millisec( 500) );
+ tsk::handle< void > h(
+ tsk::async( boost::move( t), pool) );
+ boost::this_thread::sleep( pt::millisec( 250) );
+ BOOST_CHECK_EQUAL( pool.size(), std::size_t( 1) );
+ pool.shutdown_now();
+ BOOST_CHECK( pool.closed() );
+ BOOST_CHECK_EQUAL( pool.size(), std::size_t( 0) );
+ BOOST_CHECK_THROW( h.get(), tsk::task_interrupted);
+}
+
+// check wait
+void test_case_10()
+{
+ tsk::static_pool<
+ tsk::unbounded_onelock_fifo,
+ tsk::distrib_rr_ums
+ > pool( tsk::poolsize( 3) );
+ tsk::task< int > t( fibonacci_fn, 10);
+ tsk::handle< int > h(
+ tsk::async( boost::move( t), pool) );
+ h.wait();
+ BOOST_CHECK( h.is_ready() );
+ BOOST_CHECK( h.has_value() );
+ BOOST_CHECK( ! h.has_exception() );
+ BOOST_CHECK_EQUAL( h.get(), 55);
+}
+
+// check wait_for
+void test_case_11()
+{
+ tsk::static_pool<
+ tsk::unbounded_onelock_fifo,
+ tsk::distrib_rr_ums
+ > pool( tsk::poolsize( 3) );
+ tsk::task< void > t( delay_fn, pt::seconds( 1) );
+ tsk::handle< void > h(
+ tsk::async( boost::move( t), pool) );
+ BOOST_CHECK( h.wait_for( pt::seconds( 3) ) );
+ BOOST_CHECK( h.is_ready() );
+ BOOST_CHECK( h.has_value() );
+ BOOST_CHECK( ! h.has_exception() );
+}
+
+// check wait_for
+void test_case_12()
+{
+ tsk::static_pool<
+ tsk::unbounded_onelock_fifo,
+ tsk::distrib_rr_ums
+ > pool( tsk::poolsize( 3) );
+ tsk::task< void > t( delay_fn, pt::seconds( 3) );
+ tsk::handle< void > h(
+ tsk::async( boost::move( t), pool) );
+ BOOST_CHECK( ! h.wait_for( pt::seconds( 1) ) );
+ BOOST_CHECK( ! h.is_ready() );
+ BOOST_CHECK( ! h.has_value() );
+ BOOST_CHECK( ! h.has_exception() );
+}
+
+// check wait_until
+void test_case_13()
+{
+ tsk::static_pool<
+ tsk::unbounded_onelock_fifo,
+ tsk::distrib_rr_ums
+ > pool( tsk::poolsize( 3) );
+ tsk::task< void > t( delay_fn, pt::seconds( 1) );
+ tsk::handle< void > h(
+ tsk::async( boost::move( t), pool) );
+ BOOST_CHECK( h.wait_until( boost::get_system_time() + pt::seconds( 3) ) );
+ BOOST_CHECK( h.is_ready() );
+ BOOST_CHECK( h.has_value() );
+ BOOST_CHECK( ! h.has_exception() );
+}
+
+// check wait_until
+void test_case_14()
+{
+ tsk::static_pool<
+ tsk::unbounded_onelock_fifo,
+ tsk::distrib_rr_ums
+ > pool( tsk::poolsize( 3) );
+ tsk::task< void > t( delay_fn, pt::seconds( 3) );
+ tsk::handle< void > h(
+ tsk::async( boost::move( t), pool) );
+ BOOST_CHECK( ! h.wait_until( boost::get_system_time() + pt::seconds( 1) ) );
+ BOOST_CHECK( ! h.is_ready() );
+ BOOST_CHECK( ! h.has_value() );
+ BOOST_CHECK( ! h.has_exception() );
+}
+
+// check interrupt
+void test_case_15()
+{
+ tsk::static_pool<
+ tsk::unbounded_onelock_fifo,
+ tsk::distrib_rr_ums
+ > pool( tsk::poolsize( 3) );
+ tsk::task< void > t( delay_fn, pt::seconds( 3) );
+ tsk::handle< void > h(
+ tsk::async( boost::move( t), pool) );
+ h.interrupt();
+ BOOST_CHECK( h.interruption_requested() );
+ BOOST_CHECK_THROW( h.get(), tsk::task_interrupted);
+}
+
+// check interrupt_all_worker
+void test_case_16()
+{
+ tsk::static_pool<
+ tsk::unbounded_onelock_fifo,
+ tsk::distrib_rr_ums
+ > pool( tsk::poolsize( 5) );
+ tsk::task< void > t1( delay_fn, pt::seconds( 3) );
+ tsk::task< void > t2( delay_fn, pt::seconds( 3) );
+ tsk::task< void > t3( delay_fn, pt::seconds( 3) );
+ tsk::handle< void > h1(
+ tsk::async( boost::move( t1), pool) );
+ tsk::handle< void > h2(
+ tsk::async( boost::move( t2), pool) );
+ tsk::handle< void > h3(
+ tsk::async( boost::move( t3), pool) );
+ boost::this_thread::sleep( pt::millisec( 250) );
+ pool.interrupt_all_worker();
+ BOOST_CHECK( ! h1.interruption_requested() );
+ BOOST_CHECK( ! h2.interruption_requested() );
+ BOOST_CHECK( ! h3.interruption_requested() );
+ BOOST_CHECK_THROW( h1.get(), tsk::task_interrupted);
+ BOOST_CHECK_THROW( h2.get(), tsk::task_interrupted);
+ BOOST_CHECK_THROW( h3.get(), tsk::task_interrupted);
+ BOOST_CHECK_EQUAL( pool.size(), std::size_t( 5) );
+}
+
+// check interrupt_and_wait
+void test_case_17()
+{
+ tsk::static_pool<
+ tsk::unbounded_onelock_fifo,
+ tsk::distrib_rr_ums
+ > pool( tsk::poolsize( 3) );
+ bool finished( false);
+ tsk::task< void > t(
+ interrupt_fn,
+ pt::seconds( 1),
+ boost::ref( finished) );
+ tsk::handle< void > h(
+ tsk::async( boost::move( t), pool) );
+ h.interrupt_and_wait();
+ BOOST_CHECK( finished);
+ BOOST_CHECK( h.is_ready() );
+ BOOST_CHECK( ! h.has_value() );
+ BOOST_CHECK( h.has_exception() );
+ BOOST_CHECK( h.interruption_requested() );
+ BOOST_CHECK_THROW( h.get(), tsk::task_interrupted);
+}
+
+// check interrupt_and_wait_for
+void test_case_18()
+{
+ tsk::static_pool<
+ tsk::unbounded_onelock_fifo,
+ tsk::distrib_rr_ums
+ > pool( tsk::poolsize( 3) );
+ bool finished( false);
+ tsk::task< void > t(
+ interrupt_fn,
+ pt::seconds( 1),
+ boost::ref( finished) );
+ tsk::handle< void > h(
+ tsk::async( boost::move( t), pool) );
+ BOOST_CHECK( h.interrupt_and_wait_for( pt::seconds( 3) ) );
+ BOOST_CHECK( finished);
+ BOOST_CHECK( h.is_ready() );
+ BOOST_CHECK( ! h.has_value() );
+ BOOST_CHECK( h.has_exception() );
+ BOOST_CHECK( h.interruption_requested() );
+ BOOST_CHECK_THROW( h.get(), tsk::task_interrupted);
+}
+
+// check interrupt_and_wait_for
+void test_case_19()
+{
+ tsk::static_pool<
+ tsk::unbounded_onelock_fifo,
+ tsk::distrib_rr_ums
+ > pool( tsk::poolsize( 3) );
+ tsk::task< void > t( non_interrupt_fn, 3);
+ tsk::handle< void > h(
+ tsk::async( boost::move( t), pool) );
+ BOOST_CHECK( ! h.interrupt_and_wait_for( pt::seconds( 1) ) );
+}
+
+// check interrupt_and_wait_until
+void test_case_20()
+{
+ tsk::static_pool<
+ tsk::unbounded_onelock_fifo,
+ tsk::distrib_rr_ums
+ > pool( tsk::poolsize( 3) );
+ bool finished( false);
+ tsk::task< void > t(
+ interrupt_fn,
+ pt::seconds( 1),
+ boost::ref( finished) );
+ tsk::handle< void > h(
+ tsk::async( boost::move( t), pool) );
+ BOOST_CHECK( h.interrupt_and_wait_until( boost::get_system_time() + pt::seconds( 3) ) );
+ BOOST_CHECK( finished);
+ BOOST_CHECK( h.is_ready() );
+ BOOST_CHECK( ! h.has_value() );
+ BOOST_CHECK( h.has_exception() );
+ BOOST_CHECK( h.interruption_requested() );
+ BOOST_CHECK_THROW( h.get(), tsk::task_interrupted);
+}
+
+// check interrupt_and_wait_until
+void test_case_21()
+{
+ tsk::static_pool<
+ tsk::unbounded_onelock_fifo,
+ tsk::distrib_rr_ums
+ > pool( tsk::poolsize( 3) );
+ tsk::task< void > t( non_interrupt_fn, 3);
+ tsk::handle< void > h(
+ tsk::async( boost::move( t), pool) );
+ BOOST_CHECK( ! h.interrupt_and_wait_until( boost::get_system_time() + pt::seconds( 1) ) );
+}
+
+// check fifo scheduling
+void test_case_22()
+{
+ typedef tsk::static_pool<
+ tsk::unbounded_onelock_fifo,
+ tsk::distrib_rr_ums
+ > pool_type;
+ BOOST_CHECK( ! tsk::has_attribute< pool_type >::value);
+ pool_type pool( tsk::poolsize( 1) );
+ boost::barrier b( 2);
+ std::vector< int > buffer;
+ tsk::task< void > t1( barrier_fn, boost::ref( b) );
+ tsk::task< void > t2(
+ buffer_fibonacci_fn,
+ boost::ref( buffer),
+ 10);
+ tsk::task< void > t3(
+ buffer_fibonacci_fn,
+ boost::ref( buffer),
+ 0);
+ tsk::async( boost::move( t1), pool);
+ boost::this_thread::sleep( pt::millisec( 250) );
+ tsk::async( boost::move( t2), pool);
+ tsk::async( boost::move( t3), pool);
+ b.wait();
+ pool.shutdown();
+ BOOST_CHECK_EQUAL( buffer[0], 55);
+ BOOST_CHECK_EQUAL( buffer[1], 0);
+ BOOST_CHECK_EQUAL( buffer.size(), std::size_t( 2) );
+}
+
+// check priority scheduling
+void test_case_23()
+{
+ typedef tsk::static_pool<
+ tsk::unbounded_onelock_prio_queue< int >,
+ tsk::distrib_rr_ums
+ > pool_type;
+ BOOST_CHECK( tsk::has_attribute< pool_type >::value);
+ typedef boost::is_same< tsk::attribute_type< pool_type >::type, int > type;
+ BOOST_CHECK( type::value);
+ pool_type pool( tsk::poolsize( 1) );
+ boost::barrier b( 2);
+ std::vector< int > buffer;
+ tsk::task< void > t1( barrier_fn, boost::ref( b) );
+ tsk::task< void > t2(
+ buffer_fibonacci_fn,
+ boost::ref( buffer),
+ 10) ;
+ tsk::task< void > t3(
+ buffer_fibonacci_fn,
+ boost::ref( buffer),
+ 0);
+ tsk::async( boost::move( t1), 0, pool);
+ boost::this_thread::sleep( pt::millisec( 250) );
+ tsk::async( boost::move( t2), 1, pool);
+ tsk::async( boost::move( t3), 0, pool);
+ b.wait();
+ pool.shutdown();
+ BOOST_CHECK_EQUAL( buffer[0], 55);
+ BOOST_CHECK_EQUAL( buffer[1], 0);
+ BOOST_CHECK_EQUAL( buffer.size(), std::size_t( 2) );
+}
+
+// check smart scheduling
+void test_case_24()
+{
+ typedef tsk::static_pool<
+ tsk::unbounded_onelock_smart_queue< int, std::less< int > >,
+ tsk::distrib_rr_ums
+ > pool_type;
+ BOOST_CHECK( tsk::has_attribute< pool_type >::value);
+ typedef boost::is_same< tsk::attribute_type< pool_type >::type, int > type;
+ BOOST_CHECK( type::value);
+ pool_type pool( tsk::poolsize( 1) );
+ boost::barrier b( 2);
+ std::vector< int > buffer;
+ tsk::task< void > t1( barrier_fn, boost::ref( b) );
+ tsk::task< void > t2(
+ buffer_fibonacci_fn,
+ boost::ref( buffer),
+ 10);
+ tsk::task< void > t3(
+ buffer_fibonacci_fn,
+ boost::ref( buffer),
+ 0);
+ tsk::task< void > t4(
+ buffer_fibonacci_fn,
+ boost::ref( buffer),
+ 1);
+ pool.submit( boost::move( t1), 0);
+ boost::this_thread::sleep( pt::millisec( 250) );
+ tsk::async( boost::move( t2), 2, pool);
+ tsk::async( boost::move( t3), 1, pool);
+ tsk::async( boost::move( t4), 2, pool);
+ b.wait();
+ pool.shutdown();
+ BOOST_CHECK_EQUAL( buffer[0], 0);
+ BOOST_CHECK_EQUAL( buffer[1], 1);
+ BOOST_CHECK_EQUAL( buffer.size(), std::size_t( 2) );
+}
+
+}
+
+boost::unit_test::test_suite * init_unit_test_suite( int, char* [])
+{
+ boost::unit_test::test_suite * test =
+ BOOST_TEST_SUITE("Boost.Task: unbounded-onelock-pool test suite");
+
+ test->add( BOOST_TEST_CASE( & test_case_1) );
+ test->add( BOOST_TEST_CASE( & test_case_2) );
+ test->add( BOOST_TEST_CASE( & test_case_3) );
+ test->add( BOOST_TEST_CASE( & test_case_4) );
+ test->add( BOOST_TEST_CASE( & test_case_5) );
+ test->add( BOOST_TEST_CASE( & test_case_6) );
+ test->add( BOOST_TEST_CASE( & test_case_7) );
+ test->add( BOOST_TEST_CASE( & test_case_8) );
+ test->add( BOOST_TEST_CASE( & test_case_9) );
+ test->add( BOOST_TEST_CASE( & test_case_10) );
+ test->add( BOOST_TEST_CASE( & test_case_11) );
+ test->add( BOOST_TEST_CASE( & test_case_12) );
+ test->add( BOOST_TEST_CASE( & test_case_13) );
+ 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_18) );
+ test->add( BOOST_TEST_CASE( & test_case_19) );
+ test->add( BOOST_TEST_CASE( & test_case_20) );
+ test->add( BOOST_TEST_CASE( & test_case_21) );
+ test->add( BOOST_TEST_CASE( & test_case_22) );
+ test->add( BOOST_TEST_CASE( & test_case_23) );
+ test->add( BOOST_TEST_CASE( & test_case_24) );
+
+ 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