Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r53000 - in sandbox/task: boost boost/task libs/task/doc libs/task/examples libs/task/test
From: oliver.kowalke_at_[hidden]
Date: 2009-05-14 15:59:31


Author: olli
Date: 2009-05-14 15:59:27 EDT (Thu, 14 May 2009)
New Revision: 53000
URL: http://svn.boost.org/trac/boost/changeset/53000

Log:
* refactoring of class pool to class static_pool

Added:
   sandbox/task/boost/task/static_pool.hpp (contents, props changed)
Removed:
   sandbox/task/boost/task/pool.hpp
Text files modified:
   sandbox/task/boost/task.hpp | 2
   sandbox/task/boost/task/async.hpp | 6 ++--
   sandbox/task/boost/task/default_pool.hpp | 4 +-
   sandbox/task/boost/task/handle.hpp | 6 ++--
   sandbox/task/libs/task/doc/Jamfile.v2 | 15 ++++++------
   sandbox/task/libs/task/doc/boost_task.qbk | 37 ++++++++++++++++---------------
   sandbox/task/libs/task/doc/introduction.qbk | 18 +++++++++------
   sandbox/task/libs/task/doc/overview.qbk | 2
   sandbox/task/libs/task/doc/todo.qbk | 46 ++++++++++++++++++++++++++++-----------
   sandbox/task/libs/task/examples/bind_to_processors.cpp | 2
   sandbox/task/libs/task/examples/fork_join.cpp | 2
   sandbox/task/libs/task/examples/priority.cpp | 2
   sandbox/task/libs/task/examples/shutdonw_now.cpp | 2
   sandbox/task/libs/task/examples/smart.cpp | 2
   sandbox/task/libs/task/examples/submit.cpp | 2
   sandbox/task/libs/task/test/test_bounded_pool.cpp | 26 +++++++++++-----------
   sandbox/task/libs/task/test/test_unbounded_pool.cpp | 26 +++++++++++-----------
   17 files changed, 113 insertions(+), 87 deletions(-)

Modified: sandbox/task/boost/task.hpp
==============================================================================
--- sandbox/task/boost/task.hpp (original)
+++ sandbox/task/boost/task.hpp 2009-05-14 15:59:27 EDT (Thu, 14 May 2009)
@@ -16,11 +16,11 @@
 #include <boost/task/handle.hpp>
 #include <boost/task/id.hpp>
 #include <boost/task/info.hpp>
-#include <boost/task/pool.hpp>
 #include <boost/task/poolsize.hpp>
 #include <boost/task/priority.hpp>
 #include <boost/task/scanns.hpp>
 #include <boost/task/semaphore.hpp>
+#include <boost/task/static_pool.hpp>
 #include <boost/task/smart.hpp>
 #include <boost/task/task.hpp>
 #include <boost/task/unbounded_channel.hpp>

Modified: sandbox/task/boost/task/async.hpp
==============================================================================
--- sandbox/task/boost/task/async.hpp (original)
+++ sandbox/task/boost/task/async.hpp 2009-05-14 15:59:27 EDT (Thu, 14 May 2009)
@@ -19,7 +19,7 @@
 #include <boost/task/detail/worker.hpp>
 #include <boost/task/handle.hpp>
 #include <boost/task/future.hpp>
-#include <boost/task/pool.hpp>
+#include <boost/task/static_pool.hpp>
 #include <boost/task/task.hpp>
 
 namespace boost { namespace task
@@ -99,11 +99,11 @@
 { return fn( t); }
 
 template< typename R, typename Channel >
-handle< R > async( pool< Channel > & pool, task< R > t)
+handle< R > async( static_pool< Channel > & pool, task< R > t)
 { return pool.submit( t); }
 
 template< typename R, typename Channel, typename Attr >
-handle< R > async( pool< Channel > & pool, task< R > t, Attr attr)
+handle< R > async( static_pool< Channel > & pool, task< R > t, Attr attr)
 { return pool.submit( t, attr); }
 
 } }

Modified: sandbox/task/boost/task/default_pool.hpp
==============================================================================
--- sandbox/task/boost/task/default_pool.hpp (original)
+++ sandbox/task/boost/task/default_pool.hpp 2009-05-14 15:59:27 EDT (Thu, 14 May 2009)
@@ -9,14 +9,14 @@
 
 #include <boost/task/detail/config.hpp>
 #include <boost/task/fifo.hpp>
