|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r51582 - in sandbox/threadpool: boost boost/tp boost/tp/detail libs/tp/build libs/tp/doc libs/tp/doc/html libs/tp/doc/html/boost_threadpool libs/tp/examples libs/tp/src
From: oliver.kowalke_at_[hidden]
Date: 2009-03-03 16:18:37
Author: olli
Date: 2009-03-03 16:18:34 EST (Tue, 03 Mar 2009)
New Revision: 51582
URL: http://svn.boost.org/trac/boost/changeset/51582
Log:
* default-pool and get_default_pool() added
* documentation changed
Added:
sandbox/threadpool/boost/tp/default_pool.hpp (contents, props changed)
sandbox/threadpool/libs/tp/build/Jamfile.v2 (contents, props changed)
sandbox/threadpool/libs/tp/examples/parallel_sort.cpp (contents, props changed)
sandbox/threadpool/libs/tp/src/callable.cpp (contents, props changed)
sandbox/threadpool/libs/tp/src/default_pool.cpp (contents, props changed)
sandbox/threadpool/libs/tp/src/guard.cpp (contents, props changed)
sandbox/threadpool/libs/tp/src/interrupter.cpp (contents, props changed)
sandbox/threadpool/libs/tp/src/poolsize.cpp (contents, props changed)
sandbox/threadpool/libs/tp/src/scanns.cpp (contents, props changed)
sandbox/threadpool/libs/tp/src/watermark.cpp (contents, props changed)
Text files modified:
sandbox/threadpool/boost/future.hpp | 5
sandbox/threadpool/boost/tp/detail/callable.hpp | 13 -
sandbox/threadpool/boost/tp/detail/guard.hpp | 13 --
sandbox/threadpool/boost/tp/detail/interrupter.hpp | 87 +++---------------
sandbox/threadpool/boost/tp/pool.hpp | 10 --
sandbox/threadpool/boost/tp/poolsize.hpp | 7 -
sandbox/threadpool/boost/tp/scanns.hpp | 7 -
sandbox/threadpool/boost/tp/watermark.hpp | 20 ---
sandbox/threadpool/libs/tp/doc/acknowledgement.qbk | 2
sandbox/threadpool/libs/tp/doc/html/boost_threadpool/acknowledgement.html | 5
sandbox/threadpool/libs/tp/doc/html/boost_threadpool/channel.html | 4
sandbox/threadpool/libs/tp/doc/html/boost_threadpool/pool.html | 22 +++-
sandbox/threadpool/libs/tp/doc/html/boost_threadpool/reference.html | 133 ++++++++++++++++------------
sandbox/threadpool/libs/tp/doc/html/boost_threadpool/scheduling.html | 8
sandbox/threadpool/libs/tp/doc/html/boost_threadpool/task.html | 4
sandbox/threadpool/libs/tp/doc/html/index.html | 27 -----
sandbox/threadpool/libs/tp/doc/introduction.qbk | 9 -
sandbox/threadpool/libs/tp/doc/pool.qbk | 6 +
sandbox/threadpool/libs/tp/doc/pool_ref.qbk | 11 ++
sandbox/threadpool/libs/tp/doc/threadpool.xml | 184 +++++++++++++++++++++------------------
20 files changed, 256 insertions(+), 321 deletions(-)
Modified: sandbox/threadpool/boost/future.hpp
==============================================================================
--- sandbox/threadpool/boost/future.hpp (original)
+++ sandbox/threadpool/boost/future.hpp 2009-03-03 16:18:34 EST (Tue, 03 Mar 2009)
@@ -1406,7 +1406,10 @@
}
};
-
+
+ template< typename T >
+ detail::thread_move_t< packaged_task< T > > move( packaged_task< T > & t)
+ { return detail::thread_move_t< packaged_task< T > >( t); }
}
#undef CATCH_ENABLE_CURRENT_EXCEPTION
Added: sandbox/threadpool/boost/tp/default_pool.hpp
==============================================================================
--- (empty file)
+++ sandbox/threadpool/boost/tp/default_pool.hpp 2009-03-03 16:18:34 EST (Tue, 03 Mar 2009)
@@ -0,0 +1,27 @@
+// Copyright (c) 2008 Oliver Kowalke. 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_TP_DEFAULT_POOL_H
+#define BOOST_TP_DEFAULT_POOL_H
+
+#include <boost/tp/fifo.hpp>
+#include <boost/tp/pool.hpp>
+#include <boost/tp/unbounded_channel.hpp>
+
+namespace boost { namespace tp
+{
+typedef pool< unbounded_channel< fifo > > default_pool;
+
+namespace detail
+{
+struct static_pool
+{ static default_pool instance; };
+}
+
+inline
+default_pool & get_default_pool()
+{ return detail::static_pool::instance; }
+} }
+
+#endif // BOOST_TP_DEFAULT_POOL_H
Modified: sandbox/threadpool/boost/tp/detail/callable.hpp
==============================================================================
--- sandbox/threadpool/boost/tp/detail/callable.hpp (original)
+++ sandbox/threadpool/boost/tp/detail/callable.hpp 2009-03-03 16:18:34 EST (Tue, 03 Mar 2009)
@@ -38,23 +38,18 @@
boost::shared_ptr< impl > impl_;
public:
- callable()
- : impl_()
- {}
+ callable();
template< typename T >
callable( boost::detail::thread_move_t< packaged_task< T > > const& t)
: impl_( new impl_wrapper< T >( t) )
{}
- void operator()()
- { impl_->run(); }
+ void operator()();
- bool empty() const
- { return ! impl_; }
+ bool empty() const;
- void clear()
- { impl_.reset(); }
+ void clear();
};
} } }
Modified: sandbox/threadpool/boost/tp/detail/guard.hpp
==============================================================================
--- sandbox/threadpool/boost/tp/detail/guard.hpp (original)
+++ sandbox/threadpool/boost/tp/detail/guard.hpp 2009-03-03 16:18:34 EST (Tue, 03 Mar 2009)
@@ -19,18 +19,9 @@
volatile uint32_t & active_worker_;
public:
- guard( volatile uint32_t & active_worker)
- : active_worker_( active_worker)
- {
- BOOST_ASSERT( active_worker_ >= 0);
- interprocess::detail::atomic_inc32( & active_worker_);
- }
+ guard( volatile uint32_t & active_worker);
- ~guard()
- {
- interprocess::detail::atomic_dec32( & active_worker_);
- BOOST_ASSERT( active_worker_ >= 0);
- }
+ ~guard();
};
} } }
Modified: sandbox/threadpool/boost/tp/detail/interrupter.hpp
==============================================================================
--- sandbox/threadpool/boost/tp/detail/interrupter.hpp (original)
+++ sandbox/threadpool/boost/tp/detail/interrupter.hpp 2009-03-03 16:18:34 EST (Tue, 03 Mar 2009)
@@ -28,65 +28,20 @@
mutex mtx_;
shared_ptr< thread > thrd_;
- void interrupt_()
- {
- if ( ! interruption_requested_)
- {
- interruption_requested_ = true;
- if ( thrd_) thrd_->interrupt();
- }
- }
+ void interrupt_();
public:
- impl()
- :
- interruption_requested_( false),
- cond_(),
- mtx_(),
- thrd_()
- {}
+ impl();
- void set( shared_ptr< thread > const& thrd)
- {
- BOOST_ASSERT( thrd);
- unique_lock< mutex > lk( mtx_);
- thrd_ = thrd;
- BOOST_ASSERT( thrd_);
- if ( interruption_requested_) thrd_->interrupt();
- }
+ void set( shared_ptr< thread > const& thrd);
- void reset()
- {
- unique_lock< mutex > lk( mtx_);
- thrd_.reset();
- BOOST_ASSERT( ! thrd_);
- try
- { this_thread::interruption_point(); }
- catch ( thread_interrupted const&)
- {}
- BOOST_ASSERT( ! this_thread::interruption_requested() );
- cond_.notify_all();
- }
+ void reset();
- void interrupt()
- {
- unique_lock< mutex > lk( mtx_);
- interrupt_();
- }
+ void interrupt();
- void interrupt_and_wait()
- {
- unique_lock< mutex > lk( mtx_);
- interrupt_();
- cond_.wait( lk);
- }
+ void interrupt_and_wait();
- void interrupt_and_wait( system_time const& abs_time)
- {
- unique_lock< mutex > lk( mtx_);
- interrupt_();
- cond_.timed_wait( lk, abs_time);
- }
+ void interrupt_and_wait( system_time const& abs_time);
template< typename DurationType >
void interrupt_and_wait( DurationType const& rel_time)
@@ -96,41 +51,29 @@
cond_.timed_wait( lk, rel_time);
}
- bool interruption_requested()
- {
- unique_lock< mutex > lk( mtx_);
- return interruption_requested_;
- }
+ bool interruption_requested();
};
shared_ptr< impl > impl_;
public:
- interrupter()
- : impl_( new impl() )
- {}
+ interrupter();
- void set( shared_ptr< thread > const& thrd)
- { impl_->set( thrd); }
+ void set( shared_ptr< thread > const& thrd);
- void reset()
- { impl_->reset(); }
+ void reset();
- void interrupt()
- { impl_->interrupt(); }
+ void interrupt();
- void interrupt_and_wait()
- { impl_->interrupt_and_wait(); }
+ void interrupt_and_wait();
- void interrupt_and_wait( system_time const& abs_time)
- { impl_->interrupt_and_wait( abs_time); }
+ void interrupt_and_wait( system_time const& abs_time);
template< typename DurationType >
void interrupt_and_wait( DurationType const& rel_time)
{ impl_->interrupt_and_wait( rel_time); }
- bool interruption_requested()
- { return impl_->interruption_requested(); }
+ bool interruption_requested();
};
}
} }
Modified: sandbox/threadpool/boost/tp/pool.hpp
==============================================================================
--- sandbox/threadpool/boost/tp/pool.hpp (original)
+++ sandbox/threadpool/boost/tp/pool.hpp 2009-03-03 16:18:34 EST (Tue, 03 Mar 2009)
@@ -47,16 +47,6 @@
#include <boost/tp/task.hpp>
#include <boost/tp/watermark.hpp>
-// workaround until boost::move is fixed by Anthony Williams
-namespace boost
-{
- template< typename T >
- detail::thread_move_t< packaged_task< T > > move( packaged_task< T > & t)
- {
- return detail::thread_move_t< packaged_task< T > >( t);
- }
-}
-
namespace boost {
namespace this_task
Modified: sandbox/threadpool/boost/tp/poolsize.hpp
==============================================================================
--- sandbox/threadpool/boost/tp/poolsize.hpp (original)
+++ sandbox/threadpool/boost/tp/poolsize.hpp 2009-03-03 16:18:34 EST (Tue, 03 Mar 2009)
@@ -17,12 +17,9 @@
std::size_t value_;
public:
- explicit poolsize( std::size_t value)
- : value_( value)
- { if ( value <= 0) throw invalid_poolsize("core poolsize must be greater than zero"); }
+ explicit poolsize( std::size_t value);
- operator std::size_t () const
- { return value_; }
+ operator std::size_t () const;
};
} }
Modified: sandbox/threadpool/boost/tp/scanns.hpp
==============================================================================
--- sandbox/threadpool/boost/tp/scanns.hpp (original)
+++ sandbox/threadpool/boost/tp/scanns.hpp 2009-03-03 16:18:34 EST (Tue, 03 Mar 2009)
@@ -18,12 +18,9 @@
std::size_t value_;
public:
- explicit scanns( std::size_t value)
- : value_( value)
- { if ( value < 0) throw invalid_scanns("scanns must be greater than or equal to zero"); }
+ explicit scanns( std::size_t value);
- operator std::size_t () const
- { return value_; }
+ operator std::size_t () const;
};
} }
Modified: sandbox/threadpool/boost/tp/watermark.hpp
==============================================================================
--- sandbox/threadpool/boost/tp/watermark.hpp (original)
+++ sandbox/threadpool/boost/tp/watermark.hpp 2009-03-03 16:18:34 EST (Tue, 03 Mar 2009)
@@ -17,15 +17,9 @@
std::size_t value_;
public:
- explicit high_watermark( std::size_t value)
- : value_( value)
- {
- if ( value <= 0)
- throw invalid_watermark("high watermark must be greater than zero");
- }
+ explicit high_watermark( std::size_t value);
- operator std::size_t () const
- { return value_; }
+ operator std::size_t () const;
};
class low_watermark
@@ -34,15 +28,9 @@
std::size_t value_;
public:
- explicit low_watermark( std::size_t value)
- : value_( value)
- {
- if ( value < 0)
- throw invalid_watermark("low watermark must be greater than or equal to zero");
- }
+ explicit low_watermark( std::size_t value);
- operator std::size_t () const
- { return value_; }
+ operator std::size_t () const;
};
} }
Added: sandbox/threadpool/libs/tp/build/Jamfile.v2
==============================================================================
--- (empty file)
+++ sandbox/threadpool/libs/tp/build/Jamfile.v2 2009-03-03 16:18:34 EST (Tue, 03 Mar 2009)
@@ -0,0 +1,25 @@
+# Boost System Library Build Jamfile
+
+# (C) Copyright Oliver Kowalke 2009
+
+# Distributed under the Boost Software License, Version 1.0.
+# (See accompanying file LICENSE_1_0.txt or www.boost.org/LICENSE_1_0.txt)
+
+# See library home page at http://www.boost.org/libs/system
+
+project boost/tp
+ : source-location ../src
+ : usage-requirements # pass these requirement to dependents (i.e. users)
+ <link>shared:<define>BOOST_THREADPOOL_DYN_LINK=1
+ <link>static:<define>BOOST_THREADPOOL_STATIC_LINK=1
+ ;
+
+SOURCES = callable default_pool guard interrupter poolsize scanns watermark ;
+
+lib boost_threadpool
+ : $(SOURCES).cpp
+ : <link>shared:<define>BOOST_THREADPOOL_DYN_LINK=1
+ <link>static:<define>BOOST_THREADPOOL_STATIC_LINK=1
+ ;
+
+boost-install boost_threadpool ;
Modified: sandbox/threadpool/libs/tp/doc/acknowledgement.qbk
==============================================================================
--- sandbox/threadpool/libs/tp/doc/acknowledgement.qbk (original)
+++ sandbox/threadpool/libs/tp/doc/acknowledgement.qbk 2009-03-03 16:18:34 EST (Tue, 03 Mar 2009)
@@ -6,6 +6,6 @@
]
[section:acknowledgement Acknowledgements]
-I'd like to thank Vincente Botet for his comments on the implementation details of the code and
+I'd like to thank Vincente Botet Escriba for his comments on the implementation details of the code and
Anthony Williams and Braddock Gaskill for their future libraries.
[endsect]
Modified: sandbox/threadpool/libs/tp/doc/html/boost_threadpool/acknowledgement.html
==============================================================================
--- sandbox/threadpool/libs/tp/doc/html/boost_threadpool/acknowledgement.html (original)
+++ sandbox/threadpool/libs/tp/doc/html/boost_threadpool/acknowledgement.html 2009-03-03 16:18:34 EST (Tue, 03 Mar 2009)
@@ -27,8 +27,9 @@
<a name="boost_threadpool.acknowledgement"></a><a class="link" href="acknowledgement.html" title="Acknowledgements"> Acknowledgements</a>
</h2></div></div></div>
<p>
- I'd like to thank Vincente Botet for his comments on the implementation details
- of the code and Anthony Williams and Braddock Gaskill for their future libraries.
+ I'd like to thank Vincente Botet Escriba for his comments on the implementation
+ details of the code and Anthony Williams and Braddock Gaskill for their future
+ libraries.
</p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
Modified: sandbox/threadpool/libs/tp/doc/html/boost_threadpool/channel.html
==============================================================================
--- sandbox/threadpool/libs/tp/doc/html/boost_threadpool/channel.html (original)
+++ sandbox/threadpool/libs/tp/doc/html/boost_threadpool/channel.html 2009-03-03 16:18:34 EST (Tue, 03 Mar 2009)
@@ -34,7 +34,7 @@
action is put in.
</p>
<a name="boost_threadpool.channel.bounded_channel"></a><h4>
-<a name="id372093"></a>
+<a name="id372210"></a>
<a class="link" href="channel.html#boost_threadpool.channel.bounded_channel">bounded channel</a>
</h4>
<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span> <span class="keyword">typename</span> <span class="identifier">SchedulingPolicy</span> <span class="special">></span> <span class="keyword">class</span> <span class="identifier">bounded_channel</span>
@@ -52,7 +52,7 @@
tasks reaches low watermark.
</p>
<a name="boost_threadpool.channel.unbounded_channel"></a><h4>
-<a name="id372209"></a>
+<a name="id372323"></a>
<a class="link" href="channel.html#boost_threadpool.channel.unbounded_channel">unbounded channel</a>
</h4>
<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span> <span class="keyword">typename</span> <span class="identifier">SchedulingPolicy</span> <span class="special">></span> <span class="keyword">class</span> <span class="identifier">unbounded_channel</span>
Modified: sandbox/threadpool/libs/tp/doc/html/boost_threadpool/pool.html
==============================================================================
--- sandbox/threadpool/libs/tp/doc/html/boost_threadpool/pool.html (original)
+++ sandbox/threadpool/libs/tp/doc/html/boost_threadpool/pool.html 2009-03-03 16:18:34 EST (Tue, 03 Mar 2009)
@@ -38,7 +38,7 @@
later by a worker thread.
</p>
<a name="boost_threadpool.pool.work_stealing"></a><h4>
-<a name="id326471"></a>
+<a name="id326427"></a>
<a class="link" href="pool.html#boost_threadpool.pool.work_stealing">Work-Stealing</a>
</h4>
<p>
@@ -128,7 +128,7 @@
</p></td></tr>
</table></div>
<a name="boost_threadpool.pool.creation"></a><h4>
-<a name="id367698"></a>
+<a name="id367654"></a>
<a class="link" href="pool.html#boost_threadpool.pool.creation">Creation</a>
</h4>
<p>
@@ -163,7 +163,7 @@
queue</em></span></a> without blocking the inserting thread.
</p>
<a name="boost_threadpool.pool.shutdown"></a><h4>
-<a name="id368199"></a>
+<a name="id368155"></a>
<a class="link" href="pool.html#boost_threadpool.pool.shutdown">Shutdown</a>
</h4>
<p>
@@ -204,7 +204,7 @@
</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">t2</span><span class="special">.</span><span class="identifier">result</span><span class="special">().</span><span class="identifier">get</span><span class="special">()</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="comment">// 55
</span></pre>
<a name="boost_threadpool.pool.shutdown_immediatly"></a><h4>
-<a name="id368845"></a>
+<a name="id368800"></a>
<a class="link" href="pool.html#boost_threadpool.pool.shutdown_immediatly">Shutdown immediatly</a>
</h4>
<p>
@@ -224,8 +224,18 @@
was called.
</p></td></tr>
</table></div>
+<a name="boost_threadpool.pool.default_pool"></a><h4>
+<a name="id368934"></a>
+ <a class="link" href="pool.html#boost_threadpool.pool.default_pool">Default pool</a>
+ </h4>
+<p>
+ The free function <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">tp</span><span class="special">::</span><span class="identifier">get_default_pool</span><span class="special">()</span></code> returns a reference to the default thread
+ pool instance. The default thread pool is of type <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">tp</span><span class="special">::</span><span class="identifier">pool</span><span class="special"><</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">tp</span><span class="special">::</span><span class="identifier">unbounded_channel</span><span class="special"><</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">tp</span><span class="special">::</span><span class="identifier">fifo</span> <span class="special">></span> <span class="special">></span></code> and will contain as many worker threads
+ as <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">thread</span><span class="special">::</span><span class="identifier">hardware_concurrency</span><span class="special">()</span></code>
+ returns.
+ </p>
<a name="boost_threadpool.pool.meta_functions"></a><h4>
-<a name="id368978"></a>
+<a name="id369097"></a>
<a class="link" href="pool.html#boost_threadpool.pool.meta_functions">Meta functions</a>
</h4>
<p>
@@ -249,7 +259,7 @@
<pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">boolalpha</span> <span class="special"><<</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">tp</span><span class="special">::</span><span class="identifier">has_fibers</span><span class="special"><</span> <span class="identifier">pool_type</span> <span class="special">>::</span><span class="identifier">value</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
</pre>
<a name="boost_threadpool.pool.processor_binding"></a><h4>
-<a name="id369552"></a>
+<a name="id369670"></a>
<a class="link" href="pool.html#boost_threadpool.pool.processor_binding">Processor binding</a>
</h4>
<p>
Modified: sandbox/threadpool/libs/tp/doc/html/boost_threadpool/reference.html
==============================================================================
--- sandbox/threadpool/libs/tp/doc/html/boost_threadpool/reference.html (original)
+++ sandbox/threadpool/libs/tp/doc/html/boost_threadpool/reference.html 2009-03-03 16:18:34 EST (Tue, 03 Mar 2009)
@@ -99,65 +99,69 @@
<dt><span class="section"><a href="reference.html#boost_threadpool.reference.pool.submit_attr"> Member
function <code class="computeroutput"><span class="identifier">submit</span><span class="special">(</span>
<span class="identifier">Act</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">act</span><span class="special">,</span> <span class="identifier">Attr</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">attr</span><span class="special">)</span></code></a></span></dt>
+<dt><span class="section"><a href="reference.html#boost_threadpool.reference.pool.get_default_pool">
+ Non-member function <code class="computeroutput"><span class="identifier">get_default_pool</span><span class="special">()</span></code></a></span></dt>
</dl></div>
-<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">tp</span><span class="special">/</span><span class="identifier">pool</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
-
-<span class="keyword">template</span><span class="special"><</span> <span class="keyword">typename</span> <span class="identifier">Channel</span> <span class="special">></span>
-<span class="keyword">class</span> <span class="identifier">pool</span>
-<span class="special">:</span> <span class="keyword">private</span> <span class="identifier">noncopyable</span>
-<span class="special">{</span>
-<span class="keyword">public</span><span class="special">:</span>
- <span class="keyword">explicit</span> <span class="identifier">pool</span><span class="special">(</span>
- <span class="identifier">poolsize</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">psize</span><span class="special">,</span>
- <span class="identifier">posix_time</span><span class="special">::</span><span class="identifier">time_duration</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">asleep</span> <span class="special">=</span> <span class="identifier">posix_time</span><span class="special">::</span><span class="identifier">microseconds</span><span class="special">(</span> <span class="number">10</span><span class="special">),</span>
- <span class="identifier">scanns</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">scns</span> <span class="special">=</span> <span class="identifier">scanns</span><span class="special">(</span> <span class="number">20</span><span class="special">)</span> <span class="special">);</span>
-
- <span class="keyword">explicit</span> <span class="identifier">pool</span><span class="special">(</span>
- <span class="identifier">poolsize</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">psize</span><span class="special">,</span>
- <span class="identifier">high_watermark</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">hwm</span><span class="special">,</span>
- <span class="identifier">low_watermark</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">lwm</span><span class="special">,</span>
- <span class="identifier">posix_time</span><span class="special">::</span><span class="identifier">time_duration</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">asleep</span> <span class="special">=</span> <span class="identifier">posix_time</span><span class="special">::</span><span class="identifier">milliseconds</span><span class="special">(</span> <span class="number">100</span><span class="special">),</span>
- <span class="identifier">scanns</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">scns</span> <span class="special">=</span> <span class="identifier">scanns</span><span class="special">(</span> <span class="number">20</span><span class="special">)</span> <span class="special">);</span>
-
-
- <span class="keyword">explicit</span> <span class="identifier">pool</span><span class="special">(</span>
- <span class="identifier">posix_time</span><span class="special">::</span><span class="identifier">time_duration</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">asleep</span> <span class="special">=</span> <span class="identifier">posix_time</span><span class="special">::</span><span class="identifier">microseconds</span><span class="special">(</span> <span class="number">10</span><span class="special">),</span>
- <span class="identifier">scanns</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">scns</span> <span class="special">=</span> <span class="identifier">scanns</span><span class="special">(</span> <span class="number">20</span><span class="special">)</span> <span class="special">);</span>
-
- <span class="keyword">explicit</span> <span class="identifier">pool</span><span class="special">(</span>
- <span class="identifier">high_watermark</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">hwm</span><span class="special">,</span>
- <span class="identifier">low_watermark</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">lwm</span><span class="special">,</span>
- <span class="identifier">posix_time</span><span class="special">::</span><span class="identifier">time_duration</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">asleep</span> <span class="special">=</span> <span class="identifier">posix_time</span><span class="special">::</span><span class="identifier">milliseconds</span><span class="special">(</span> <span class="number">100</span><span class="special">),</span>
- <span class="identifier">scanns</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">scns</span> <span class="special">=</span> <span class="identifier">scanns</span><span class="special">(</span> <span class="number">20</span><span class="special">)</span> <span class="special">);</span>
+<pre class="programlisting"> <span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">tp</span><span class="special">/</span><span class="identifier">pool</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
- <span class="special">~</span><span class="identifier">pool</span><span class="special">();</span>
+ <span class="keyword">template</span><span class="special"><</span> <span class="keyword">typename</span> <span class="identifier">Channel</span> <span class="special">></span>
+ <span class="keyword">class</span> <span class="identifier">pool</span>
+ <span class="special">:</span> <span class="keyword">private</span> <span class="identifier">noncopyable</span>
+ <span class="special">{</span>
+ <span class="keyword">public</span><span class="special">:</span>
+ <span class="keyword">explicit</span> <span class="identifier">pool</span><span class="special">(</span>
+ <span class="identifier">poolsize</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">psize</span><span class="special">,</span>
+ <span class="identifier">posix_time</span><span class="special">::</span><span class="identifier">time_duration</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">asleep</span> <span class="special">=</span> <span class="identifier">posix_time</span><span class="special">::</span><span class="identifier">microseconds</span><span class="special">(</span> <span class="number">10</span><span class="special">),</span>
+ <span class="identifier">scanns</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">scns</span> <span class="special">=</span> <span class="identifier">scanns</span><span class="special">(</span> <span class="number">20</span><span class="special">)</span> <span class="special">);</span>
+
+ <span class="keyword">explicit</span> <span class="identifier">pool</span><span class="special">(</span>
+ <span class="identifier">poolsize</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">psize</span><span class="special">,</span>
+ <span class="identifier">high_watermark</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">hwm</span><span class="special">,</span>
+ <span class="identifier">low_watermark</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">lwm</span><span class="special">,</span>
+ <span class="identifier">posix_time</span><span class="special">::</span><span class="identifier">time_duration</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">asleep</span> <span class="special">=</span> <span class="identifier">posix_time</span><span class="special">::</span><span class="identifier">milliseconds</span><span class="special">(</span> <span class="number">100</span><span class="special">),</span>
+ <span class="identifier">scanns</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">scns</span> <span class="special">=</span> <span class="identifier">scanns</span><span class="special">(</span> <span class="number">20</span><span class="special">)</span> <span class="special">);</span>
+
+
+ <span class="keyword">explicit</span> <span class="identifier">pool</span><span class="special">(</span>
+ <span class="identifier">posix_time</span><span class="special">::</span><span class="identifier">time_duration</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">asleep</span> <span class="special">=</span> <span class="identifier">posix_time</span><span class="special">::</span><span class="identifier">microseconds</span><span class="special">(</span> <span class="number">10</span><span class="special">),</span>
+ <span class="identifier">scanns</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">scns</span> <span class="special">=</span> <span class="identifier">scanns</span><span class="special">(</span> <span class="number">20</span><span class="special">)</span> <span class="special">);</span>
+
+ <span class="keyword">explicit</span> <span class="identifier">pool</span><span class="special">(</span>
+ <span class="identifier">high_watermark</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">hwm</span><span class="special">,</span>
+ <span class="identifier">low_watermark</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">lwm</span><span class="special">,</span>
+ <span class="identifier">posix_time</span><span class="special">::</span><span class="identifier">time_duration</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">asleep</span> <span class="special">=</span> <span class="identifier">posix_time</span><span class="special">::</span><span class="identifier">milliseconds</span><span class="special">(</span> <span class="number">100</span><span class="special">),</span>
+ <span class="identifier">scanns</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">scns</span> <span class="special">=</span> <span class="identifier">scanns</span><span class="special">(</span> <span class="number">20</span><span class="special">)</span> <span class="special">);</span>
+
+ <span class="special">~</span><span class="identifier">pool</span><span class="special">();</span>
+
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">size</span><span class="special">();</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">active</span><span class="special">();</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">idle</span><span class="special">();</span>
+
+ <span class="keyword">void</span> <span class="identifier">shutdown</span><span class="special">();</span>
+ <span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span> <span class="identifier">callable</span> <span class="special">></span> <span class="identifier">shutdown_now</span><span class="special">();</span>
+
+ <span class="keyword">bool</span> <span class="identifier">terminated</span><span class="special">();</span>
+ <span class="keyword">bool</span> <span class="identifier">terminateing</span><span class="special">();</span>
+ <span class="keyword">void</span> <span class="identifier">clear</span><span class="special">();</span>
+ <span class="keyword">bool</span> <span class="identifier">empty</span><span class="special">();</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">pending</span><span class="special">();</span>
+
+ <span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">upper_bound</span><span class="special">();</span>
+ <span class="keyword">void</span> <span class="identifier">upper_bound</span><span class="special">(</span> <span class="identifier">high_watermark</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">hwm</span><span class="special">);</span>
+ <span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">lower_bound</span><span class="special">();</span>
+ <span class="keyword">void</span> <span class="identifier">lower_bound</span><span class="special">(</span> <span class="identifier">low_watermark</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">lwm</span><span class="special">);</span>
+
+ <span class="keyword">template</span><span class="special"><</span> <span class="keyword">typename</span> <span class="identifier">Act</span> <span class="special">></span>
+ <span class="identifier">task</span><span class="special"><</span> <span class="keyword">typename</span> <span class="identifier">result_of</span><span class="special"><</span> <span class="identifier">Act</span><span class="special">()</span> <span class="special">>::</span><span class="identifier">type</span> <span class="special">></span> <span class="identifier">submit</span><span class="special">(</span> <span class="identifier">Act</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">act</span><span class="special">);</span>
+
+ <span class="keyword">template</span><span class="special"><</span> <span class="keyword">typename</span> <span class="identifier">Act</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">Attr</span> <span class="special">></span>
+ <span class="identifier">task</span><span class="special"><</span> <span class="keyword">typename</span> <span class="identifier">result_of</span><span class="special"><</span> <span class="identifier">Act</span><span class="special">()</span> <span class="special">>::</span><span class="identifier">type</span> <span class="special">></span> <span class="identifier">submit</span><span class="special">(</span>
+ <span class="identifier">Act</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">act</span><span class="special">,</span>
+ <span class="identifier">Attr</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">attr</span><span class="special">);</span>
+ <span class="special">};</span>
- <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">size</span><span class="special">();</span>
- <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">active</span><span class="special">();</span>
- <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">idle</span><span class="special">();</span>
-
- <span class="keyword">void</span> <span class="identifier">shutdown</span><span class="special">();</span>
- <span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span> <span class="identifier">callable</span> <span class="special">></span> <span class="identifier">shutdown_now</span><span class="special">();</span>
-
- <span class="keyword">bool</span> <span class="identifier">terminated</span><span class="special">();</span>
- <span class="keyword">bool</span> <span class="identifier">terminateing</span><span class="special">();</span>
- <span class="keyword">void</span> <span class="identifier">clear</span><span class="special">();</span>
- <span class="keyword">bool</span> <span class="identifier">empty</span><span class="special">();</span>
- <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">pending</span><span class="special">();</span>
-
- <span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">upper_bound</span><span class="special">();</span>
- <span class="keyword">void</span> <span class="identifier">upper_bound</span><span class="special">(</span> <span class="identifier">high_watermark</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">hwm</span><span class="special">);</span>
- <span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">lower_bound</span><span class="special">();</span>
- <span class="keyword">void</span> <span class="identifier">lower_bound</span><span class="special">(</span> <span class="identifier">low_watermark</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">lwm</span><span class="special">);</span>
-
- <span class="keyword">template</span><span class="special"><</span> <span class="keyword">typename</span> <span class="identifier">Act</span> <span class="special">></span>
- <span class="identifier">task</span><span class="special"><</span> <span class="keyword">typename</span> <span class="identifier">result_of</span><span class="special"><</span> <span class="identifier">Act</span><span class="special">()</span> <span class="special">>::</span><span class="identifier">type</span> <span class="special">></span> <span class="identifier">submit</span><span class="special">(</span> <span class="identifier">Act</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">act</span><span class="special">);</span>
-
- <span class="keyword">template</span><span class="special"><</span> <span class="keyword">typename</span> <span class="identifier">Act</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">Attr</span> <span class="special">></span>
- <span class="identifier">task</span><span class="special"><</span> <span class="keyword">typename</span> <span class="identifier">result_of</span><span class="special"><</span> <span class="identifier">Act</span><span class="special">()</span> <span class="special">>::</span><span class="identifier">type</span> <span class="special">></span> <span class="identifier">submit</span><span class="special">(</span>
- <span class="identifier">Act</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">act</span><span class="special">,</span>
- <span class="identifier">Attr</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">attr</span><span class="special">);</span>
-<span class="special">};</span>
+<span class="identifier">pool</span><span class="special"><</span> <span class="identifier">unbounded_channel</span><span class="special"><</span> <span class="identifier">fifo</span> <span class="special">></span> <span class="special">></span> <span class="special">&</span> <span class="identifier">get_default_pool</span><span class="special">();</span>
</pre>
<div class="section" lang="en">
<div class="titlepage"><div><div><h4 class="title">
@@ -747,6 +751,23 @@
</dl>
</div>
</div>
+<div class="section" lang="en">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_threadpool.reference.pool.get_default_pool"></a><a class="link" href="reference.html#boost_threadpool.reference.pool.get_default_pool" title="Non-member function get_default_pool()">
+ Non-member function <code class="computeroutput"><span class="identifier">get_default_pool</span><span class="special">()</span></code></a>
+</h4></div></div></div>
+<pre class="programlisting"><span class="identifier">pool</span><span class="special"><</span> <span class="identifier">unbounded_channel</span><span class="special"><</span> <span class="identifier">fifo</span> <span class="special">></span> <span class="special">></span> <span class="special">&</span> <span class="identifier">get_default_pool</span><span class="special">();</span>
+</pre>
+<div class="variablelist">
+<p class="title"><b></b></p>
+<dl>
+<dt><span class="term">Effects:</span></dt>
+<dd><p>
+ Get access to default thread pool (static).
+ </p></dd>
+</dl>
+</div>
+</div>
</div>
<div class="section" lang="en">
<div class="titlepage"><div><div><h3 class="title">
Modified: sandbox/threadpool/libs/tp/doc/html/boost_threadpool/scheduling.html
==============================================================================
--- sandbox/threadpool/libs/tp/doc/html/boost_threadpool/scheduling.html (original)
+++ sandbox/threadpool/libs/tp/doc/html/boost_threadpool/scheduling.html 2009-03-03 16:18:34 EST (Tue, 03 Mar 2009)
@@ -30,7 +30,7 @@
The scheduling policy determines how actions are scheduled inside the <a class="link" href="channel.html" title="Channel"><span class="emphasis"><em>channel</em></span></a>.
</p>
<a name="boost_threadpool.scheduling.fifo"></a><h4>
-<a name="id372290"></a>
+<a name="id372404"></a>
<a class="link" href="scheduling.html#boost_threadpool.scheduling.fifo">fifo</a>
</h4>
<pre class="programlisting"><span class="keyword">struct</span> <span class="identifier">fifo</span>
@@ -39,7 +39,7 @@
First inserted pending action get taken first.
</p>
<a name="boost_threadpool.scheduling.lifo"></a><h4>
-<a name="id372323"></a>
+<a name="id372437"></a>
<a class="link" href="scheduling.html#boost_threadpool.scheduling.lifo">lifo</a>
</h4>
<pre class="programlisting"><span class="keyword">struct</span> <span class="identifier">lifo</span>
@@ -48,7 +48,7 @@
Last inserted pending action get taken first.
</p>
<a name="boost_threadpool.scheduling.priority"></a><h4>
-<a name="id372356"></a>
+<a name="id372470"></a>
<a class="link" href="scheduling.html#boost_threadpool.scheduling.priority">priority</a>
</h4>
<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span> <span class="keyword">typename</span> <span class="identifier">Attr</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">Ord</span> <span class="special">=</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">less</span><span class="special"><</span> <span class="identifier">Attr</span> <span class="special">></span> <span class="special">></span> <span class="keyword">struct</span> <span class="identifier">priority</span>
@@ -58,7 +58,7 @@
ordering actions.
</p>
<a name="boost_threadpool.scheduling.smart"></a><h4>
-<a name="id372462"></a>
+<a name="id372576"></a>
<a class="link" href="scheduling.html#boost_threadpool.scheduling.smart">smart</a>
</h4>
<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span> <span class="keyword">typename</span> <span class="identifier">Attr</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">Ord</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">Enq</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">Deq</span> <span class="special">></span> <span class="keyword">struct</span> <span class="identifier">smart</span>
Modified: sandbox/threadpool/libs/tp/doc/html/boost_threadpool/task.html
==============================================================================
--- sandbox/threadpool/libs/tp/doc/html/boost_threadpool/task.html (original)
+++ sandbox/threadpool/libs/tp/doc/html/boost_threadpool/task.html 2009-03-03 16:18:34 EST (Tue, 03 Mar 2009)
@@ -48,7 +48,7 @@
<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">t</span><span class="special">.</span><span class="identifier">result</span><span class="special">().</span><span class="identifier">get</span><span class="special">()</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="comment">// 55
</span></pre>
<a name="boost_threadpool.task.interruption"></a><h4>
-<a name="id370026"></a>
+<a name="id370144"></a>
<a class="link" href="task.html#boost_threadpool.task.interruption">Interruption</a>
</h4>
<p>
@@ -118,7 +118,7 @@
</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">t</span><span class="special">.</span><span class="identifier">result</span><span class="special">().</span><span class="identifier">get</span><span class="special">()</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
</pre>
<a name="boost_threadpool.task.exceptions_in_tasks"></a><h4>
-<a name="id371080"></a>
+<a name="id371198"></a>
<a class="link" href="task.html#boost_threadpool.task.exceptions_in_tasks">Exceptions in tasks</a>
</h4>
<p>
Modified: sandbox/threadpool/libs/tp/doc/html/index.html
==============================================================================
--- sandbox/threadpool/libs/tp/doc/html/index.html (original)
+++ sandbox/threadpool/libs/tp/doc/html/index.html 2009-03-03 16:18:34 EST (Tue, 03 Mar 2009)
@@ -113,35 +113,10 @@
of the futures library, N2561 C++0x proposal, from Anthony Williams (http://www.justsoftwaresolutions.co.uk/threading/updated-implementation-of-c++-futures-3.html).
</p></td></tr>
</table></div>
-<a name="boost_threadpool.introduction.tested_platforms"></a><h4>
-<a name="id326365"></a>
- <a class="link" href="index.html#boost_threadpool.introduction.tested_platforms">Tested Platforms</a>
- </h4>
-<p>
- <span class="bold"><strong>Boost.Threadpool</strong></span> has been tested on the following
- compilers/platforms:
- </p>
-<div class="itemizedlist"><ul type="disc">
-<li>
- FreeBSD 7.0 (amd64), GCC 4.2.1
- </li>
-<li>
- Linux 2.6.26 (amd64), GCC 4.3.1
- </li>
-<li>
- Linux 2.6.23.9 (i386), GCC 4.2.4
- </li>
-<li>
- OpenSolaris/Nexenta 1.0.1 (amd64), GCC 4.2.1
- </li>
-<li>
- Windows XP Professional (i386), MSVC 9.0
- </li>
-</ul></div>
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
-<td align="left"><p><small>Last revised: March 02, 2009 at 20:05:56 GMT</small></p></td>
+<td align="left"><p><small>Last revised: March 03, 2009 at 21:18:39 GMT</small></p></td>
<td align="right"><div class="copyright-footer"></div></td>
</tr></table>
<hr>
Modified: sandbox/threadpool/libs/tp/doc/introduction.qbk
==============================================================================
--- sandbox/threadpool/libs/tp/doc/introduction.qbk (original)
+++ sandbox/threadpool/libs/tp/doc/introduction.qbk 2009-03-03 16:18:34 EST (Tue, 03 Mar 2009)
@@ -21,13 +21,4 @@
[note
__boost_threadpool__ uses a modified version of the futures library, N2561 C++0x proposal, from Anthony Williams ([@http://www.justsoftwaresolutions.co.uk/threading/updated-implementation-of-c++-futures-3.html]).]
-[heading Tested Platforms]
-__boost_threadpool__ has been tested on the following compilers/platforms:
-
-* FreeBSD 7.0 (amd64), GCC 4.2.1
-* Linux 2.6.26 (amd64), GCC 4.3.1
-* Linux 2.6.23.9 (i386), GCC 4.2.4
-* OpenSolaris/Nexenta 1.0.1 (amd64), GCC 4.2.1
-* Windows XP Professional (i386), MSVC 9.0
-
[endsect]
Modified: sandbox/threadpool/libs/tp/doc/pool.qbk
==============================================================================
--- sandbox/threadpool/libs/tp/doc/pool.qbk (original)
+++ sandbox/threadpool/libs/tp/doc/pool.qbk 2009-03-03 16:18:34 EST (Tue, 03 Mar 2009)
@@ -87,6 +87,12 @@
[important Pending __actions__ in the local __worker_queues__ are not returned if `boost::tp::pool< Channel >::shutdown_now()` was called.]
+[heading Default pool]
+The free function `boost::tp::get_default_pool()` returns a reference to the default __threadpool__ instance. The default __threadpool__ is
+of type `boost::tp::pool< boost::tp::unbounded_channel< boost::tp::fifo > >` and will contain as many __worker_threads__ as
+`boost::thread::hardware_concurrency()` returns.
+
+
[heading Meta functions]
If the __threadpool__ supports priorities `boost::tp::has_priority< pool_type >` evaluates to `true`. The priority type is determined by `boost::tp::priority_type< pool_type >`.
Modified: sandbox/threadpool/libs/tp/doc/pool_ref.qbk
==============================================================================
--- sandbox/threadpool/libs/tp/doc/pool_ref.qbk (original)
+++ sandbox/threadpool/libs/tp/doc/pool_ref.qbk 2009-03-03 16:18:34 EST (Tue, 03 Mar 2009)
@@ -66,6 +66,7 @@
Attr const& attr);
};
+ pool< unbounded_channel< fifo > > & get_default_pool();
[section:constructor_unbounded_channel_hw Constructor (unbounded channel)]
@@ -335,4 +336,14 @@
[endsect]
+[section:get_default_pool Non-member function `get_default_pool()`]
+
+ pool< unbounded_channel< fifo > > & get_default_pool();
+
+[variablelist
+[[Effects:] [Get access to default thread pool (static).]]
+]
+[endsect]
+
+
[endsect]
Modified: sandbox/threadpool/libs/tp/doc/threadpool.xml
Added: sandbox/threadpool/libs/tp/examples/parallel_sort.cpp
Added: sandbox/threadpool/libs/tp/src/callable.cpp
Added: sandbox/threadpool/libs/tp/src/default_pool.cpp
Added: sandbox/threadpool/libs/tp/src/guard.cpp
Added: sandbox/threadpool/libs/tp/src/interrupter.cpp
Added: sandbox/threadpool/libs/tp/src/poolsize.cpp
Added: sandbox/threadpool/libs/tp/src/scanns.cpp
Added: sandbox/threadpool/libs/tp/src/watermark.cpp
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
==============================================================================
--- sandbox/threadpool/libs/tp/doc/threadpool.xml (original)
+++ sandbox/threadpool/libs/tp/doc/threadpool.xml 2009-03-03 16:18:34 EST (Tue, 03 Mar 2009)
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">
<library id="boost_threadpool" name="Boost.Threadpool" dirname="boost_threadpool"
-last-revision="$Date: 2009/03/02 20:05:53 $" xmlns:xi="http://www.w3.org/2001/XInclude">
+last-revision="$Date: 2009/03/03 21:18:36 $" xmlns:xi="http://www.w3.org/2001/XInclude">
<libraryinfo>
<authorgroup>
<author>
@@ -61,31 +61,6 @@
url="http://www.justsoftwaresolutions.co.uk/threading/updated-implementation-of-c++-futures-3.html">http://www.justsoftwaresolutions.co.uk/threading/updated-implementation-of-c++-futures-3.html>).
</para>
</note>
- <anchor id="boost_threadpool.introduction.tested_platforms"/>
- <bridgehead renderas="sect3">
- <link linkend="boost_threadpool.introduction.tested_platforms">Tested Platforms</link>
- </bridgehead>
- <para>
- <emphasis role="bold">Boost.Threadpool</emphasis> has been tested on the following
- compilers/platforms:
- </para>
- <itemizedlist>
- <listitem>
- FreeBSD 7.0 (amd64), GCC 4.2.1
- </listitem>
- <listitem>
- Linux 2.6.26 (amd64), GCC 4.3.1
- </listitem>
- <listitem>
- Linux 2.6.23.9 (i386), GCC 4.2.4
- </listitem>
- <listitem>
- OpenSolaris/Nexenta 1.0.1 (amd64), GCC 4.2.1
- </listitem>
- <listitem>
- Windows XP Professional (i386), MSVC 9.0
- </listitem>
- </itemizedlist>
</section>
<section id="boost_threadpool.pool">
<title><link linkend="boost_threadpool.pool"> Pool</link></title>
@@ -290,6 +265,28 @@
was called.
</para>
</important>
+ <anchor id="boost_threadpool.pool.default_pool"/>
+ <bridgehead renderas="sect3">
+ <link linkend="boost_threadpool.pool.default_pool">Default pool</link>
+ </bridgehead>
+ <para>
+ The free function <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">tp</phrase><phrase role="special">::</phrase><phrase role="identifier">get_default_pool</phrase><phrase
+ role="special">()</phrase></code> returns a reference to the default thread
+ pool instance. The default thread pool is of type <code><phrase role="identifier">boost</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">tp</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">pool</phrase><phrase role="special"><</phrase> <phrase
+ role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">tp</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">unbounded_channel</phrase><phrase
+ role="special"><</phrase> <phrase role="identifier">boost</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">tp</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">fifo</phrase> <phrase role="special">></phrase> <phrase
+ role="special">></phrase></code> and will contain as many worker threads
+ as <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">thread</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">hardware_concurrency</phrase><phrase role="special">()</phrase></code>
+ returns.
+ </para>
<anchor id="boost_threadpool.pool.meta_functions"/>
<bridgehead renderas="sect3">
<link linkend="boost_threadpool.pool.meta_functions">Meta functions</link>
@@ -1512,8 +1509,9 @@
<section id="boost_threadpool.acknowledgement">
<title><link linkend="boost_threadpool.acknowledgement"> Acknowledgements</link></title>
<para>
- I'd like to thank Vincente Botet for his comments on the implementation details
- of the code and Anthony Williams and Braddock Gaskill for their future libraries.
+ I'd like to thank Vincente Botet Escriba for his comments on the implementation
+ details of the code and Anthony Williams and Braddock Gaskill for their future
+ libraries.
</para>
</section>
<section id="boost_threadpool.reference">
@@ -1521,64 +1519,66 @@
<section id="boost_threadpool.reference.pool">
<title><link linkend="boost_threadpool.reference.pool"> Class template <code><phrase
role="identifier">pool</phrase></code></link></title>
-<programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">tp</phrase><phrase role="special">/</phrase><phrase role="identifier">pool</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase>
-
-<phrase role="keyword">template</phrase><phrase role="special"><</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Channel</phrase> <phrase role="special">></phrase>
-<phrase role="keyword">class</phrase> <phrase role="identifier">pool</phrase>
-<phrase role="special">:</phrase> <phrase role="keyword">private</phrase> <phrase role="identifier">noncopyable</phrase>
-<phrase role="special">{</phrase>
-<phrase role="keyword">public</phrase><phrase role="special">:</phrase>
- <phrase role="keyword">explicit</phrase> <phrase role="identifier">pool</phrase><phrase role="special">(</phrase>
- <phrase role="identifier">poolsize</phrase> <phrase role="keyword">const</phrase><phrase role="special">&</phrase> <phrase role="identifier">psize</phrase><phrase role="special">,</phrase>
- <phrase role="identifier">posix_time</phrase><phrase role="special">::</phrase><phrase role="identifier">time_duration</phrase> <phrase role="keyword">const</phrase><phrase role="special">&</phrase> <phrase role="identifier">asleep</phrase> <phrase role="special">=</phrase> <phrase role="identifier">posix_time</phrase><phrase role="special">::</phrase><phrase role="identifier">microseconds</phrase><phrase role="special">(</phrase> <phrase role="number">10</phrase><phrase role="special">),</phrase>
- <phrase role="identifier">scanns</phrase> <phrase role="keyword">const</phrase><phrase role="special">&</phrase> <phrase role="identifier">scns</phrase> <phrase role="special">=</phrase> <phrase role="identifier">scanns</phrase><phrase role="special">(</phrase> <phrase role="number">20</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase>
-
- <phrase role="keyword">explicit</phrase> <phrase role="identifier">pool</phrase><phrase role="special">(</phrase>
- <phrase role="identifier">poolsize</phrase> <phrase role="keyword">const</phrase><phrase role="special">&</phrase> <phrase role="identifier">psize</phrase><phrase role="special">,</phrase>
- <phrase role="identifier">high_watermark</phrase> <phrase role="keyword">const</phrase><phrase role="special">&</phrase> <phrase role="identifier">hwm</phrase><phrase role="special">,</phrase>
- <phrase role="identifier">low_watermark</phrase> <phrase role="keyword">const</phrase><phrase role="special">&</phrase> <phrase role="identifier">lwm</phrase><phrase role="special">,</phrase>
- <phrase role="identifier">posix_time</phrase><phrase role="special">::</phrase><phrase role="identifier">time_duration</phrase> <phrase role="keyword">const</phrase><phrase role="special">&</phrase> <phrase role="identifier">asleep</phrase> <phrase role="special">=</phrase> <phrase role="identifier">posix_time</phrase><phrase role="special">::</phrase><phrase role="identifier">milliseconds</phrase><phrase role="special">(</phrase> <phrase role="number">100</phrase><phrase role="special">),</phrase>
- <phrase role="identifier">scanns</phrase> <phrase role="keyword">const</phrase><phrase role="special">&</phrase> <phrase role="identifier">scns</phrase> <phrase role="special">=</phrase> <phrase role="identifier">scanns</phrase><phrase role="special">(</phrase> <phrase role="number">20</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase>
-
-
- <phrase role="keyword">explicit</phrase> <phrase role="identifier">pool</phrase><phrase role="special">(</phrase>
- <phrase role="identifier">posix_time</phrase><phrase role="special">::</phrase><phrase role="identifier">time_duration</phrase> <phrase role="keyword">const</phrase><phrase role="special">&</phrase> <phrase role="identifier">asleep</phrase> <phrase role="special">=</phrase> <phrase role="identifier">posix_time</phrase><phrase role="special">::</phrase><phrase role="identifier">microseconds</phrase><phrase role="special">(</phrase> <phrase role="number">10</phrase><phrase role="special">),</phrase>
- <phrase role="identifier">scanns</phrase> <phrase role="keyword">const</phrase><phrase role="special">&</phrase> <phrase role="identifier">scns</phrase> <phrase role="special">=</phrase> <phrase role="identifier">scanns</phrase><phrase role="special">(</phrase> <phrase role="number">20</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase>
-
- <phrase role="keyword">explicit</phrase> <phrase role="identifier">pool</phrase><phrase role="special">(</phrase>
- <phrase role="identifier">high_watermark</phrase> <phrase role="keyword">const</phrase><phrase role="special">&</phrase> <phrase role="identifier">hwm</phrase><phrase role="special">,</phrase>
- <phrase role="identifier">low_watermark</phrase> <phrase role="keyword">const</phrase><phrase role="special">&</phrase> <phrase role="identifier">lwm</phrase><phrase role="special">,</phrase>
- <phrase role="identifier">posix_time</phrase><phrase role="special">::</phrase><phrase role="identifier">time_duration</phrase> <phrase role="keyword">const</phrase><phrase role="special">&</phrase> <phrase role="identifier">asleep</phrase> <phrase role="special">=</phrase> <phrase role="identifier">posix_time</phrase><phrase role="special">::</phrase><phrase role="identifier">milliseconds</phrase><phrase role="special">(</phrase> <phrase role="number">100</phrase><phrase role="special">),</phrase>
- <phrase role="identifier">scanns</phrase> <phrase role="keyword">const</phrase><phrase role="special">&</phrase> <phrase role="identifier">scns</phrase> <phrase role="special">=</phrase> <phrase role="identifier">scanns</phrase><phrase role="special">(</phrase> <phrase role="number">20</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase>
+<programlisting> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">tp</phrase><phrase role="special">/</phrase><phrase role="identifier">pool</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase>
- <phrase role="special">~</phrase><phrase role="identifier">pool</phrase><phrase role="special">();</phrase>
+ <phrase role="keyword">template</phrase><phrase role="special"><</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Channel</phrase> <phrase role="special">></phrase>
+ <phrase role="keyword">class</phrase> <phrase role="identifier">pool</phrase>
+ <phrase role="special">:</phrase> <phrase role="keyword">private</phrase> <phrase role="identifier">noncopyable</phrase>
+ <phrase role="special">{</phrase>
+ <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
+ <phrase role="keyword">explicit</phrase> <phrase role="identifier">pool</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">poolsize</phrase> <phrase role="keyword">const</phrase><phrase role="special">&</phrase> <phrase role="identifier">psize</phrase><phrase role="special">,</phrase>
+ <phrase role="identifier">posix_time</phrase><phrase role="special">::</phrase><phrase role="identifier">time_duration</phrase> <phrase role="keyword">const</phrase><phrase role="special">&</phrase> <phrase role="identifier">asleep</phrase> <phrase role="special">=</phrase> <phrase role="identifier">posix_time</phrase><phrase role="special">::</phrase><phrase role="identifier">microseconds</phrase><phrase role="special">(</phrase> <phrase role="number">10</phrase><phrase role="special">),</phrase>
+ <phrase role="identifier">scanns</phrase> <phrase role="keyword">const</phrase><phrase role="special">&</phrase> <phrase role="identifier">scns</phrase> <phrase role="special">=</phrase> <phrase role="identifier">scanns</phrase><phrase role="special">(</phrase> <phrase role="number">20</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase>
+
+ <phrase role="keyword">explicit</phrase> <phrase role="identifier">pool</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">poolsize</phrase> <phrase role="keyword">const</phrase><phrase role="special">&</phrase> <phrase role="identifier">psize</phrase><phrase role="special">,</phrase>
+ <phrase role="identifier">high_watermark</phrase> <phrase role="keyword">const</phrase><phrase role="special">&</phrase> <phrase role="identifier">hwm</phrase><phrase role="special">,</phrase>
+ <phrase role="identifier">low_watermark</phrase> <phrase role="keyword">const</phrase><phrase role="special">&</phrase> <phrase role="identifier">lwm</phrase><phrase role="special">,</phrase>
+ <phrase role="identifier">posix_time</phrase><phrase role="special">::</phrase><phrase role="identifier">time_duration</phrase> <phrase role="keyword">const</phrase><phrase role="special">&</phrase> <phrase role="identifier">asleep</phrase> <phrase role="special">=</phrase> <phrase role="identifier">posix_time</phrase><phrase role="special">::</phrase><phrase role="identifier">milliseconds</phrase><phrase role="special">(</phrase> <phrase role="number">100</phrase><phrase role="special">),</phrase>
+ <phrase role="identifier">scanns</phrase> <phrase role="keyword">const</phrase><phrase role="special">&</phrase> <phrase role="identifier">scns</phrase> <phrase role="special">=</phrase> <phrase role="identifier">scanns</phrase><phrase role="special">(</phrase> <phrase role="number">20</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase>
+
+
+ <phrase role="keyword">explicit</phrase> <phrase role="identifier">pool</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">posix_time</phrase><phrase role="special">::</phrase><phrase role="identifier">time_duration</phrase> <phrase role="keyword">const</phrase><phrase role="special">&</phrase> <phrase role="identifier">asleep</phrase> <phrase role="special">=</phrase> <phrase role="identifier">posix_time</phrase><phrase role="special">::</phrase><phrase role="identifier">microseconds</phrase><phrase role="special">(</phrase> <phrase role="number">10</phrase><phrase role="special">),</phrase>
+ <phrase role="identifier">scanns</phrase> <phrase role="keyword">const</phrase><phrase role="special">&</phrase> <phrase role="identifier">scns</phrase> <phrase role="special">=</phrase> <phrase role="identifier">scanns</phrase><phrase role="special">(</phrase> <phrase role="number">20</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase>
+
+ <phrase role="keyword">explicit</phrase> <phrase role="identifier">pool</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">high_watermark</phrase> <phrase role="keyword">const</phrase><phrase role="special">&</phrase> <phrase role="identifier">hwm</phrase><phrase role="special">,</phrase>
+ <phrase role="identifier">low_watermark</phrase> <phrase role="keyword">const</phrase><phrase role="special">&</phrase> <phrase role="identifier">lwm</phrase><phrase role="special">,</phrase>
+ <phrase role="identifier">posix_time</phrase><phrase role="special">::</phrase><phrase role="identifier">time_duration</phrase> <phrase role="keyword">const</phrase><phrase role="special">&</phrase> <phrase role="identifier">asleep</phrase> <phrase role="special">=</phrase> <phrase role="identifier">posix_time</phrase><phrase role="special">::</phrase><phrase role="identifier">milliseconds</phrase><phrase role="special">(</phrase> <phrase role="number">100</phrase><phrase role="special">),</phrase>
+ <phrase role="identifier">scanns</phrase> <phrase role="keyword">const</phrase><phrase role="special">&</phrase> <phrase role="identifier">scns</phrase> <phrase role="special">=</phrase> <phrase role="identifier">scanns</phrase><phrase role="special">(</phrase> <phrase role="number">20</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase>
+
+ <phrase role="special">~</phrase><phrase role="identifier">pool</phrase><phrase role="special">();</phrase>
+
+ <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">size</phrase><phrase role="special">();</phrase>
+ <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">active</phrase><phrase role="special">();</phrase>
+ <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">idle</phrase><phrase role="special">();</phrase>
+
+ <phrase role="keyword">void</phrase> <phrase role="identifier">shutdown</phrase><phrase role="special">();</phrase>
+ <phrase role="keyword">const</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special"><</phrase> <phrase role="identifier">callable</phrase> <phrase role="special">></phrase> <phrase role="identifier">shutdown_now</phrase><phrase role="special">();</phrase>
+
+ <phrase role="keyword">bool</phrase> <phrase role="identifier">terminated</phrase><phrase role="special">();</phrase>
+ <phrase role="keyword">bool</phrase> <phrase role="identifier">terminateing</phrase><phrase role="special">();</phrase>
+ <phrase role="keyword">void</phrase> <phrase role="identifier">clear</phrase><phrase role="special">();</phrase>
+ <phrase role="keyword">bool</phrase> <phrase role="identifier">empty</phrase><phrase role="special">();</phrase>
+ <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">pending</phrase><phrase role="special">();</phrase>
+
+ <phrase role="keyword">const</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">upper_bound</phrase><phrase role="special">();</phrase>
+ <phrase role="keyword">void</phrase> <phrase role="identifier">upper_bound</phrase><phrase role="special">(</phrase> <phrase role="identifier">high_watermark</phrase> <phrase role="keyword">const</phrase><phrase role="special">&</phrase> <phrase role="identifier">hwm</phrase><phrase role="special">);</phrase>
+ <phrase role="keyword">const</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">lower_bound</phrase><phrase role="special">();</phrase>
+ <phrase role="keyword">void</phrase> <phrase role="identifier">lower_bound</phrase><phrase role="special">(</phrase> <phrase role="identifier">low_watermark</phrase> <phrase role="keyword">const</phrase><phrase role="special">&</phrase> <phrase role="identifier">lwm</phrase><phrase role="special">);</phrase>
+
+ <phrase role="keyword">template</phrase><phrase role="special"><</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Act</phrase> <phrase role="special">></phrase>
+ <phrase role="identifier">task</phrase><phrase role="special"><</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">result_of</phrase><phrase role="special"><</phrase> <phrase role="identifier">Act</phrase><phrase role="special">()</phrase> <phrase role="special">>::</phrase><phrase role="identifier">type</phrase> <phrase role="special">></phrase> <phrase role="identifier">submit</phrase><phrase role="special">(</phrase> <phrase role="identifier">Act</phrase> <phrase role="keyword">const</phrase><phrase role="special">&</phrase> <phrase role="identifier">act</phrase><phrase role="special">);</phrase>
+
+ <phrase role="keyword">template</phrase><phrase role="special"><</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Act</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Attr</phrase> <phrase role="special">></phrase>
+ <phrase role="identifier">task</phrase><phrase role="special"><</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">result_of</phrase><phrase role="special"><</phrase> <phrase role="identifier">Act</phrase><phrase role="special">()</phrase> <phrase role="special">>::</phrase><phrase role="identifier">type</phrase> <phrase role="special">></phrase> <phrase role="identifier">submit</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">Act</phrase> <phrase role="keyword">const</phrase><phrase role="special">&</phrase> <phrase role="identifier">act</phrase><phrase role="special">,</phrase>
+ <phrase role="identifier">Attr</phrase> <phrase role="keyword">const</phrase><phrase role="special">&</phrase> <phrase role="identifier">attr</phrase><phrase role="special">);</phrase>
+ <phrase role="special">};</phrase>
- <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">size</phrase><phrase role="special">();</phrase>
- <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">active</phrase><phrase role="special">();</phrase>
- <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">idle</phrase><phrase role="special">();</phrase>
-
- <phrase role="keyword">void</phrase> <phrase role="identifier">shutdown</phrase><phrase role="special">();</phrase>
- <phrase role="keyword">const</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special"><</phrase> <phrase role="identifier">callable</phrase> <phrase role="special">></phrase> <phrase role="identifier">shutdown_now</phrase><phrase role="special">();</phrase>
-
- <phrase role="keyword">bool</phrase> <phrase role="identifier">terminated</phrase><phrase role="special">();</phrase>
- <phrase role="keyword">bool</phrase> <phrase role="identifier">terminateing</phrase><phrase role="special">();</phrase>
- <phrase role="keyword">void</phrase> <phrase role="identifier">clear</phrase><phrase role="special">();</phrase>
- <phrase role="keyword">bool</phrase> <phrase role="identifier">empty</phrase><phrase role="special">();</phrase>
- <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">pending</phrase><phrase role="special">();</phrase>
-
- <phrase role="keyword">const</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">upper_bound</phrase><phrase role="special">();</phrase>
- <phrase role="keyword">void</phrase> <phrase role="identifier">upper_bound</phrase><phrase role="special">(</phrase> <phrase role="identifier">high_watermark</phrase> <phrase role="keyword">const</phrase><phrase role="special">&</phrase> <phrase role="identifier">hwm</phrase><phrase role="special">);</phrase>
- <phrase role="keyword">const</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">lower_bound</phrase><phrase role="special">();</phrase>
- <phrase role="keyword">void</phrase> <phrase role="identifier">lower_bound</phrase><phrase role="special">(</phrase> <phrase role="identifier">low_watermark</phrase> <phrase role="keyword">const</phrase><phrase role="special">&</phrase> <phrase role="identifier">lwm</phrase><phrase role="special">);</phrase>
-
- <phrase role="keyword">template</phrase><phrase role="special"><</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Act</phrase> <phrase role="special">></phrase>
- <phrase role="identifier">task</phrase><phrase role="special"><</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">result_of</phrase><phrase role="special"><</phrase> <phrase role="identifier">Act</phrase><phrase role="special">()</phrase> <phrase role="special">>::</phrase><phrase role="identifier">type</phrase> <phrase role="special">></phrase> <phrase role="identifier">submit</phrase><phrase role="special">(</phrase> <phrase role="identifier">Act</phrase> <phrase role="keyword">const</phrase><phrase role="special">&</phrase> <phrase role="identifier">act</phrase><phrase role="special">);</phrase>
-
- <phrase role="keyword">template</phrase><phrase role="special"><</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Act</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Attr</phrase> <phrase role="special">></phrase>
- <phrase role="identifier">task</phrase><phrase role="special"><</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">result_of</phrase><phrase role="special"><</phrase> <phrase role="identifier">Act</phrase><phrase role="special">()</phrase> <phrase role="special">>::</phrase><phrase role="identifier">type</phrase> <phrase role="special">></phrase> <phrase role="identifier">submit</phrase><phrase role="special">(</phrase>
- <phrase role="identifier">Act</phrase> <phrase role="keyword">const</phrase><phrase role="special">&</phrase> <phrase role="identifier">act</phrase><phrase role="special">,</phrase>
- <phrase role="identifier">Attr</phrase> <phrase role="keyword">const</phrase><phrase role="special">&</phrase> <phrase role="identifier">attr</phrase><phrase role="special">);</phrase>
-<phrase role="special">};</phrase>
+<phrase role="identifier">pool</phrase><phrase role="special"><</phrase> <phrase role="identifier">unbounded_channel</phrase><phrase role="special"><</phrase> <phrase role="identifier">fifo</phrase> <phrase role="special">></phrase> <phrase role="special">></phrase> <phrase role="special">&</phrase> <phrase role="identifier">get_default_pool</phrase><phrase role="special">();</phrase>
</programlisting>
<section id="boost_threadpool.reference.pool.constructor_unbounded_channel_hw">
<title><link linkend="boost_threadpool.reference.pool.constructor_unbounded_channel_hw">
@@ -2281,6 +2281,22 @@
</varlistentry>
</variablelist>
</section>
+ <section id="boost_threadpool.reference.pool.get_default_pool">
+ <title><link linkend="boost_threadpool.reference.pool.get_default_pool">
+ Non-member function <code><phrase role="identifier">get_default_pool</phrase><phrase
+ role="special">()</phrase></code></link></title>
+<programlisting><phrase role="identifier">pool</phrase><phrase role="special"><</phrase> <phrase role="identifier">unbounded_channel</phrase><phrase role="special"><</phrase> <phrase role="identifier">fifo</phrase> <phrase role="special">></phrase> <phrase role="special">></phrase> <phrase role="special">&</phrase> <phrase role="identifier">get_default_pool</phrase><phrase role="special">();</phrase>
+</programlisting>
+ <variablelist>
+ <title></title> <varlistentry><term>Effects:</term>
+ <listitem>
+ <para>
+ Get access to default thread pool (static).
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
</section>
<section id="boost_threadpool.reference.task">
<title><link linkend="boost_threadpool.reference.task"> Class template <code><phrase
==============================================================================
--- (empty file)
+++ sandbox/threadpool/libs/tp/examples/parallel_sort.cpp 2009-03-03 16:18:34 EST (Tue, 03 Mar 2009)
@@ -0,0 +1,273 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2008-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)
+//
+// See http://www.boost.org/libs/interthreads for documentation.
+//
+// Based on the shared.cpp example from the threadalert library of Roland Schwarz
+//////////////////////////////////////////////////////////////////////////////
+
+// requires interthread and range available at boost-sandbox and boost-vault
+
+#include <iostream>
+#include <algorithm>
+
+#include <boost/progress.hpp>
+#include <boost/thread/thread.hpp>
+#include <boost/bind.hpp>
+#include <boost/tp/pool.hpp>
+#include <boost/tp/unbounded_channel.hpp>
+#include <boost/tp/fifo.hpp>
+#include <boost/range/algorithm/sort.hpp>
+#include <boost/range/algorithm/inplace_merge.hpp>
+#include <boost/range/sub_range.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/range/algorithm/equal.hpp>
+#include <boost/range/algorithm/for_each.hpp>
+#include <boost/range/algorithm/transform.hpp>
+#include <boost/range/adaptor/sliced.hpp>
+#include <boost/interthreads/fork.hpp>
+#include <boost/interthreads/algorithm/wait.hpp>
+#include <boost/interthreads/scheduler.hpp>
+#include <boost/array.hpp>
+
+#include <assert.h>
+
+#define BOOST_PARTS 2
+#define NN 10000000
+
+class scoped_timer {
+ boost::posix_time::ptime start_;
+public:
+ scoped_timer()
+ : start_(boost::posix_time::microsec_clock::universal_time())
+ {}
+ ~scoped_timer() {
+ boost::posix_time::ptime stop( boost::posix_time::microsec_clock::universal_time() );
+ std::cout << " " << ( stop - start_).total_milliseconds() << " milli seconds" << std::endl;
+ }
+};
+
+template <typename Range>
+class partition
+{
+public:
+ boost::iterator_range<typename boost::range_iterator<Range>::type> range_;
+ std::size_t parts_;
+ partition(boost::iterator_range<typename boost::range_iterator<Range>::type>& range, std::size_t parts):
+ range_(range),
+ parts_(parts)
+ {}
+ boost::iterator_range<typename boost::range_iterator<Range>::type> operator[](unsigned i) {
+ unsigned size = boost::size(range_);
+ if (i<(parts_-1))
+ return boost::make_sliced_range(range_, i*(size/parts_), ((i+1)*(size/parts_)));
+ else
+ return boost::make_sliced_range(range_, (parts_-1)*(size/parts_), size);
+ }
+};
+
+typedef boost::tp::pool<
+ boost::tp::unbounded_channel< boost::tp::fifo >
+> pool_type;
+
+#ifdef TASK_POOL
+ typedef boost::tp::task< pool_type, void > task_type;
+#else
+ typedef boost::tp::task< void > task_type;
+#endif
+
+
+template <
+ typename DirectSolver,
+ typename Composer,
+ typename AE,
+ typename Range
+>
+ void inplace_solve( AE & ae,
+ boost::iterator_range<typename boost::range_iterator<Range>::type> range,
+ unsigned cutoff );
+
+template <
+ typename DirectSolver,
+ typename Composer,
+ typename AE,
+ typename Range
+>
+ void inplace_solve( AE & ae,
+ boost::iterator_range<typename boost::range_iterator<Range>::type> range,
+ unsigned cutoff )
+ {
+ unsigned size = boost::size(range);
+ //std::cout << "<<par_ " << size;
+ if ( size <= cutoff) DirectSolver()(range);
+ else {
+ partition<Range> parts(range, BOOST_PARTS);
+ std::list<task_type> tasks;
+ #if 0 // this code do not compiles with gcc 3.4.4 cygwin
+ boost::transform(parts, boost::begin(tasks),
+ boost::bind(&AE::submit, boost::ref(ae),
+ //boost::bind(&boost::interthreads::fork<AE>, boost::ref(ae),
+ boost::bind(&inplace_solve<DirectSolver,Composer,AE,Range>, boost::ref(ae),_1,cutoff)));
+ #else
+ for (unsigned i=0;i < BOOST_PARTS-1; ++i) {
+ task_type tmp(ae.submit(
+ boost::bind(
+ &inplace_solve<DirectSolver,Composer,AE,Range>,
+ boost::ref(ae),
+ parts[i],
+ cutoff
+ )));
+ tasks.push_back(tmp);
+ }
+ #endif
+ inplace_solve<DirectSolver,Composer,AE,Range>(ae, parts[BOOST_PARTS-1], cutoff);
+ boost::for_each(tasks, &boost::interthreads::wait_act<task_type>);
+
+ //std::cout << "par_inplace_merge_fct " << size << ">>"<< std::endl;
+ Composer()(range);
+ //std::cout << "par_ " << size << ">>"<< std::endl;
+
+ }
+ }
+
+struct sort_fct {
+ template<class RandomAccessRange>
+ RandomAccessRange& operator()(RandomAccessRange rng) {
+ return boost::sort(rng);
+ }
+};
+
+struct inplace_merge_fct {
+ template<class BidirectionalRange>
+ BidirectionalRange&
+ operator()( BidirectionalRange rng) {
+ return boost::inplace_merge(rng, boost::begin(rng)+(boost::size(rng)/2));
+ }
+};
+template <typename AE, typename Range>
+void parallel_sort(AE& ae, Range& range, unsigned cutoff=10000) {
+ boost::iterator_range<typename boost::range_iterator<Range>::type> rng(range);
+ inplace_solve<sort_fct,inplace_merge_fct,pool_type,Range>( ae, rng, cutoff);
+}
+
+int sorted[NN];
+int values1[NN];
+int values2[NN];
+int values3[NN];
+int values4[NN];
+int values5[NN];
+int values6[NN];
+
+int main() {
+ for (unsigned i=0; i<NN; ++i) sorted[i]=i;
+
+ for (unsigned i=0; i<NN; ++i) values1[i]=NN-i-1;
+ {
+ std::cout << "std::sort: reverse 0.." << NN;
+ scoped_timer t; // start timing
+ std::sort(boost::begin(values1), boost::end(values1));
+ }
+ assert(boost::equal(values1, sorted));
+ {
+ std::cout << "std::sort: 0.." << NN;
+ scoped_timer t; // start timing
+ std::sort(boost::begin(values1), boost::end(values1));
+ }
+
+ for (unsigned i=0; i<NN; ++i) values2[i]=NN-i-1;
+ {
+ std::cout << "boost::sort: reverse 0.."<<NN;
+ scoped_timer t; // start timing
+ boost::sort(values2);
+ }
+ assert(boost::equal(values2, sorted));
+ {
+ std::cout << "boost::sort: 0.."<<NN;
+ scoped_timer t; // start timing
+ boost::sort(values2);
+ }
+
+ // creates a threadpool with two worker-threads
+ pool_type pool( boost::tp::poolsize( 2) );
+
+// // creates a threadpool with as many worker-threads
+// // as CPUs/Cores are online and bind each worker-thread
+// // to a specific CPU/Core
+// // requires BOOST_BIND_WORKER_TO_PROCESSORS to be specified
+// pool_type pool;
+
+ for (unsigned i=0; i<NN; ++i) values5[i]=NN-i-1;
+ {
+ std::cout << "parallel_sort "<<NN/2<<": reverse 0.."<<NN;
+ scoped_timer tmr; // start timing
+ parallel_sort(pool, values5, NN/2);
+ }
+ assert(boost::equal(values5, sorted));
+ {
+ std::cout << "parallel_sort "<<NN/2<<": 0.."<<NN;
+ scoped_timer tmr; // start timing
+ parallel_sort(pool, values5, NN/2);
+ }
+
+ for (unsigned i=0; i<NN; ++i) values5[i]=NN-i-1;
+ {
+ std::cout << "parallel_sort "<<NN/4<<": reverse 0.."<<NN;
+ scoped_timer tmr; // start timing
+ parallel_sort(pool, values5, NN/4);
+ }
+ assert(boost::equal(values5, sorted));
+ {
+ std::cout << "parallel_sort "<<NN/4<<": 0.."<<NN;
+ scoped_timer tmr; // start timing
+ parallel_sort(pool, values5, NN/4);
+ }
+
+ for (unsigned i=0; i<NN; ++i) values5[i]=NN-i-1;
+ {
+ std::cout << "parallel_sort "<<NN/8<<": reverse 0.."<<NN;
+ scoped_timer tmr; // start timing
+ parallel_sort(pool, values5, NN/8);
+ }
+ assert(boost::equal(values5, sorted));
+ {
+ std::cout << "parallel_sort "<<NN/8<<": 0.."<<NN;
+ scoped_timer tmr; // start timing
+ parallel_sort(pool, values5, NN/8);
+ }
+
+ for (unsigned i=0; i<NN; ++i) values5[i]=NN-i-1;
+ {
+ std::cout << "parallel_sort "<<NN/16<<": reverse 0.."<<NN;
+ scoped_timer tmr; // start timing
+ parallel_sort(pool, values5, NN/16);
+ }
+ assert(boost::equal(values5, sorted));
+ {
+ std::cout << "parallel_sort "<<NN/16<<": 0.."<<NN;
+ scoped_timer tmr; // start timing
+ parallel_sort(pool, values5, NN/16);
+ }
+
+ for (unsigned i=0; i<NN; ++i) values5[i]=NN-i-1;
+ {
+ std::cout << "parallel_sort "<<NN/32<<": reverse 0.."<<NN;
+ scoped_timer tmr; // start timing
+ parallel_sort(pool, values5, NN/32);
+ }
+ assert(boost::equal(values5, sorted));
+ {
+ std::cout << "parallel_sort "<<NN/32<<": 0.."<<NN;
+ scoped_timer tmr; // start timing
+ parallel_sort(pool, values5, NN/32);
+ }
+
+
+ std::cout << "shutdown"<< std::endl;
+ pool.shutdown();
+ std::cout << "end"<< std::endl;
+ return 0;
+}
==============================================================================
--- (empty file)
+++ sandbox/threadpool/libs/tp/src/callable.cpp 2009-03-03 16:18:34 EST (Tue, 03 Mar 2009)
@@ -0,0 +1,22 @@
+#include "boost/tp/detail/callable.hpp"
+
+namespace boost { namespace tp {
+namespace detail
+{
+callable::callable()
+: impl_()
+{}
+
+void
+callable::operator()()
+{ impl_->run(); }
+
+bool
+callable::empty() const
+{ return ! impl_; }
+
+void
+callable::clear()
+{ impl_.reset(); }
+} } }
+
==============================================================================
--- (empty file)
+++ sandbox/threadpool/libs/tp/src/default_pool.cpp 2009-03-03 16:18:34 EST (Tue, 03 Mar 2009)
@@ -0,0 +1,10 @@
+#include "boost/tp/default_pool.hpp"
+#include <boost/thread.hpp>
+
+namespace boost { namespace tp {
+namespace detail
+{
+default_pool
+static_pool::instance( poolsize( thread::hardware_concurrency() ) );
+}
+} }
\ No newline at end of file
==============================================================================
--- (empty file)
+++ sandbox/threadpool/libs/tp/src/guard.cpp 2009-03-03 16:18:34 EST (Tue, 03 Mar 2009)
@@ -0,0 +1,19 @@
+#include "boost/tp/detail/guard.hpp"
+
+namespace boost { namespace tp {
+namespace detail
+{
+guard::guard( volatile uint32_t & active_worker)
+: active_worker_( active_worker)
+{
+ BOOST_ASSERT( active_worker_ >= 0);
+ interprocess::detail::atomic_inc32( & active_worker_);
+}
+
+guard::~guard()
+{
+ interprocess::detail::atomic_dec32( & active_worker_);
+ BOOST_ASSERT( active_worker_ >= 0);
+}
+} } }
+
==============================================================================
--- (empty file)
+++ sandbox/threadpool/libs/tp/src/interrupter.cpp 2009-03-03 16:18:34 EST (Tue, 03 Mar 2009)
@@ -0,0 +1,107 @@
+#include "boost/tp/detail/interrupter.hpp"
+
+namespace boost { namespace tp {
+namespace detail
+{
+void
+interrupter::impl::interrupt_()
+{
+ if ( ! interruption_requested_)
+ {
+ interruption_requested_ = true;
+ if ( thrd_) thrd_->interrupt();
+ }
+}
+
+interrupter::impl::impl()
+:
+interruption_requested_( false),
+cond_(),
+mtx_(),
+thrd_()
+{}
+
+void
+interrupter::impl::set( shared_ptr< thread > const& thrd)
+{
+ BOOST_ASSERT( thrd);
+ unique_lock< mutex > lk( mtx_);
+ thrd_ = thrd;
+ BOOST_ASSERT( thrd_);
+ if ( interruption_requested_) thrd_->interrupt();
+}
+
+void
+interrupter::impl::reset()
+{
+ unique_lock< mutex > lk( mtx_);
+ thrd_.reset();
+ BOOST_ASSERT( ! thrd_);
+ try
+ { this_thread::interruption_point(); }
+ catch ( thread_interrupted const&)
+ {}
+ BOOST_ASSERT( ! this_thread::interruption_requested() );
+ cond_.notify_all();
+}
+
+void
+interrupter::impl::interrupt()
+{
+ unique_lock< mutex > lk( mtx_);
+ interrupt_();
+}
+
+void
+interrupter::impl::interrupt_and_wait()
+{
+ unique_lock< mutex > lk( mtx_);
+ interrupt_();
+ cond_.wait( lk);
+}
+
+void
+interrupter::impl::interrupt_and_wait( system_time const& abs_time)
+{
+ unique_lock< mutex > lk( mtx_);
+ interrupt_();
+ cond_.timed_wait( lk, abs_time);
+}
+
+bool
+interrupter::impl::interruption_requested()
+{
+ unique_lock< mutex > lk( mtx_);
+ return interruption_requested_;
+}
+
+interrupter::interrupter()
+: impl_( new impl() )
+{}
+
+void
+interrupter::set( shared_ptr< thread > const& thrd)
+{ impl_->set( thrd); }
+
+void
+interrupter::reset()
+{ impl_->reset(); }
+
+void
+interrupter::interrupt()
+{ impl_->interrupt(); }
+
+void
+interrupter::interrupt_and_wait()
+{ impl_->interrupt_and_wait(); }
+
+void
+interrupter::interrupt_and_wait( system_time const& abs_time)
+{ impl_->interrupt_and_wait( abs_time); }
+
+bool
+interrupter::interruption_requested()
+{ return impl_->interruption_requested(); }
+}
+} }
+
==============================================================================
--- (empty file)
+++ sandbox/threadpool/libs/tp/src/poolsize.cpp 2009-03-03 16:18:34 EST (Tue, 03 Mar 2009)
@@ -0,0 +1,12 @@
+#include "boost/tp/poolsize.hpp"
+
+namespace boost { namespace tp
+{
+poolsize::poolsize( std::size_t value)
+: value_( value)
+{ if ( value <= 0) throw invalid_poolsize("core poolsize must be greater than zero"); }
+
+poolsize::operator std::size_t () const
+{ return value_; }
+} }
+
==============================================================================
--- (empty file)
+++ sandbox/threadpool/libs/tp/src/scanns.cpp 2009-03-03 16:18:34 EST (Tue, 03 Mar 2009)
@@ -0,0 +1,12 @@
+#include "boost/tp/scanns.hpp"
+
+namespace boost { namespace tp
+{
+scanns::scanns( std::size_t value)
+: value_( value)
+{ if ( value < 0) throw invalid_scanns("scanns must be greater than or equal to zero"); }
+
+scanns::operator std::size_t () const
+{ return value_; }
+} }
+
==============================================================================
--- (empty file)
+++ sandbox/threadpool/libs/tp/src/watermark.cpp 2009-03-03 16:18:34 EST (Tue, 03 Mar 2009)
@@ -0,0 +1,24 @@
+#include "boost/tp/watermark.hpp"
+
+namespace boost { namespace tp
+{
+high_watermark::high_watermark( std::size_t value)
+: value_( value)
+{
+ if ( value <= 0)
+ throw invalid_watermark("high watermark must be greater than zero");
+}
+
+high_watermark::operator std::size_t () const
+{ return value_; }
+
+low_watermark::low_watermark( std::size_t value)
+: value_( value)
+{
+ if ( value < 0)
+ throw invalid_watermark("low watermark must be greater than or equal to zero");
+}
+
+low_watermark::operator std::size_t () const
+{ return value_; }
+} }