|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r51625 - in sandbox/threadpool: boost/tp libs/tp/doc libs/tp/doc/html libs/tp/doc/html/boost_threadpool libs/tp/test
From: oliver.kowalke_at_[hidden]
Date: 2009-03-05 13:17:26
Author: olli
Date: 2009-03-05 13:17:24 EST (Thu, 05 Mar 2009)
New Revision: 51625
URL: http://svn.boost.org/trac/boost/changeset/51625
Log:
* this_task:is_worker() and this_task::worker_id() added
* worker class moved from pool (inner class) into own file and into
namespace detail
Text files modified:
sandbox/threadpool/boost/tp/pool.hpp | 10 ++++
sandbox/threadpool/libs/tp/doc/html/boost_threadpool/channel.html | 4
sandbox/threadpool/libs/tp/doc/html/boost_threadpool/reference.html | 87 ++++++++++++++++++++++++++++++++++-----
sandbox/threadpool/libs/tp/doc/html/boost_threadpool/scheduling.html | 8 +-
sandbox/threadpool/libs/tp/doc/html/boost_threadpool/this_task.html | 13 ++---
sandbox/threadpool/libs/tp/doc/html/index.html | 10 +++-
sandbox/threadpool/libs/tp/doc/this_task.qbk | 8 ++-
sandbox/threadpool/libs/tp/doc/this_task_ref.qbk | 41 +++++++++++++++---
sandbox/threadpool/libs/tp/test/Jamfile.v2 | 3
9 files changed, 143 insertions(+), 41 deletions(-)
Modified: sandbox/threadpool/boost/tp/pool.hpp
==============================================================================
--- sandbox/threadpool/boost/tp/pool.hpp (original)
+++ sandbox/threadpool/boost/tp/pool.hpp 2009-03-05 13:17:24 EST (Thu, 05 Mar 2009)
@@ -61,8 +61,16 @@
}
inline
-bool is_valid()
+bool is_worker()
{ return tp::detail::worker::tss_get() != 0; }
+
+inline
+thread::id worker_id()
+{
+ tp::detail::worker * w( tp::detail::worker::tss_get() );
+ BOOST_ASSERT( w);
+ return w->get_id();
+}
}
namespace tp
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-05 13:17:24 EST (Thu, 05 Mar 2009)
@@ -34,7 +34,7 @@
action is put in.
</p>
<a name="boost_threadpool.channel.bounded_channel"></a><h4>
-<a name="id372210"></a>
+<a name="id372246"></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="id372323"></a>
+<a name="id372359"></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/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-05 13:17:24 EST (Thu, 05 Mar 2009)
@@ -29,9 +29,13 @@
<dt><span class="section"> Class template pool
</span></dt>
<dt><span class="section"> Class template task
</span></dt>
<dt><span class="section"><a href="reference.html#boost_threadpool.reference.reschedule_until"> Non-member
- function <code class="computeroutput"><span class="identifier">reschedule_until</span></code></a></span></dt>
+ function <code class="computeroutput"><span class="identifier">reschedule_until</span><span class="special">()</span></code></a></span></dt>
<dt><span class="section"><a href="reference.html#boost_threadpool.reference.get_thread_pool"> Non-member
- function <code class="computeroutput"><span class="identifier">get_thread_pool</span></code></a></span></dt>
+ function <code class="computeroutput"><span class="identifier">get_thread_pool</span><span class="special">()</span></code></a></span></dt>
+<dt><span class="section"><a href="reference.html#boost_threadpool.reference.is_worker"> Non-member function
+ <code class="computeroutput"><span class="identifier">is_worker</span><span class="special">()</span></code></a></span></dt>
+<dt><span class="section"><a href="reference.html#boost_threadpool.reference.worker_id"> Non-member function
+ <code class="computeroutput"><span class="identifier">worker_id</span><span class="special">()</span></code></a></span></dt>
<dt><span class="section"> Class poolsize
</span></dt>
<dt><span class="section"> Class scanns
</span></dt>
<dt><span class="section"> Class high_watermark
</span></dt>
@@ -910,16 +914,13 @@
</div>
<div class="section" lang="en">
<div class="titlepage"><div><div><h3 class="title">
-<a name="boost_threadpool.reference.reschedule_until"></a><a class="link" href="reference.html#boost_threadpool.reference.reschedule_until" title="Non-member function reschedule_until"> Non-member
- function <code class="computeroutput"><span class="identifier">reschedule_until</span></code></a>
+<a name="boost_threadpool.reference.reschedule_until"></a><a class="link" href="reference.html#boost_threadpool.reference.reschedule_until" title="Non-member function reschedule_until()"> Non-member
+ function <code class="computeroutput"><span class="identifier">reschedule_until</span><span class="special">()</span></code></a>
</h3></div></div></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">Pool</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">R</span> <span class="special">></span>
-<span class="keyword">void</span> <span class="identifier">reschedule_until</span><span class="special">(</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">unique_future</span><span class="special"><</span> <span class="identifier">R</span> <span class="special">></span> <span class="keyword">const</span><span class="special">&);</span>
-
-<span class="keyword">template</span><span class="special"><</span> <span class="keyword">typename</span> <span class="identifier">Pool</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">R</span> <span class="special">></span>
-<span class="keyword">void</span> <span class="identifier">reschedule_until</span><span class="special">(</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">shared_future</span><span class="special"><</span> <span class="identifier">R</span> <span class="special">></span> <span class="keyword">const</span><span class="special">&);</span>
+<span class="keyword">template</span><span class="special"><</span> <span class="keyword">typename</span> <span class="identifier">Pred</span> <span class="special">></span>
+<span class="keyword">void</span> <span class="identifier">reschedule_until</span><span class="special">(</span> <span class="identifier">Pred</span> <span class="keyword">const</span><span class="special">&);</span>
</pre>
<div class="variablelist">
<p class="title"><b></b></p>
@@ -927,7 +928,7 @@
<dt><span class="term">Effects:</span></dt>
<dd>
<p>
- Reschedules current task until passed future becomes ready.
+ Reschedules current task until passed callable predicate becomes ready.
</p>
<p>
[Throws:
@@ -945,8 +946,8 @@
</div>
<div class="section" lang="en">
<div class="titlepage"><div><div><h3 class="title">
-<a name="boost_threadpool.reference.get_thread_pool"></a><a class="link" href="reference.html#boost_threadpool.reference.get_thread_pool" title="Non-member function get_thread_pool"> Non-member
- function <code class="computeroutput"><span class="identifier">get_thread_pool</span></code></a>
+<a name="boost_threadpool.reference.get_thread_pool"></a><a class="link" href="reference.html#boost_threadpool.reference.get_thread_pool" title="Non-member function get_thread_pool()"> Non-member
+ function <code class="computeroutput"><span class="identifier">get_thread_pool</span><span class="special">()</span></code></a>
</h3></div></div></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>
@@ -978,6 +979,68 @@
</div>
<div class="section" lang="en">
<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_threadpool.reference.is_worker"></a><a class="link" href="reference.html#boost_threadpool.reference.is_worker" title="Non-member function is_worker()"> Non-member function
+ <code class="computeroutput"><span class="identifier">is_worker</span><span class="special">()</span></code></a>
+</h3></div></div></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">bool</span> <span class="identifier">is_worker</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>
+ Returns true if the current thread is a worker-thread form a pool.
+ </p>
+<p>
+ [Throws:
+ </p>
+<p>
+ Nothing.
+ </p>
+</dd>
+<dt><span class="term">Note:</span></dt>
+<dd><p>
+ This function resides in namespace <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">this_task</span></code>.
+ </p></dd>
+</dl>
+</div>
+</div>
+<div class="section" lang="en">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_threadpool.reference.worker_id"></a><a class="link" href="reference.html#boost_threadpool.reference.worker_id" title="Non-member function worker_id()"> Non-member function
+ <code class="computeroutput"><span class="identifier">worker_id</span><span class="special">()</span></code></a>
+</h3></div></div></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="identifier">thread</span><span class="special">::</span><span class="identifier">id</span> <span class="identifier">worker_id</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>
+ Returns returns the thread-id of the worker-thread.
+ </p>
+<p>
+ [Throws:
+ </p>
+<p>
+ Nothing.
+ </p>
+</dd>
+<dt><span class="term">Note:</span></dt>
+<dd><p>
+ This function resides in namespace <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">this_task</span></code>.
+ </p></dd>
+</dl>
+</div>
+</div>
+<div class="section" lang="en">
+<div class="titlepage"><div><div><h3 class="title">
<a name="boost_threadpool.reference.poolsize"></a><a class="link" href="reference.html#boost_threadpool.reference.poolsize" title="Class poolsize"> Class <code class="computeroutput"><span class="identifier">poolsize</span></code></a>
</h3></div></div></div>
<div class="toc"><dl>
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-05 13:17:24 EST (Thu, 05 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="id372404"></a>
+<a name="id372440"></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="id372437"></a>
+<a name="id372473"></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="id372470"></a>
+<a name="id372506"></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="id372576"></a>
+<a name="id372612"></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/this_task.html
==============================================================================
--- sandbox/threadpool/libs/tp/doc/html/boost_threadpool/this_task.html (original)
+++ sandbox/threadpool/libs/tp/doc/html/boost_threadpool/this_task.html 2009-03-05 13:17:24 EST (Thu, 05 Mar 2009)
@@ -28,13 +28,12 @@
</h2></div></div></div>
<p>
In the function <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">this_task</span><span class="special">::</span><span class="identifier">reschedule_until</span><span class="special">(</span>
- <span class="identifier">boost</span><span class="special">::</span><span class="identifier">shared_future</span><span class="special"><</span>
- <span class="identifier">R</span> <span class="special">></span>
- <span class="keyword">const</span><span class="special">&)</span></code>
- allows to synchronize the task with other asynchronous events without blocking
- the worker threads. The current task will be rescheduled until the passed future
- becomes ready. The pool can be accessed via <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">this_task</span><span class="special">::</span><span class="identifier">get_thread_pool</span><span class="special"><</span> <span class="identifier">Pool</span> <span class="special">>()</span></code> if the calling code is executed by a
- worker thread.
+ <span class="identifier">Pred</span> <span class="keyword">const</span><span class="special">&)</span></code> allows to synchronize the task with other
+ asynchronous events without blocking the worker threads (bool Pred::operator()()
+ must not block) The current task will be rescheduled until the passed predicate
+ becomes true. The pool can be accessed via <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">this_task</span><span class="special">::</span><span class="identifier">get_thread_pool</span><span class="special"><</span> <span class="identifier">Pool</span> <span class="special">>()</span></code> if the calling code is executed by a
+ worker thread. <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">this_task</span><span class="special">::</span><span class="identifier">s_worker</span><span class="special">()</span></code>
+ evaluates true if the current thread is worker thread and <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">this_task</span><span class="special">::</span><span class="identifier">worker_id</span><span class="special">()</span></code> returns the thread id.
</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/index.html
==============================================================================
--- sandbox/threadpool/libs/tp/doc/html/index.html (original)
+++ sandbox/threadpool/libs/tp/doc/html/index.html 2009-03-05 13:17:24 EST (Thu, 05 Mar 2009)
@@ -49,9 +49,13 @@
<dt><span class="section"> Class template pool
</span></dt>
<dt><span class="section"> Class template task
</span></dt>
<dt><span class="section"><a href="boost_threadpool/reference.html#boost_threadpool.reference.reschedule_until"> Non-member
- function <code class="computeroutput"><span class="identifier">reschedule_until</span></code></a></span></dt>
+ function <code class="computeroutput"><span class="identifier">reschedule_until</span><span class="special">()</span></code></a></span></dt>
<dt><span class="section"><a href="boost_threadpool/reference.html#boost_threadpool.reference.get_thread_pool"> Non-member
- function <code class="computeroutput"><span class="identifier">get_thread_pool</span></code></a></span></dt>
+ function <code class="computeroutput"><span class="identifier">get_thread_pool</span><span class="special">()</span></code></a></span></dt>
+<dt><span class="section"><a href="boost_threadpool/reference.html#boost_threadpool.reference.is_worker"> Non-member function
+ <code class="computeroutput"><span class="identifier">is_worker</span><span class="special">()</span></code></a></span></dt>
+<dt><span class="section"><a href="boost_threadpool/reference.html#boost_threadpool.reference.worker_id"> Non-member function
+ <code class="computeroutput"><span class="identifier">worker_id</span><span class="special">()</span></code></a></span></dt>
<dt><span class="section"> Class poolsize
</span></dt>
<dt><span class="section"> Class scanns
</span></dt>
<dt><span class="section"> Class high_watermark
</span></dt>
@@ -116,7 +120,7 @@
</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 03, 2009 at 21:18:39 GMT</small></p></td>
+<td align="left"><p><small>Last revised: March 05, 2009 at 18:12:14 GMT</small></p></td>
<td align="right"><div class="copyright-footer"></div></td>
</tr></table>
<hr>
Modified: sandbox/threadpool/libs/tp/doc/this_task.qbk
==============================================================================
--- sandbox/threadpool/libs/tp/doc/this_task.qbk (original)
+++ sandbox/threadpool/libs/tp/doc/this_task.qbk 2009-03-05 13:17:24 EST (Thu, 05 Mar 2009)
@@ -6,9 +6,11 @@
]
[section:this_task Namespace this_task]
-In the function `boost::this_task::reschedule_until( boost::shared_future< R > const&)` allows to synchronize the task with other
-asynchronous events without blocking the __worker_threads__. The current task will be rescheduled until the passed future
-becomes ready.
+In the function `boost::this_task::reschedule_until( Pred const&)` allows to synchronize the task with other
+asynchronous events without blocking the __worker_threads__ (bool Pred::operator()() must not block)
+The current task will be rescheduled until the passed predicate becomes true.
The pool can be accessed via `boost::this_task::get_thread_pool< Pool >()` if the calling code is executed by a __worker_thread__.
+`boost::this_task::s_worker()` evaluates true if the current thread is __worker_thread__ and `boost::this_task::worker_id()`
+returns the thread id.
[endsect]
Modified: sandbox/threadpool/libs/tp/doc/this_task_ref.qbk
==============================================================================
--- sandbox/threadpool/libs/tp/doc/this_task_ref.qbk (original)
+++ sandbox/threadpool/libs/tp/doc/this_task_ref.qbk 2009-03-05 13:17:24 EST (Thu, 05 Mar 2009)
@@ -5,25 +5,22 @@
http://www.boost.org/LICENSE_1_0.txt).
]
-[section:reschedule_until Non-member function `reschedule_until`]
+[section:reschedule_until Non-member function `reschedule_until()`]
#include <boost/tp/pool.hpp>
- template< typename Pool, typename R >
- void reschedule_until( boost::unique_future< R > const&);
-
- template< typename Pool, typename R >
- void reschedule_until( boost::shared_future< R > const&);
+ template< typename Pred >
+ void reschedule_until( Pred const&);
[variablelist
-[[Effects:] [Reschedules current task until passed future becomes ready.]
+[[Effects:] [Reschedules current task until passed callable predicate becomes ready.]
[[Throws:] [Nothing.]]
[[Note:] [This function resides in namespace `boost::this_task`.]]
]
[endsect]
-[section:get_thread_pool Non-member function `get_thread_pool`]
+[section:get_thread_pool Non-member function `get_thread_pool()`]
#include <boost/tp/pool.hpp>
@@ -37,3 +34,31 @@
]
[endsect]
+
+[section:is_worker Non-member function `is_worker()`]
+
+ #include <boost/tp/pool.hpp>
+
+ bool is_worker();
+
+[variablelist
+[[Effects:] [Returns true if the current thread is a worker-thread form a pool.]
+[[Throws:] [Nothing.]]
+[[Note:] [This function resides in namespace `boost::this_task`.]]
+]
+
+[endsect]
+
+[section:worker_id Non-member function `worker_id()`]
+
+ #include <boost/tp/pool.hpp>
+
+ thread::id worker_id();
+
+[variablelist
+[[Effects:] [Returns returns the thread-id of the worker-thread.]
+[[Throws:] [Nothing.]]
+[[Note:] [This function resides in namespace `boost::this_task`.]]
+]
+
+[endsect]
Modified: sandbox/threadpool/libs/tp/test/Jamfile.v2
==============================================================================
--- sandbox/threadpool/libs/tp/test/Jamfile.v2 (original)
+++ sandbox/threadpool/libs/tp/test/Jamfile.v2 2009-03-05 13:17:24 EST (Thu, 05 Mar 2009)
@@ -14,6 +14,7 @@
<library>../../test/build//boost_unit_test_framework
<library>../../thread/build//boost_thread
<library>../../system/build//boost_system
+ <library>../../tp/build//boost_threadpool
<link>static
<threading>multi
;
@@ -34,4 +35,4 @@
[ tp-test test_unbounded_queue_lifo ]
[ tp-test test_unbounded_queue_priority ]
[ tp-test test_unbounded_queue_smart ]
- ;
\ No newline at end of file
+ ;
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