-#include <boost/task/pool.hpp>
+#include <boost/task/static_pool.hpp>
 #include <boost/task/unbounded_channel.hpp>
 
 #include <boost/config/abi_prefix.hpp>
 
 namespace boost { namespace task
 {
-typedef pool< unbounded_channel< fifo > > default_pool_t;
+typedef static_pool< unbounded_channel< fifo > > default_pool_t;
 
 namespace detail
 {

Modified: sandbox/task/boost/task/handle.hpp
==============================================================================
--- sandbox/task/boost/task/handle.hpp (original)
+++ sandbox/task/boost/task/handle.hpp 2009-05-14 15:59:27 EDT (Thu, 14 May 2009)
@@ -19,7 +19,7 @@
 {
 
 template< typename Channel >
-class pool;
+class static_pool;
 
 struct own_thread;
 struct new_thread;
@@ -30,7 +30,7 @@
 {
 private:
         template< typename Channel >
- friend class pool;
+ friend class static_pool;
         friend struct own_thread;
         friend struct new_thread;
         friend struct as_sub_task;
@@ -135,7 +135,7 @@
 {
 private:
         template< typename Channel >
- friend class pool;
+ friend class static_pool;
         friend struct own_thread;
         friend struct new_thread;
         friend struct as_sub_task;

Deleted: sandbox/task/boost/task/pool.hpp
==============================================================================
--- sandbox/task/boost/task/pool.hpp 2009-05-14 15:59:27 EDT (Thu, 14 May 2009)
+++ (empty file)
@@ -1,315 +0,0 @@
-
-// Copyright Oliver Kowalke 2009.
-// Distributed under the Boost Software License, Version 1.0.
-// (See accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-
-#ifndef BOOST_TASK_POOL_H
-#define BOOST_TASK_POOL_H
-
-#include <cstddef>
-#include <utility>
-#include <vector>
-
-#include <boost/assert.hpp>
-#include <boost/bind.hpp>
-#include <boost/cstdint.hpp>
-#include <boost/date_time/posix_time/posix_time.hpp>
-#include <boost/function.hpp>
-#include <boost/thread.hpp>
-#include <boost/utility.hpp>
-
-#include <boost/task/detail/atomic.hpp>
-#include <boost/task/detail/bind_processor.hpp>
-#include <boost/task/detail/interrupter.hpp>
-#include <boost/task/detail/pool_callable.hpp>
-#include <boost/task/detail/worker.hpp>
-#include <boost/task/detail/worker_group.hpp>
-#include <boost/task/exceptions.hpp>
-#include <boost/task/future.hpp>
-#include <boost/task/handle.hpp>
-#include <boost/task/poolsize.hpp>
-#include <boost/task/scanns.hpp>
-#include <boost/task/task.hpp>
-#include <boost/task/watermark.hpp>
-
-namespace boost { namespace task
-{
-template< typename Channel >
-class pool : private noncopyable
-{
-private:
- friend class detail::worker;
-
- typedef Channel channel;
- typedef typename channel::item channel_item;
-
- detail::worker_group wg_;
- shared_mutex mtx_wg_;
- volatile uint32_t state_;
- channel channel_;
- volatile uint32_t active_worker_;
- volatile uint32_t idle_worker_;
-
- void worker_entry_()
- {
- shared_lock< shared_mutex > lk( mtx_wg_);
- typename detail::worker_group::iterator i( wg_.find( this_thread::get_id() ) );
- lk.unlock();
- BOOST_ASSERT( i != wg_.end() );
-
- detail::worker w( * i);
- w.run();
- }
-
- void create_worker_(
- poolsize const& psize,
- posix_time::time_duration const& asleep,
- scanns const& max_scns)
- {
- wg_.insert(
- detail::worker(
- * this,
- psize,
- asleep,
- max_scns,
- boost::bind(
- & pool::worker_entry_,
- this) ) );
- }
-
-#ifdef BOOST_HAS_PROCESSOR_BINDINGS
- void worker_entry_( std::size_t n)
- {
- this_thread::bind_to_processor( n);
- worker_entry_();
- }
-
- void create_worker_(
- poolsize const& psize,
- posix_time::time_duration const& asleep,
- scanns const& max_scns,
- std::size_t n)
- {
- wg_.insert(
- detail::worker(
- * this,
- psize,
- asleep,
- max_scns,
- boost::bind(
- & pool::worker_entry_,
- this,
- n) ) );
- }
-#endif
-
- std::size_t active_() const
- { return active_worker_; }
-
- std::size_t idle_() const
- { return size_() - active_(); }
-
- std::size_t size_() const
- { return wg_.size(); }
-
- bool closed_() const
- { return state_ > 0; }
-
- unsigned int close_()
- { return detail::atomic_fetch_add( & state_, 1); }
-
-public:
- explicit pool(
- poolsize const& psize,
- posix_time::time_duration const& asleep = posix_time::microseconds( 10),
- scanns const& max_scns = scanns( 20) )
- :
- wg_(),
- mtx_wg_(),
- state_( 0),
- channel_(),
- active_worker_( 0),
- idle_worker_( 0)
- {
- if ( asleep.is_special() || asleep.is_negative() )
- throw invalid_timeduration();
- channel_.activate();
- unique_lock< shared_mutex > lk( mtx_wg_);
- for ( std::size_t i( 0); i < psize; ++i)
- create_worker_( psize, asleep, max_scns);
- lk.unlock();
- }
-
- explicit 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) )
- :
- wg_(),
- mtx_wg_(),
- state_( 0),
- channel_(
- hwm,
- lwm),
- active_worker_( 0),
- idle_worker_( 0)
- {
- if ( asleep.is_special() || asleep.is_negative() )
- throw invalid_timeduration();
- channel_.activate();
- unique_lock< shared_mutex > lk( mtx_wg_);
- for ( std::size_t i( 0); i < psize; ++i)
- create_worker_( psize, asleep, max_scns);
- lk.unlock();
- }
-
-#ifdef BOOST_HAS_PROCESSOR_BINDINGS
- explicit pool(
- posix_time::time_duration const& asleep = posix_time::microseconds( 10),
- scanns const& max_scns = scanns( 20) )
- :
- wg_(),
- mtx_wg_(),
- state_( 0),
- channel_(),
- active_worker_( 0),
- idle_worker_( 0)
- {
- if ( asleep.is_special() || asleep.is_negative() )
- throw invalid_timeduration();
- poolsize psize( thread::hardware_concurrency() );
- BOOST_ASSERT( psize > 0);
- channel_.activate();
- unique_lock< shared_mutex > lk( mtx_wg_);
- for ( std::size_t i( 0); i < psize; ++i)
- create_worker_( psize, asleep, max_scns, i);
- lk.unlock();
- }
-
- explicit pool(
- high_watermark const& hwm,
- low_watermark const& lwm,
- posix_time::time_duration const& asleep = posix_time::microseconds( 100),
- scanns const& max_scns = scanns( 20) )
- :
- wg_(),
- mtx_wg_(),
- state_( 0),
- channel_(
- hwm,
- lwm),
- active_worker_( 0),
- idle_worker_( 0)
- {
- if ( asleep.is_special() || asleep.is_negative() )
- throw invalid_timeduration();
- poolsize psize( thread::hardware_concurrency() );
- BOOST_ASSERT( psize > 0);
- channel_.activate();
- unique_lock< shared_mutex > lk( mtx_wg_);
- for ( std::size_t i( 0); i < psize; ++i)
- create_worker_( psize, asleep, max_scns, i);
- lk.unlock();
- }
-#endif
-
- ~pool()
- { shutdown(); }
-
- std::size_t active()
- {
- shared_lock< shared_mutex > lk( mtx_wg_);
- return active_();
- }
-
- std::size_t idle()
- {
- shared_lock< shared_mutex > lk( mtx_wg_);
- return idle_();
- }
-
- void shutdown()
- {
- if ( closed_() || close_() > 1) return;
-
- channel_.deactivate();
- shared_lock< shared_mutex > lk( mtx_wg_);
- wg_.signal_shutdown_all();
- wg_.join_all();
- lk.unlock();
- }
-
- const void shutdown_now()
- {
- if ( closed_() || close_() > 1) return;
-
- channel_.deactivate_now();
- shared_lock< shared_mutex > lk( mtx_wg_);
- wg_.signal_shutdown_now_all();
- wg_.interrupt_all();
- wg_.join_all();
- lk.unlock();
- }
-
- std::size_t size()
- {
- shared_lock< shared_mutex > lk( mtx_wg_);
- return size_();
- }
-
- bool closed()
- { return closed_(); }
-
- void clear()
- { channel_.clear(); }
-
- bool empty()
- { return channel_.empty(); }
-
- std::size_t pending()
- { return channel_.size(); }
-
- std::size_t upper_bound()
- { return channel_.upper_bound(); }
-
- void upper_bound( high_watermark const& hwm)
- { return channel_.upper_bound( hwm); }
-
- std::size_t lower_bound()
- { return channel_.lower_bound(); }
-
- void lower_bound( low_watermark const lwm)
- { return channel_.lower_bound( lwm); }
-
- template< typename R >
- handle< R > submit( task< R > t)
- {
- if ( closed_() )
- throw task_rejected("pool is closed");
-
- detail::interrupter intr;
- channel_.put( detail::pool_callable( t, intr) );
- return handle< R >( t.get_id(), t.get_future(), intr);
- }
-
- template<
- typename R,
- typename Attr
- >
- handle< R > submit( task< R > t, Attr const& attr)
- {
- if ( closed_() )
- throw task_rejected("pool is closed");
-
- detail::interrupter intr;
- channel_.put( channel_item( detail::pool_callable( t, intr), attr) );
- return handle< R >( t.get_id(), t.get_future(), intr);
- }
-};
-}}
-
-#endif // BOOST_TASK_POOL_H
-

Added: sandbox/task/boost/task/static_pool.hpp
==============================================================================
--- (empty file)
+++ sandbox/task/boost/task/static_pool.hpp 2009-05-14 15:59:27 EDT (Thu, 14 May 2009)
@@ -0,0 +1,315 @@
+
+// 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_STATIC_POOL_H
+#define BOOST_TASK_STATIC_POOL_H
+
+#include <cstddef>
+#include <utility>
+#include <vector>
+
+#include <boost/assert.hpp>
+#include <boost/bind.hpp>
+#include <boost/cstdint.hpp>
+#include <boost/date_time/posix_time/posix_time.hpp>
+#include <boost/function.hpp>
+#include <boost/thread.hpp>
+#include <boost/utility.hpp>
+
+#include <boost/task/detail/atomic.hpp>
+#include <boost/task/detail/bind_processor.hpp>
+#include <boost/task/detail/interrupter.hpp>
+#include <boost/task/detail/pool_callable.hpp>
+#include <boost/task/detail/worker.hpp>
+#include <boost/task/detail/worker_group.hpp>
+#include <boost/task/exceptions.hpp>
+#include <boost/task/future.hpp>
+#include <boost/task/handle.hpp>
+#include <boost/task/poolsize.hpp>
+#include <boost/task/scanns.hpp>
+#include <boost/task/task.hpp>
+#include <boost/task/watermark.hpp>
+
+namespace boost { namespace task
+{
+template< typename Channel >
+class static_pool : private noncopyable
+{
+private:
+ friend class detail::worker;
+
+ typedef Channel channel;
+ typedef typename channel::item channel_item;
+
+ detail::worker_group wg_;
+ shared_mutex mtx_wg_;
+ volatile uint32_t state_;
+ channel channel_;
+ volatile uint32_t active_worker_;
+ volatile uint32_t idle_worker_;
+
+ void worker_entry_()
+ {
+ shared_lock< shared_mutex > lk( mtx_wg_);
+ typename detail::worker_group::iterator i( wg_.find( this_thread::get_id() ) );
+ lk.unlock();
+ BOOST_ASSERT( i != wg_.end() );
+
+ detail::worker w( * i);
+ w.run();
+ }
+
+ void create_worker_(
+ poolsize const& psize,
+ posix_time::time_duration const& asleep,
+ scanns const& max_scns)
+ {
+ wg_.insert(
+ detail::worker(
+ * this,
+ psize,
+ asleep,
+ max_scns,
+ boost::bind(
+ & static_pool::worker_entry_,
+ this) ) );
+ }
+
+#ifdef BOOST_HAS_PROCESSOR_BINDINGS
+ void worker_entry_( std::size_t n)
+ {
+ this_thread::bind_to_processor( n);
+ worker_entry_();
+ }
+
+ void create_worker_(
+ poolsize const& psize,
+ posix_time::time_duration const& asleep,
+ scanns const& max_scns,
+ std::size_t n)
+ {
+ wg_.insert(
+ detail::worker(
+ * this,
+ psize,
+ asleep,
+ max_scns,
+ boost::bind(
+ & static_pool::worker_entry_,
+ this,
+ n) ) );
+ }
+#endif
+
+ std::size_t active_() const
+ { return active_worker_; }
+
+ std::size_t idle_() const
+ { return size_() - active_(); }
+
+ std::size_t size_() const
+ { return wg_.size(); }
+
+ bool closed_() const
+ { return state_ > 0; }
+
+ unsigned int close_()
+ { return detail::atomic_fetch_add( & state_, 1); }
+
+public:
+ explicit static_pool(
+ poolsize const& psize,
+ posix_time::time_duration const& asleep = posix_time::microseconds( 10),
+ scanns const& max_scns = scanns( 20) )
+ :
+ wg_(),
+ mtx_wg_(),
+ state_( 0),
+ channel_(),
+ active_worker_( 0),
+ idle_worker_( 0)
+ {
+ if ( asleep.is_special() || asleep.is_negative() )
+ throw invalid_timeduration();
+ channel_.activate();
+ unique_lock< shared_mutex > lk( mtx_wg_);
+ for ( std::size_t i( 0); i < psize; ++i)
+ create_worker_( psize, asleep, max_scns);
+ lk.unlock();
+ }
+
+ 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) )
+ :
+ wg_(),
+ mtx_wg_(),
+ state_( 0),
+ channel_(
+ hwm,
+ lwm),
+ active_worker_( 0),
+ idle_worker_( 0)
+ {
+ if ( asleep.is_special() || asleep.is_negative() )
+ throw invalid_timeduration();
+ channel_.activate();
+ unique_lock< shared_mutex > lk( mtx_wg_);
+ for ( std::size_t i( 0); i < psize; ++i)
+ create_worker_( psize, asleep, max_scns);
+ lk.unlock();
+ }
+
+#ifdef BOOST_HAS_PROCESSOR_BINDINGS
+ explicit static_pool(
+ posix_time::time_duration const& asleep = posix_time::microseconds( 10),
+ scanns const& max_scns = scanns( 20) )
+ :
+ wg_(),
+ mtx_wg_(),
+ state_( 0),
+ channel_(),
+ active_worker_( 0),
+ idle_worker_( 0)
+ {
+ if ( asleep.is_special() || asleep.is_negative() )
+ throw invalid_timeduration();
+ poolsize psize( thread::hardware_concurrency() );
+ BOOST_ASSERT( psize > 0);
+ channel_.activate();
+ unique_lock< shared_mutex > lk( mtx_wg_);
+ for ( std::size_t i( 0); i < psize; ++i)
+ create_worker_( psize, asleep, max_scns, i);
+ lk.unlock();
+ }
+
+ explicit static_pool(
+ high_watermark const& hwm,
+ low_watermark const& lwm,
+ posix_time::time_duration const& asleep = posix_time::microseconds( 100),
+ scanns const& max_scns = scanns( 20) )
+ :
+ wg_(),
+ mtx_wg_(),
+ state_( 0),
+ channel_(
+ hwm,
+ lwm),
+ active_worker_( 0),
+ idle_worker_( 0)
+ {
+ if ( asleep.is_special() || asleep.is_negative() )
+ throw invalid_timeduration();
+ poolsize psize( thread::hardware_concurrency() );
+ BOOST_ASSERT( psize > 0);
+ channel_.activate();
+ unique_lock< shared_mutex > lk( mtx_wg_);
+ for ( std::size_t i( 0); i < psize; ++i)
+ create_worker_( psize, asleep, max_scns, i);
+ lk.unlock();
+ }
+#endif
+
+ ~static_pool()
+ { shutdown(); }
+
+ std::size_t active()
+ {
+ shared_lock< shared_mutex > lk( mtx_wg_);
+ return active_();
+ }
+
+ std::size_t idle()
+ {
+ shared_lock< shared_mutex > lk( mtx_wg_);
+ return idle_();
+ }
+
+ void shutdown()
+ {
+ if ( closed_() || close_() > 1) return;
+
+ channel_.deactivate();
+ shared_lock< shared_mutex > lk( mtx_wg_);
+ wg_.signal_shutdown_all();
+ wg_.join_all();
+ lk.unlock();
+ }
+
+ const void shutdown_now()
+ {
+ if ( closed_() || close_() > 1) return;
+
+ channel_.deactivate_now();
+ shared_lock< shared_mutex > lk( mtx_wg_);
+ wg_.signal_shutdown_now_all();
+ wg_.interrupt_all();
+ wg_.join_all();
+ lk.unlock();
+ }
+
+ std::size_t size()
+ {
+ shared_lock< shared_mutex > lk( mtx_wg_);
+ return size_();
+ }
+
+ bool closed()
+ { return closed_(); }
+
+ void clear()
+ { channel_.clear(); }
+
+ bool empty()
+ { return channel_.empty(); }
+
+ std::size_t pending()
+ { return channel_.size(); }
+
+ std::size_t upper_bound()
+ { return channel_.upper_bound(); }
+
+ void upper_bound( high_watermark const& hwm)
+ { return channel_.upper_bound( hwm); }
+
+ std::size_t lower_bound()
+ { return channel_.lower_bound(); }
+
+ void lower_bound( low_watermark const lwm)
+ { return channel_.lower_bound( lwm); }
+
+ template< typename R >
+ handle< R > submit( task< R > t)
+ {
+ if ( closed_() )
+ throw task_rejected("pool is closed");
+
+ detail::interrupter intr;
+ channel_.put( detail::pool_callable( t, intr) );
+ return handle< R >( t.get_id(), t.get_future(), intr);
+ }
+
+ template<
+ typename R,
+ typename Attr
+ >
+ handle< R > submit( task< R > t, Attr const& attr)
+ {
+ if ( closed_() )
+ throw task_rejected("pool is closed");
+
+ detail::interrupter intr;
+ channel_.put( channel_item( detail::pool_callable( t, intr), attr) );
+ return handle< R >( t.get_id(), t.get_future(), intr);
+ }
+};
+}}
+
+#endif // BOOST_TASK_STATIC_POOL_H
+

Modified: sandbox/task/libs/task/doc/Jamfile.v2
==============================================================================
--- sandbox/task/libs/task/doc/Jamfile.v2 (original)
+++ sandbox/task/libs/task/doc/Jamfile.v2 2009-05-14 15:59:27 EDT (Thu, 14 May 2009)
@@ -1,11 +1,12 @@
-# Boost.Task Library Documentation Jamfile
+# Boost.ThreadPool Library Documentation Jamfile
 
-# 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
+# Copyright (C) 2008 Oliver Kowalke
+
+# Use, modification and distribution is subject to 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)
 
 using quickbook ;
 
-xml task : boost_task.qbk ;
-boostbook standalone : task ;
+xml threadpool : threadpool.qbk ;
+boostbook standalone : threadpool ;

Modified: sandbox/task/libs/task/doc/boost_task.qbk
==============================================================================
--- sandbox/task/libs/task/doc/boost_task.qbk (original)
+++ sandbox/task/libs/task/doc/boost_task.qbk 2009-05-14 15:59:27 EDT (Thu, 14 May 2009)
@@ -35,6 +35,7 @@
 
 [def __as_sub_task__ `as_sub_task`]
 [def __bounded_channel__ `bounded_channel`]
+[def __default_pool__ `default_pool`]
 [def __duration__ `Duration`]
 [def __handle__ `handle`]
 [def __new_thread__ `new_thread`]
@@ -43,24 +44,24 @@
 [def __system_time__ `system_time`]
 [def __unbounded_channel__ `unbounded_channel`]
 
-[def __async__ `async()`]
-[def __default_pool__ `default_pool()`]
-[def __delay__ `delay()`]
-[def __get__ `get()`]
-[def __get_id__ `get_id()`]
-[def __get_pool__ `get_pool()`]
-[def __has_value__ `has_value()`]
-[def __has_exception__ `has_exception()`]
-[def __interrupt__ `interrupt()`]
-[def __interrupt_and_wait__ `interrupt_and_wait()`]
-[def __interruption_requested__ `interruption_requested()`]
-[def __is_ready__ `is_ready()`]
-[def __make_task__ `make_task()`]
-[def __reschedule_until__ `reschedule_until()`]
-[def __runs_in_pool__ `runs_in_pool()`]
-[def __wait__ `wait()`]
-[def __worker_id__ `worker_id()`]
-[def __yield__ `yield()`]
+[def __fn_async__ `async()`]
+[def __fn_default__pool__ `default_pool()`]
+[def __fn_delay__ `delay()`]
+[def __fn_get__ `get()`]
+[def __fn_get_id__ `get_id()`]
+[def __fn_get_pool__ `get_pool()`]
+[def __fn_has_value__ `has_value()`]
+[def __fn_has_exception__ `has_exception()`]
+[def __fn_interrupt__ `interrupt()`]
+[def __fn_interrupt_and_wait__ `interrupt_and_wait()`]
+[def __fn_interruption_requested__ `interruption_requested()`]
+[def __fn_is_ready__ `is_ready()`]
+[def __fn_make_task__ `make_task()`]
+[def __fn_reschedule_until__ `reschedule_until()`]
+[def __fn_runs_in_pool__ `runs_in_pool()`]
+[def __fn_wait__ `wait()`]
+[def __fn_worker_id__ `worker_id()`]
+[def __fn_yield__ `yield()`]
 
 [def __act__ `asynchronous-completion-token`]
 [def __ae__ `asynchronous-executor`]

Modified: sandbox/task/libs/task/doc/introduction.qbk
==============================================================================
--- sandbox/task/libs/task/doc/introduction.qbk (original)
+++ sandbox/task/libs/task/doc/introduction.qbk 2009-05-14 15:59:27 EDT (Thu, 14 May 2009)
@@ -8,14 +8,18 @@
 
 [section:motivation Motivation]
 
-In order to take advantage of the technological evolution from single-core to many-core architectures multi-core machines,
-partitioning the compute bound work into smaller chunks that can run in parallel is required.
-The code can scale as the hardware gets better without changing the code (achieving desired load balancing).
+To speed-up computer-bound work and/or increase the computation-throughput is a common motivation for parallelizing a program.
+Especially for interactive applications that have to process user input while perfoming some background tasks responsivness
+is very important.
+The ongoing evolution of many-core architectures support this naturaly by requiring partitioning the program into smaller chunks that can run in parallel.
+The code can scale as the hardware gets better without changing the code (and achieving desired load balancing).
+
+[note
+ ["You can have multithreading on a single core machine, but you can only have parallelism on a multi core machine ... .
+ [footnote more to read at [@http://www.danielmoth.com/Blog/2008/11/threadingconcurrency-vs-parallelism.html]] ] -- Daniel Moth
+]
 
-[note Equating multithreading to parallelism is not accurate. You can have multithreading on a single-core machine,
-but you can only have parallelism on a multi-core machine (portions of your code that can truly run at the same time).]
-
-__boost_task__ provides a framework to utilize the available hardware and provide a way for efficient asynchronous processing of time consuming operations in the same process.
+__boost_task__ provides a framework to utilize the available hardware and provide a way for efficient asynchronous processing of time consuming operations.
 
 The framework provides some __aes__, like __new_thread__, in order to launch __task__ in a new thread:
 

Modified: sandbox/task/libs/task/doc/overview.qbk
==============================================================================
--- sandbox/task/libs/task/doc/overview.qbk (original)
+++ sandbox/task/libs/task/doc/overview.qbk 2009-05-14 15:59:27 EDT (Thu, 14 May 2009)
@@ -10,7 +10,7 @@
 
 [heading Description]
 
-__boost_task__ provides an abstraction for parallel execution of tasks - a task is a small unit of code that can be executed independently.
+__boost_task__ provides an abstraction for parallel execution of tasks (a task is a small unit of code that can be executed independently).
 
 * __task__, representing fine-grained work-item:
         * get_id() returning an identifier

Modified: sandbox/task/libs/task/doc/todo.qbk
==============================================================================
--- sandbox/task/libs/task/doc/todo.qbk (original)
+++ sandbox/task/libs/task/doc/todo.qbk 2009-05-14 15:59:27 EDT (Thu, 14 May 2009)
@@ -8,23 +8,43 @@
 
 [section:todo Appendix C: Future development]
 
-[heading Event variable]
-A event variable is a bivalued variable (up/down) on which a task can wait for an event to be set or reset. The calling task will be suspended until the state of the event variable is that required by the caller.
 
-[heading Buffer]
-A bounded/unbounded buffer is shared between several tasks. The data must be placed in, and retrieved from, the buffer under mutual exclusion.
-Condition synchronisation is required because a calling task attempting to place data into the buffer. Whne the buffer is full, must be suspended until there is space int the buffer. Also a retrieving task must be suspended when the buffer is empty. The data, once read, is destroyed.
+[heading Concurrency and communication mechanisms]
 
-[heading Multicast]
-The data is sent to a specific group of tasks and all tasks in the group should receive the data. Only when all tasks have received one item of data then another item is allowed to be transmitted.
+* Event variable: A event variable is a bivalued variable (up/down) on which a task can wait for an event to be set or reset. The calling task will be suspended until the state of the event variable is that required by the caller.
 
-[heading Rendezvous]
-A rendezvous uses direct naming and synchronous communication between tasks. One task that executes its command first will be delayed until the other tasks is ready to rendezvous.
+* Buffer: A bounded/unbounded buffer is shared between several tasks. The data must be placed in, and retrieved from, the buffer under mutual exclusion.
+Condition synchronisation is required because a calling task attempting to place data into the buffer. When the buffer is full, the task must be suspended until there is space int the buffer.
+Also a retrieving task must be suspended when the buffer is empty. The data, once read, is destroyed.
 
-[heading Protected resource]
-A protected resource is a passive entity that controls access to the internal states (to the controled real resources).
+* Multicast: The data is sent to a specific group of tasks and all tasks in the group should receive the data. Only when all tasks have received one item of data then another item is allowed to be transmitted.
+
+* Rendezvous: A rendezvous uses direct naming and synchronous communication between tasks. One task that executes its command first will be delayed until the other tasks is ready to rendezvous.
+
+* Protected resource: A protected resource is a passive entity that controls access to the internal states (to the controled real resources).
+
+* Task groups: A task group defines a graph of interdependent tasks that can mostly be run in parallel. The tasks in the group have dependencies or communicate with each other.
+
+[heading Support of explicit processor bindig]
+__aes__ related to a __thread_pool__ (like __default__threadpool__) could support explicit processor binding.
+
+The framework supports the possibility of an __ae__ executing the submitted task in an new spawned process or a pool of processes.
+__handle__ is still capable to manage the task inside the spawned process (works as a __act__ too).
+
+[heading Interdepended task]
+
+[heading Actor framework]
+
+- Microsoft's terminology: is ['agents]
+- if the solution can be modeled in terms of interactive components
+- coordinate parallel (interdepended) tasks
+- 'disciplined' access to shared state that prevents common programming errors
+
+[heading Optimizations]
+
+* two-lock-queue as global queue
+
+* maybe lock-free-queue as global queue too (how to provide the scheduling policies fifo, priority, smart?)
 
-[heading Task groups]
-A task group defines a graph of inter-dependent tasks that can mostly be run in parallel. THe tasks in the group have dependencies or communicate with each other.
 
 [endsect]

Modified: sandbox/task/libs/task/examples/bind_to_processors.cpp
==============================================================================
--- sandbox/task/libs/task/examples/bind_to_processors.cpp (original)
+++ sandbox/task/libs/task/examples/bind_to_processors.cpp 2009-05-14 15:59:27 EDT (Thu, 14 May 2009)
@@ -18,7 +18,7 @@
 namespace pt = boost::posix_time;
 namespace tsk = boost::task;
 
-typedef tsk::pool< tsk::unbounded_channel< tsk::fifo > > pool_type;
+typedef tsk::static_pool< tsk::unbounded_channel< tsk::fifo > > pool_type;
 
 long serial_fib( long n)
 {

Modified: sandbox/task/libs/task/examples/fork_join.cpp
==============================================================================
--- sandbox/task/libs/task/examples/fork_join.cpp (original)
+++ sandbox/task/libs/task/examples/fork_join.cpp 2009-05-14 15:59:27 EDT (Thu, 14 May 2009)
@@ -17,7 +17,7 @@
 namespace pt = boost::posix_time;
 namespace tsk = boost::task;
 
-typedef tsk::pool< tsk::unbounded_channel< tsk::fifo > > pool_type;
+typedef tsk::static_pool< tsk::unbounded_channel< tsk::fifo > > pool_type;
 
 long serial_fib( long n)
 {

Modified: sandbox/task/libs/task/examples/priority.cpp
==============================================================================
--- sandbox/task/libs/task/examples/priority.cpp (original)
+++ sandbox/task/libs/task/examples/priority.cpp 2009-05-14 15:59:27 EDT (Thu, 14 May 2009)
@@ -29,7 +29,7 @@
 {
         try
         {
- tsk::pool<
+ tsk::static_pool<
                         tsk::unbounded_channel< tsk::priority< int > >
> pool( tsk::poolsize( 1) );
 

Modified: sandbox/task/libs/task/examples/shutdonw_now.cpp
==============================================================================
--- sandbox/task/libs/task/examples/shutdonw_now.cpp (original)
+++ sandbox/task/libs/task/examples/shutdonw_now.cpp 2009-05-14 15:59:27 EDT (Thu, 14 May 2009)
@@ -40,7 +40,7 @@
 {
         try
         {
- tsk::pool<
+ tsk::static_pool<
                         tsk::unbounded_channel< tsk::fifo >
> pool( tsk::poolsize( 1) );
 

Modified: sandbox/task/libs/task/examples/smart.cpp
==============================================================================
--- sandbox/task/libs/task/examples/smart.cpp (original)
+++ sandbox/task/libs/task/examples/smart.cpp 2009-05-14 15:59:27 EDT (Thu, 14 May 2009)
@@ -48,7 +48,7 @@
 {
         try
         {
- tsk::pool<
+ tsk::static_pool<
                         tsk::unbounded_channel<
                                 tsk::smart<
                                         int,

Modified: sandbox/task/libs/task/examples/submit.cpp
==============================================================================
--- sandbox/task/libs/task/examples/submit.cpp (original)
+++ sandbox/task/libs/task/examples/submit.cpp 2009-05-14 15:59:27 EDT (Thu, 14 May 2009)
@@ -53,7 +53,7 @@
                                 tsk::make_task(
                                         fibonacci_fn,
                                         10) ) );
- tsk::pool<
+ tsk::static_pool<
                         tsk::unbounded_channel< tsk::priority< int > >
> pool( tsk::poolsize( 3) );
                 tsk::handle< int > h4(

Modified: sandbox/task/libs/task/test/test_bounded_pool.cpp
==============================================================================
--- sandbox/task/libs/task/test/test_bounded_pool.cpp (original)
+++ sandbox/task/libs/task/test/test_bounded_pool.cpp 2009-05-14 15:59:27 EDT (Thu, 14 May 2009)
@@ -32,7 +32,7 @@
         // check size, active, idle
         void test_case_1()
         {
- tsk::pool<
+ tsk::static_pool<
                         tsk::bounded_channel< tsk::fifo >
> pool(
                         tsk::poolsize( 3),
@@ -46,7 +46,7 @@
         // check submit
         void test_case_2()
         {
- tsk::pool<
+ tsk::static_pool<
                         tsk::bounded_channel< tsk::fifo >
> pool(
                         tsk::poolsize( 1),
@@ -64,7 +64,7 @@
         // check runs in pool
         void test_case_3()
         {
- tsk::pool<
+ tsk::static_pool<
                         tsk::bounded_channel< tsk::fifo >
> pool(
                         tsk::poolsize( 1),
@@ -81,7 +81,7 @@
         // executed twice
         void test_case_4()
         {
- tsk::pool<
+ tsk::static_pool<
                         tsk::bounded_channel< tsk::fifo >
> pool(
                         tsk::poolsize( 1),
@@ -106,7 +106,7 @@
         // check shutdown
         void test_case_5()
         {
- tsk::pool<
+ tsk::static_pool<
                         tsk::bounded_channel< tsk::fifo >
> pool(
                         tsk::poolsize( 1),
@@ -126,7 +126,7 @@
         // check runtime_error throw inside task
         void test_case_6()
         {
- tsk::pool<
+ tsk::static_pool<
                         tsk::bounded_channel< tsk::fifo >
> pool(
                         tsk::poolsize( 1),
@@ -149,7 +149,7 @@
         // check shutdown with task_rejected exception
         void test_case_7()
         {
- tsk::pool<
+ tsk::static_pool<
                         tsk::bounded_channel< tsk::fifo >
> pool(
                         tsk::poolsize( 1),
@@ -175,7 +175,7 @@
         // check shutdown_now with thread_interrupted exception
         void test_case_8()
         {
- tsk::pool<
+ tsk::static_pool<
                         tsk::bounded_channel< tsk::fifo >
> pool(
                         tsk::poolsize( 1),
@@ -205,7 +205,7 @@
         // check pending
         void test_case_9()
         {
- typedef tsk::pool<
+ typedef tsk::static_pool<
                         tsk::bounded_channel< tsk::fifo >
> pool_type;
                 pool_type pool(
@@ -247,7 +247,7 @@
         // check interruption
         void test_case_10()
         {
- typedef tsk::pool<
+ typedef tsk::static_pool<
                         tsk::bounded_channel< tsk::fifo >
> pool_type;
                 pool_type pool(
@@ -290,7 +290,7 @@
         // check fifo scheduling
         void test_case_11()
         {
- typedef tsk::pool<
+ typedef tsk::static_pool<
                         tsk::bounded_channel< tsk::fifo >
> pool_type;
                 pool_type pool(
@@ -326,7 +326,7 @@
         // check priority scheduling
         void test_case_12()
         {
- typedef tsk::pool<
+ typedef tsk::static_pool<
                         tsk::bounded_channel< tsk::priority< int > >
> pool_type;
                 pool_type pool(
@@ -365,7 +365,7 @@
         // check smart scheduling
         void test_case_13()
         {
- typedef tsk::pool<
+ typedef tsk::static_pool<
                         tsk::bounded_channel< tsk::smart< int, std::less< int >, tsk::replace_oldest, tsk::take_oldest > >
> pool_type;
                 pool_type pool(

Modified: sandbox/task/libs/task/test/test_unbounded_pool.cpp
==============================================================================
--- sandbox/task/libs/task/test/test_unbounded_pool.cpp (original)
+++ sandbox/task/libs/task/test/test_unbounded_pool.cpp 2009-05-14 15:59:27 EDT (Thu, 14 May 2009)
@@ -32,7 +32,7 @@
         // check size, active, idle
         void test_case_1()
         {
- tsk::pool<
+ tsk::static_pool<
                         tsk::unbounded_channel< tsk::fifo >
> pool( tsk::poolsize( 3) );
                 BOOST_CHECK_EQUAL( pool.size(), std::size_t( 3) );
@@ -43,7 +43,7 @@
         // check submit
         void test_case_2()
         {
- tsk::pool<
+ tsk::static_pool<
                         tsk::unbounded_channel< tsk::fifo >
> pool( tsk::poolsize( 1) );
                 tsk::handle< int > h(
@@ -58,7 +58,7 @@
         // check runs in pool
         void test_case_3()
         {
- tsk::pool<
+ tsk::static_pool<
                         tsk::unbounded_channel< tsk::fifo >
> pool( tsk::poolsize( 1) );
                 tsk::handle< bool > h(
@@ -72,7 +72,7 @@
         // executed twice
         void test_case_4()
         {
- tsk::pool<
+ tsk::static_pool<
                         tsk::unbounded_channel< tsk::fifo >
> pool( tsk::poolsize( 1) );
                 tsk::task< int > t(
@@ -94,7 +94,7 @@
         // check shutdown
         void test_case_5()
         {
- tsk::pool<
+ tsk::static_pool<
                         tsk::unbounded_channel< tsk::fifo >
> pool( tsk::poolsize( 1) );
                 tsk::handle< int > h(
@@ -111,7 +111,7 @@
         // check runtime_error throw inside task
         void test_case_6()
         {
- tsk::pool<
+ tsk::static_pool<
                         tsk::unbounded_channel< tsk::fifo >
> pool( tsk::poolsize( 1) );
                 tsk::handle< void > h(
@@ -131,7 +131,7 @@
         // check shutdown with task_rejected exception
         void test_case_7()
         {
- tsk::pool<
+ tsk::static_pool<
                         tsk::unbounded_channel< tsk::fifo >
> pool( tsk::poolsize( 1) );
                 pool.shutdown();
@@ -154,7 +154,7 @@
         // check shutdown_now with thread_interrupted exception
         void test_case_8()
         {
- tsk::pool<
+ tsk::static_pool<
                         tsk::unbounded_channel< tsk::fifo >
> pool( tsk::poolsize( 1) );
                 tsk::handle< void > h(
@@ -181,7 +181,7 @@
         // check pending
         void test_case_9()
         {
- typedef tsk::pool<
+ typedef tsk::static_pool<
                         tsk::unbounded_channel< tsk::fifo >
> pool_type;
                 pool_type pool( tsk::poolsize( 1) );
@@ -220,7 +220,7 @@
         // check interruptation
         void test_case_10()
         {
- typedef tsk::pool<
+ typedef tsk::static_pool<
                         tsk::unbounded_channel< tsk::fifo >
> pool_type;
                 pool_type pool( tsk::poolsize( 1) );
@@ -259,7 +259,7 @@
         // check fifo scheduling
         void test_case_11()
         {
- typedef tsk::pool<
+ typedef tsk::static_pool<
                         tsk::unbounded_channel< tsk::fifo >
> pool_type;
                 pool_type pool( tsk::poolsize( 1) );
@@ -292,7 +292,7 @@
         // check priority scheduling
         void test_case_12()
         {
- typedef tsk::pool<
+ typedef tsk::static_pool<
                         tsk::unbounded_channel< tsk::priority< int > >
> pool_type;
                 pool_type pool( tsk::poolsize( 1) );
@@ -328,7 +328,7 @@
         // check smart scheduling
         void test_case_13()
         {
- typedef tsk::pool<
+ typedef tsk::static_pool<
                         tsk::unbounded_channel< tsk::smart< int, std::less< int >, tsk::replace_oldest, tsk::take_oldest > >
> pool_type;
                 pool_type pool( tsk::poolsize( 1) );


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