Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r51496 - in sandbox/threadpool: boost/tp libs/tp/doc libs/tp/doc/html libs/tp/doc/html/boost_threadpool
From: oliver.kowalke_at_[hidden]
Date: 2009-03-01 03:20:14


Author: olli
Date: 2009-03-01 03:20:12 EST (Sun, 01 Mar 2009)
New Revision: 51496
URL: http://svn.boost.org/trac/boost/changeset/51496

Log:
* reschedule_until() takes a jss::future< R > as argument
* documentation update

Text files modified:
   sandbox/threadpool/boost/tp/pool.hpp | 58 +
   sandbox/threadpool/libs/tp/doc/html/boost_threadpool/channel.html | 4
   sandbox/threadpool/libs/tp/doc/html/boost_threadpool/forkjoin.html | 773 +++++++++++++++++++++++++++++++++---
   sandbox/threadpool/libs/tp/doc/html/boost_threadpool/reference.html | 40 +
   sandbox/threadpool/libs/tp/doc/html/boost_threadpool/scheduling.html | 8
   sandbox/threadpool/libs/tp/doc/html/boost_threadpool/this_task.html | 9
   sandbox/threadpool/libs/tp/doc/html/index.html | 6
   sandbox/threadpool/libs/tp/doc/this_task.qbk | 5
   sandbox/threadpool/libs/tp/doc/this_task_ref.qbk | 15
   sandbox/threadpool/libs/tp/doc/threadpool.xml | 836 ++++++++++++++++++++++++++++++++++++---
   10 files changed, 1590 insertions(+), 164 deletions(-)

Modified: sandbox/threadpool/boost/tp/pool.hpp
==============================================================================
--- sandbox/threadpool/boost/tp/pool.hpp (original)
+++ sandbox/threadpool/boost/tp/pool.hpp 2009-03-01 03:20:12 EST (Sun, 01 Mar 2009)
@@ -61,6 +61,17 @@
 
 namespace this_task
 {
+template<
+ typename Pool,
+ typename R
+>
+void reschedule_until( jss::shared_future< R > const& f)
+{
+ typename Pool::worker * w( Pool::tss_worker_.get() );
+ BOOST_ASSERT( w);
+ w->reschedule_until( f);
+}
+
 template< typename Pool >
 Pool & get_thread_pool()
 {
@@ -76,6 +87,12 @@
 class pool : private noncopyable
 {
 private:
+ template<
+ typename Pool,
+ typename R
+ >
+ friend void this_task::reschedule_until( jss::shared_future< R > const&);
+
         template< typename Pool >
         friend Pool & this_task::get_thread_pool();
 
@@ -195,6 +212,10 @@
                         void reset_scanns()
                         { scns_ = 0; }
 
+ template< typename R >
+ void reschedule_until( jss::shared_future< R > const& f)
+ { pool_ptr_->reschedule_until_( f); }
+
                         pool & get_thread_pool()
                         { return * pool_ptr_; }
                 };
@@ -259,6 +280,10 @@
                 void reset_scanns()
                 { impl_->reset_scanns(); }
 
+ template< typename R >
+ void reschedule_until( jss::shared_future< R > const& f)
+ { return impl_->reschedule_until( f); }
+
                 pool & get_thread_pool()
                 { return impl_->get_thread_pool(); }
         };
@@ -373,7 +398,8 @@
                 }
         }
 
- void reschedule_until_( function< bool() > const& cond)
+ template< typename R >
+ void reschedule_until_( jss::shared_future< R > const& f)
         {
                 worker * w( tss_worker_.get() );
                 BOOST_ASSERT( w);
@@ -381,7 +407,7 @@
                 BOOST_ASSERT( thrd);
                 detail::interrupter intr;
                 detail::callable ca;
- while ( ! cond() )
+ while ( ! f.is_ready() )
                 {
                         next_callable_( * w, ca, intr);
                         if( ! ca.empty() )
@@ -697,21 +723,17 @@
                 typedef typename result_of< Act() >::type R;
                 detail::interrupter intr;
                 jss::packaged_task< R > tsk( act);
- jss::shared_future< R > fut( tsk.get_future() );
+ jss::shared_future< R > f( tsk.get_future() );
                 worker * w( tss_worker_.get() );
                 if ( w)
                 {
- function< bool() > cond(
- bind(
- & jss::shared_future< R >::is_ready,
- fut) );
                         tsk.set_wait_callback(
                                 bind(
- ( void ( pool< Channel >::*)( function< bool() > const&) ) & pool< Channel >::reschedule_until_,
+ ( void ( pool::*)( jss::shared_future< R > const&) ) & pool::reschedule_until_,
                                         this,
- cond) );
+ f) );
                         w->put( detail::callable( move( tsk) ), intr);
- return task< R >( fut, intr);
+ return task< R >( f, intr);
                 }
                 else
                 {
@@ -723,7 +745,7 @@
 
                         channel_item itm( detail::callable( move( tsk) ), intr);
                         channel_.put( itm);
- return task< R >( fut, intr);
+ return task< R >( f, intr);
                 }
         }
 
@@ -738,21 +760,17 @@
                 typedef typename result_of< Act() >::type R;
                 detail::interrupter intr;
                 jss::packaged_task< R > tsk( act);
- jss::shared_future< R > fut( tsk.get_future() );
+ jss::shared_future< R > f( tsk.get_future() );
                 worker * w( tss_worker_.get() );
                 if ( w)
                 {
- function< bool() > cond(
- bind(
- & jss::shared_future< R >::is_ready,
- fut) );
                         tsk.set_wait_callback(
                                 bind(
- ( void ( pool< Channel >::*)( function< bool() > const&) ) & pool< Channel >::reschedule_until_,
+ ( void ( pool::*)( jss::shared_future< R > const&) ) & pool::reschedule_until_,
                                         this,
- cond) );
+ f) );
                         w->put( detail::callable( move( tsk) ), intr);
- return task< R >( fut, intr);
+ return task< R >( f, intr);
                 }
                 else
                 {
@@ -764,7 +782,7 @@
 
                         channel_item itm( detail::callable( move( tsk) ), attr, intr);
                         channel_.put( itm);
- return task< R >( fut, intr);
+ return task< R >( f, intr);
                 }
         }
 };

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-01 03:20:12 EST (Sun, 01 Mar 2009)
@@ -34,7 +34,7 @@
       action is put in.
     </p>
 <a name="boost_threadpool.channel.bounded_channel"></a><h4>
-<a name="id372089"></a>
+<a name="id372152"></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">&lt;</span> <span class="keyword">typename</span> <span class="identifier">SchedulingPolicy</span> <span class="special">&gt;</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="id372202"></a>
+<a name="id372266"></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">&lt;</span> <span class="keyword">typename</span> <span class="identifier">SchedulingPolicy</span> <span class="special">&gt;</span> <span class="keyword">class</span> <span class="identifier">unbounded_channel</span>

Modified: sandbox/threadpool/libs/tp/doc/html/boost_threadpool/forkjoin.html
==============================================================================
--- sandbox/threadpool/libs/tp/doc/html/boost_threadpool/forkjoin.html (original)
+++ sandbox/threadpool/libs/tp/doc/html/boost_threadpool/forkjoin.html 2009-03-01 03:20:12 EST (Sun, 01 Mar 2009)
@@ -38,76 +38,723 @@
       other actions from its local <a class="link" href="pool.html#boost_threadpool.pool.work_stealing"><span class="emphasis"><em>worker
       queue</em></span></a>.
     </p>
-<pre class="programlisting"><span class="comment">// defines the threadpool type
-</span><span class="keyword">typedef</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">&lt;</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">&lt;</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">&gt;</span>
-<span class="special">&gt;</span> <span class="identifier">pool_type</span><span class="special">;</span>
+<pre class="programlisting"> <span class="comment">// defines the threadpool type
+</span> <span class="keyword">namespace</span> <span class="identifier">pt</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">posix_time</span><span class="special">;</span>
+<span class="keyword">namespace</span> <span class="identifier">tp</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="keyword">typedef</span> <span class="identifier">tp</span><span class="special">::</span><span class="identifier">pool</span><span class="special">&lt;</span> <span class="identifier">tp</span><span class="special">::</span><span class="identifier">unbounded_channel</span><span class="special">&lt;</span> <span class="identifier">tp</span><span class="special">::</span><span class="identifier">fifo</span> <span class="special">&gt;</span> <span class="special">&gt;</span> <span class="identifier">pool_type</span><span class="special">;</span>
 
 <span class="keyword">class</span> <span class="identifier">fibo</span>
 <span class="special">{</span>
 <span class="keyword">private</span><span class="special">:</span>
- <span class="identifier">pool_type</span> <span class="special">&amp;</span> <span class="identifier">pool_</span><span class="special">;</span>
- <span class="keyword">int</span> <span class="identifier">cutoff_</span><span class="special">;</span>
+ <span class="keyword">int</span> <span class="identifier">offset_</span><span class="special">;</span>
+
+ <span class="keyword">int</span> <span class="identifier">seq_</span><span class="special">(</span> <span class="keyword">int</span> <span class="identifier">n</span><span class="special">)</span>
+ <span class="special">{</span>
+ <span class="keyword">if</span> <span class="special">(</span> <span class="identifier">n</span> <span class="special">&lt;=</span> <span class="number">1</span><span class="special">)</span> <span class="keyword">return</span> <span class="identifier">n</span><span class="special">;</span>
+ <span class="keyword">else</span> <span class="keyword">return</span> <span class="identifier">seq_</span><span class="special">(</span> <span class="identifier">n</span> <span class="special">-</span> <span class="number">2</span><span class="special">)</span> <span class="special">+</span> <span class="identifier">seq_</span><span class="special">(</span> <span class="identifier">n</span> <span class="special">-</span> <span class="number">1</span><span class="special">);</span>
+ <span class="special">}</span>
+
+ <span class="keyword">int</span> <span class="identifier">par_</span><span class="special">(</span> <span class="keyword">int</span> <span class="identifier">n</span><span class="special">)</span>
+ <span class="special">{</span>
+ <span class="keyword">if</span> <span class="special">(</span> <span class="identifier">n</span> <span class="special">&lt;=</span> <span class="identifier">offset_</span><span class="special">)</span> <span class="keyword">return</span> <span class="identifier">seq_</span><span class="special">(</span> <span class="identifier">n</span><span class="special">);</span>
+ <span class="keyword">else</span>
+ <span class="special">{</span>
+ <span class="identifier">tp</span><span class="special">::</span><span class="identifier">task</span><span class="special">&lt;</span> <span class="keyword">int</span> <span class="special">&gt;</span> <span class="identifier">t1</span><span class="special">(</span>
+ <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">&lt;</span> <span class="identifier">pool_type</span> <span class="special">&gt;().</span><span class="identifier">submit</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">bind</span><span class="special">(</span>
+ <span class="special">&amp;</span> <span class="identifier">fibo</span><span class="special">::</span><span class="identifier">par_</span><span class="special">,</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">ref</span><span class="special">(</span> <span class="special">*</span> <span class="keyword">this</span><span class="special">),</span>
+ <span class="identifier">n</span> <span class="special">-</span> <span class="number">1</span><span class="special">)</span> <span class="special">)</span> <span class="special">);</span>
+ <span class="identifier">tp</span><span class="special">::</span><span class="identifier">task</span><span class="special">&lt;</span> <span class="keyword">int</span> <span class="special">&gt;</span> <span class="identifier">t2</span><span class="special">(</span>
+ <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">&lt;</span> <span class="identifier">pool_type</span> <span class="special">&gt;().</span><span class="identifier">submit</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">bind</span><span class="special">(</span>
+ <span class="special">&amp;</span> <span class="identifier">fibo</span><span class="special">::</span><span class="identifier">par_</span><span class="special">,</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">ref</span><span class="special">(</span> <span class="special">*</span> <span class="keyword">this</span><span class="special">),</span>
+ <span class="identifier">n</span> <span class="special">-</span> <span class="number">2</span><span class="special">)</span> <span class="special">)</span> <span class="special">);</span>
+ <span class="keyword">return</span> <span class="identifier">t1</span><span class="special">.</span><span class="identifier">get</span><span class="special">()</span> <span class="special">+</span> <span class="identifier">t2</span><span class="special">.</span><span class="identifier">get</span><span class="special">();</span>
+ <span class="special">}</span>
+ <span class="special">}</span>
+
+<span class="keyword">public</span><span class="special">:</span>
+ <span class="identifier">fibo</span><span class="special">(</span> <span class="keyword">int</span> <span class="identifier">offset</span><span class="special">)</span>
+ <span class="special">:</span> <span class="identifier">offset_</span><span class="special">(</span> <span class="identifier">offset</span><span class="special">)</span>
+ <span class="special">{}</span>
+
+ <span class="keyword">int</span> <span class="identifier">execute</span><span class="special">(</span> <span class="keyword">int</span> <span class="identifier">n</span><span class="special">)</span>
+ <span class="special">{</span>
+ <span class="keyword">int</span> <span class="identifier">result</span><span class="special">(</span> <span class="identifier">par_</span><span class="special">(</span> <span class="identifier">n</span><span class="special">)</span> <span class="special">);</span>
+ <span class="keyword">return</span> <span class="identifier">result</span><span class="special">;</span>
+ <span class="special">}</span>
+<span class="special">};</span>
+
+<span class="keyword">int</span> <span class="identifier">main</span><span class="special">(</span> <span class="keyword">int</span> <span class="identifier">argc</span><span class="special">,</span> <span class="keyword">char</span> <span class="special">*</span><span class="identifier">argv</span><span class="special">[])</span>
+<span class="special">{</span>
+ <span class="keyword">try</span>
+ <span class="special">{</span>
+ <span class="identifier">pool_type</span> <span class="identifier">pool</span><span class="special">(</span> <span class="identifier">tp</span><span class="special">::</span><span class="identifier">poolsize</span><span class="special">(</span> <span class="number">3</span><span class="special">)</span> <span class="special">);</span>
+ <span class="identifier">fibo</span> <span class="identifier">fib</span><span class="special">(</span> <span class="number">5</span><span class="special">);</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span> <span class="identifier">tp</span><span class="special">::</span><span class="identifier">task</span><span class="special">&lt;</span> <span class="keyword">int</span> <span class="special">&gt;</span> <span class="special">&gt;</span> <span class="identifier">results</span><span class="special">;</span>
+ <span class="identifier">results</span><span class="special">.</span><span class="identifier">reserve</span><span class="special">(</span> <span class="number">40</span><span class="special">);</span>
+
+ <span class="identifier">pt</span><span class="special">::</span><span class="identifier">ptime</span> <span class="identifier">start</span><span class="special">(</span> <span class="identifier">pt</span><span class="special">::</span><span class="identifier">microsec_clock</span><span class="special">::</span><span class="identifier">universal_time</span><span class="special">()</span> <span class="special">);</span>
+
+ <span class="keyword">for</span> <span class="special">(</span> <span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special">&lt;</span> <span class="number">32</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span>
+ <span class="identifier">results</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span>
+ <span class="identifier">pool</span><span class="special">.</span><span class="identifier">submit</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">bind</span><span class="special">(</span>
+ <span class="special">&amp;</span> <span class="identifier">fibo</span><span class="special">::</span><span class="identifier">execute</span><span class="special">,</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">ref</span><span class="special">(</span> <span class="identifier">fib</span><span class="special">),</span>
+ <span class="identifier">i</span><span class="special">)</span> <span class="special">)</span> <span class="special">);</span>
+
+ <span class="keyword">int</span> <span class="identifier">k</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span> <span class="identifier">tp</span><span class="special">::</span><span class="identifier">task</span><span class="special">&lt;</span> <span class="keyword">int</span> <span class="special">&gt;</span> <span class="special">&gt;::</span><span class="identifier">iterator</span> <span class="identifier">e</span><span class="special">(</span> <span class="identifier">results</span><span class="special">.</span><span class="identifier">end</span><span class="special">()</span> <span class="special">);</span>
+ <span class="keyword">for</span> <span class="special">(</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span> <span class="identifier">tp</span><span class="special">::</span><span class="identifier">task</span><span class="special">&lt;</span> <span class="keyword">int</span> <span class="special">&gt;</span> <span class="special">&gt;::</span><span class="identifier">iterator</span> <span class="identifier">i</span><span class="special">(</span> <span class="identifier">results</span><span class="special">.</span><span class="identifier">begin</span><span class="special">()</span> <span class="special">);</span>
+ <span class="identifier">i</span> <span class="special">!=</span> <span class="identifier">e</span><span class="special">;</span>
+ <span class="special">++</span><span class="identifier">i</span><span class="special">)</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"fibonacci "</span> <span class="special">&lt;&lt;</span> <span class="identifier">k</span><span class="special">++</span> <span class="special">&lt;&lt;</span> <span class="string">" == "</span> <span class="special">&lt;&lt;</span> <span class="identifier">i</span><span class="special">-&gt;</span><span class="identifier">get</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
+
+ <span class="identifier">pt</span><span class="special">::</span><span class="identifier">ptime</span> <span class="identifier">stop</span><span class="special">(</span> <span class="identifier">pt</span><span class="special">::</span><span class="identifier">microsec_clock</span><span class="special">::</span><span class="identifier">universal_time</span><span class="special">()</span> <span class="special">);</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="special">(</span> <span class="identifier">stop</span> <span class="special">-</span> <span class="identifier">start</span><span class="special">).</span><span class="identifier">total_milliseconds</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="string">" milli seconds"</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
+
+ <span class="keyword">return</span> <span class="identifier">EXIT_SUCCESS</span><span class="special">;</span>
+ <span class="special">}</span>
+ <span class="keyword">catch</span> <span class="special">(</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">exception</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">e</span><span class="special">)</span>
+ <span class="special">{</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cerr</span> <span class="special">&lt;&lt;</span> <span class="string">"exception: "</span> <span class="special">&lt;&lt;</span> <span class="identifier">e</span><span class="special">.</span><span class="identifier">what</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="special">}</span>
+ <span class="keyword">catch</span> <span class="special">(</span> <span class="special">...</span> <span class="special">)</span>
+ <span class="special">{</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cerr</span> <span class="special">&lt;&lt;</span> <span class="string">"unhandled"</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="special">}</span>
+
+ <span class="keyword">return</span> <span class="identifier">EXIT_FAILURE</span><span class="special">;</span>
+<span class="special">}</span>
+</pre>
+<p>
+ // defines the threadpool type namespace pt = boost::posix_time; namespace
+ tp = boost::tp;
+ </p>
+<pre class="programlisting"><span class="keyword">typedef</span> <span class="identifier">tp</span><span class="special">::</span><span class="identifier">pool</span><span class="special">&lt;</span> <span class="identifier">tp</span><span class="special">::</span><span class="identifier">unbounded_channel</span><span class="special">&lt;</span> <span class="identifier">tp</span><span class="special">::</span><span class="identifier">fifo</span> <span class="special">&gt;</span> <span class="special">&gt;</span> <span class="identifier">pool_type</span><span class="special">;</span>
+
+<span class="keyword">class</span> <span class="identifier">fibo</span>
+<span class="special">{</span>
+<span class="keyword">private</span><span class="special">:</span>
+ <span class="keyword">int</span> <span class="identifier">offset_</span><span class="special">;</span>
+
+ <span class="keyword">int</span> <span class="identifier">seq_</span><span class="special">(</span> <span class="keyword">int</span> <span class="identifier">n</span><span class="special">)</span>
+ <span class="special">{</span>
+ <span class="keyword">if</span> <span class="special">(</span> <span class="identifier">n</span> <span class="special">&lt;=</span> <span class="number">1</span><span class="special">)</span> <span class="keyword">return</span> <span class="identifier">n</span><span class="special">;</span>
+ <span class="keyword">else</span> <span class="keyword">return</span> <span class="identifier">seq_</span><span class="special">(</span> <span class="identifier">n</span> <span class="special">-</span> <span class="number">2</span><span class="special">)</span> <span class="special">+</span> <span class="identifier">seq_</span><span class="special">(</span> <span class="identifier">n</span> <span class="special">-</span> <span class="number">1</span><span class="special">);</span>
+ <span class="special">}</span>
+
+ <span class="keyword">int</span> <span class="identifier">par_</span><span class="special">(</span> <span class="keyword">int</span> <span class="identifier">n</span><span class="special">)</span>
+ <span class="special">{</span>
+ <span class="keyword">if</span> <span class="special">(</span> <span class="identifier">n</span> <span class="special">&lt;=</span> <span class="identifier">offset_</span><span class="special">)</span> <span class="keyword">return</span> <span class="identifier">seq_</span><span class="special">(</span> <span class="identifier">n</span><span class="special">);</span>
+ <span class="keyword">else</span>
+ <span class="special">{</span>
+ <span class="identifier">tp</span><span class="special">::</span><span class="identifier">task</span><span class="special">&lt;</span> <span class="keyword">int</span> <span class="special">&gt;</span> <span class="identifier">t1</span><span class="special">(</span>
+ <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">&lt;</span> <span class="identifier">pool_type</span> <span class="special">&gt;().</span><span class="identifier">submit</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">bind</span><span class="special">(</span>
+ <span class="special">&amp;</span> <span class="identifier">fibo</span><span class="special">::</span><span class="identifier">par_</span><span class="special">,</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">ref</span><span class="special">(</span> <span class="special">*</span> <span class="keyword">this</span><span class="special">),</span>
+ <span class="identifier">n</span> <span class="special">-</span> <span class="number">1</span><span class="special">)</span> <span class="special">)</span> <span class="special">);</span>
+ <span class="identifier">tp</span><span class="special">::</span><span class="identifier">task</span><span class="special">&lt;</span> <span class="keyword">int</span> <span class="special">&gt;</span> <span class="identifier">t2</span><span class="special">(</span>
+ <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">&lt;</span> <span class="identifier">pool_type</span> <span class="special">&gt;().</span><span class="identifier">submit</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">bind</span><span class="special">(</span>
+ <span class="special">&amp;</span> <span class="identifier">fibo</span><span class="special">::</span><span class="identifier">par_</span><span class="special">,</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">ref</span><span class="special">(</span> <span class="special">*</span> <span class="keyword">this</span><span class="special">),</span>
+ <span class="identifier">n</span> <span class="special">-</span> <span class="number">2</span><span class="special">)</span> <span class="special">)</span> <span class="special">);</span>
+ <span class="keyword">return</span> <span class="identifier">t1</span><span class="special">.</span><span class="identifier">get</span><span class="special">()</span> <span class="special">+</span> <span class="identifier">t2</span><span class="special">.</span><span class="identifier">get</span><span class="special">();</span>
+ <span class="special">}</span>
+ <span class="special">}</span>
+
+<span class="keyword">public</span><span class="special">:</span>
+ <span class="identifier">fibo</span><span class="special">(</span> <span class="keyword">int</span> <span class="identifier">offset</span><span class="special">)</span>
+ <span class="special">:</span> <span class="identifier">offset_</span><span class="special">(</span> <span class="identifier">offset</span><span class="special">)</span>
+ <span class="special">{}</span>
+
+ <span class="keyword">int</span> <span class="identifier">execute</span><span class="special">(</span> <span class="keyword">int</span> <span class="identifier">n</span><span class="special">)</span>
+ <span class="special">{</span>
+ <span class="keyword">int</span> <span class="identifier">result</span><span class="special">(</span> <span class="identifier">par_</span><span class="special">(</span> <span class="identifier">n</span><span class="special">)</span> <span class="special">);</span>
+ <span class="keyword">return</span> <span class="identifier">result</span><span class="special">;</span>
+ <span class="special">}</span>
+<span class="special">};</span>
+
+<span class="keyword">int</span> <span class="identifier">main</span><span class="special">(</span> <span class="keyword">int</span> <span class="identifier">argc</span><span class="special">,</span> <span class="keyword">char</span> <span class="special">*</span><span class="identifier">argv</span><span class="special">[])</span>
+<span class="special">{</span>
+ <span class="keyword">try</span>
+ <span class="special">{</span>
+ <span class="identifier">pool_type</span> <span class="identifier">pool</span><span class="special">(</span> <span class="identifier">tp</span><span class="special">::</span><span class="identifier">poolsize</span><span class="special">(</span> <span class="number">3</span><span class="special">)</span> <span class="special">);</span>
+ <span class="identifier">fibo</span> <span class="identifier">fib</span><span class="special">(</span> <span class="number">5</span><span class="special">);</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span> <span class="identifier">tp</span><span class="special">::</span><span class="identifier">task</span><span class="special">&lt;</span> <span class="keyword">int</span> <span class="special">&gt;</span> <span class="special">&gt;</span> <span class="identifier">results</span><span class="special">;</span>
+ <span class="identifier">results</span><span class="special">.</span><span class="identifier">reserve</span><span class="special">(</span> <span class="number">40</span><span class="special">);</span>
+
+ <span class="identifier">pt</span><span class="special">::</span><span class="identifier">ptime</span> <span class="identifier">start</span><span class="special">(</span> <span class="identifier">pt</span><span class="special">::</span><span class="identifier">microsec_clock</span><span class="special">::</span><span class="identifier">universal_time</span><span class="special">()</span> <span class="special">);</span>
+
+ <span class="keyword">for</span> <span class="special">(</span> <span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special">&lt;</span> <span class="number">32</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span>
+ <span class="identifier">results</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span>
+ <span class="identifier">pool</span><span class="special">.</span><span class="identifier">submit</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">bind</span><span class="special">(</span>
+ <span class="special">&amp;</span> <span class="identifier">fibo</span><span class="special">::</span><span class="identifier">execute</span><span class="special">,</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">ref</span><span class="special">(</span> <span class="identifier">fib</span><span class="special">),</span>
+ <span class="identifier">i</span><span class="special">)</span> <span class="special">)</span> <span class="special">);</span>
+
+ <span class="keyword">int</span> <span class="identifier">k</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span> <span class="identifier">tp</span><span class="special">::</span><span class="identifier">task</span><span class="special">&lt;</span> <span class="keyword">int</span> <span class="special">&gt;</span> <span class="special">&gt;::</span><span class="identifier">iterator</span> <span class="identifier">e</span><span class="special">(</span> <span class="identifier">results</span><span class="special">.</span><span class="identifier">end</span><span class="special">()</span> <span class="special">);</span>
+ <span class="keyword">for</span> <span class="special">(</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span> <span class="identifier">tp</span><span class="special">::</span><span class="identifier">task</span><span class="special">&lt;</span> <span class="keyword">int</span> <span class="special">&gt;</span> <span class="special">&gt;::</span><span class="identifier">iterator</span> <span class="identifier">i</span><span class="special">(</span> <span class="identifier">results</span><span class="special">.</span><span class="identifier">begin</span><span class="special">()</span> <span class="special">);</span>
+ <span class="identifier">i</span> <span class="special">!=</span> <span class="identifier">e</span><span class="special">;</span>
+ <span class="special">++</span><span class="identifier">i</span><span class="special">)</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"fibonacci "</span> <span class="special">&lt;&lt;</span> <span class="identifier">k</span><span class="special">++</span> <span class="special">&lt;&lt;</span> <span class="string">" == "</span> <span class="special">&lt;&lt;</span> <span class="identifier">i</span><span class="special">-&gt;</span><span class="identifier">get</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
+
+ <span class="identifier">pt</span><span class="special">::</span><span class="identifier">ptime</span> <span class="identifier">stop</span><span class="special">(</span> <span class="identifier">pt</span><span class="special">::</span><span class="identifier">microsec_clock</span><span class="special">::</span><span class="identifier">universal_time</span><span class="special">()</span> <span class="special">);</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="special">(</span> <span class="identifier">stop</span> <span class="special">-</span> <span class="identifier">start</span><span class="special">).</span><span class="identifier">total_milliseconds</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="string">" milli seconds"</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
+
+ <span class="keyword">return</span> <span class="identifier">EXIT_SUCCESS</span><span class="special">;</span>
+ <span class="special">}</span>
+ <span class="keyword">catch</span> <span class="special">(</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">exception</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">e</span><span class="special">)</span>
+ <span class="special">{</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cerr</span> <span class="special">&lt;&lt;</span> <span class="string">"exception: "</span> <span class="special">&lt;&lt;</span> <span class="identifier">e</span><span class="special">.</span><span class="identifier">what</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="special">}</span>
+ <span class="keyword">catch</span> <span class="special">(</span> <span class="special">...</span> <span class="special">)</span>
+ <span class="special">{</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cerr</span> <span class="special">&lt;&lt;</span> <span class="string">"unhandled"</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="special">}</span>
+
+ <span class="keyword">return</span> <span class="identifier">EXIT_FAILURE</span><span class="special">;</span>
+<span class="special">}</span>
+</pre>
+<p>
+ typedef tp::pool&lt; tp::unbounded_channel&lt; tp::fifo &gt; &gt; pool_type;
+ </p>
+<pre class="programlisting"><span class="keyword">class</span> <span class="identifier">fibo</span>
+<span class="special">{</span>
+<span class="keyword">private</span><span class="special">:</span>
+ <span class="keyword">int</span> <span class="identifier">offset_</span><span class="special">;</span>
+
+ <span class="keyword">int</span> <span class="identifier">seq_</span><span class="special">(</span> <span class="keyword">int</span> <span class="identifier">n</span><span class="special">)</span>
+ <span class="special">{</span>
+ <span class="keyword">if</span> <span class="special">(</span> <span class="identifier">n</span> <span class="special">&lt;=</span> <span class="number">1</span><span class="special">)</span> <span class="keyword">return</span> <span class="identifier">n</span><span class="special">;</span>
+ <span class="keyword">else</span> <span class="keyword">return</span> <span class="identifier">seq_</span><span class="special">(</span> <span class="identifier">n</span> <span class="special">-</span> <span class="number">2</span><span class="special">)</span> <span class="special">+</span> <span class="identifier">seq_</span><span class="special">(</span> <span class="identifier">n</span> <span class="special">-</span> <span class="number">1</span><span class="special">);</span>
+ <span class="special">}</span>
+
+ <span class="keyword">int</span> <span class="identifier">par_</span><span class="special">(</span> <span class="keyword">int</span> <span class="identifier">n</span><span class="special">)</span>
+ <span class="special">{</span>
+ <span class="keyword">if</span> <span class="special">(</span> <span class="identifier">n</span> <span class="special">&lt;=</span> <span class="identifier">offset_</span><span class="special">)</span> <span class="keyword">return</span> <span class="identifier">seq_</span><span class="special">(</span> <span class="identifier">n</span><span class="special">);</span>
+ <span class="keyword">else</span>
+ <span class="special">{</span>
+ <span class="identifier">tp</span><span class="special">::</span><span class="identifier">task</span><span class="special">&lt;</span> <span class="keyword">int</span> <span class="special">&gt;</span> <span class="identifier">t1</span><span class="special">(</span>
+ <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">&lt;</span> <span class="identifier">pool_type</span> <span class="special">&gt;().</span><span class="identifier">submit</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">bind</span><span class="special">(</span>
+ <span class="special">&amp;</span> <span class="identifier">fibo</span><span class="special">::</span><span class="identifier">par_</span><span class="special">,</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">ref</span><span class="special">(</span> <span class="special">*</span> <span class="keyword">this</span><span class="special">),</span>
+ <span class="identifier">n</span> <span class="special">-</span> <span class="number">1</span><span class="special">)</span> <span class="special">)</span> <span class="special">);</span>
+ <span class="identifier">tp</span><span class="special">::</span><span class="identifier">task</span><span class="special">&lt;</span> <span class="keyword">int</span> <span class="special">&gt;</span> <span class="identifier">t2</span><span class="special">(</span>
+ <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">&lt;</span> <span class="identifier">pool_type</span> <span class="special">&gt;().</span><span class="identifier">submit</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">bind</span><span class="special">(</span>
+ <span class="special">&amp;</span> <span class="identifier">fibo</span><span class="special">::</span><span class="identifier">par_</span><span class="special">,</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">ref</span><span class="special">(</span> <span class="special">*</span> <span class="keyword">this</span><span class="special">),</span>
+ <span class="identifier">n</span> <span class="special">-</span> <span class="number">2</span><span class="special">)</span> <span class="special">)</span> <span class="special">);</span>
+ <span class="keyword">return</span> <span class="identifier">t1</span><span class="special">.</span><span class="identifier">get</span><span class="special">()</span> <span class="special">+</span> <span class="identifier">t2</span><span class="special">.</span><span class="identifier">get</span><span class="special">();</span>
+ <span class="special">}</span>
+ <span class="special">}</span>
+
+<span class="keyword">public</span><span class="special">:</span>
+ <span class="identifier">fibo</span><span class="special">(</span> <span class="keyword">int</span> <span class="identifier">offset</span><span class="special">)</span>
+ <span class="special">:</span> <span class="identifier">offset_</span><span class="special">(</span> <span class="identifier">offset</span><span class="special">)</span>
+ <span class="special">{}</span>
+
+ <span class="keyword">int</span> <span class="identifier">execute</span><span class="special">(</span> <span class="keyword">int</span> <span class="identifier">n</span><span class="special">)</span>
+ <span class="special">{</span>
+ <span class="keyword">int</span> <span class="identifier">result</span><span class="special">(</span> <span class="identifier">par_</span><span class="special">(</span> <span class="identifier">n</span><span class="special">)</span> <span class="special">);</span>
+ <span class="keyword">return</span> <span class="identifier">result</span><span class="special">;</span>
+ <span class="special">}</span>
+<span class="special">};</span>
+
+<span class="keyword">int</span> <span class="identifier">main</span><span class="special">(</span> <span class="keyword">int</span> <span class="identifier">argc</span><span class="special">,</span> <span class="keyword">char</span> <span class="special">*</span><span class="identifier">argv</span><span class="special">[])</span>
+<span class="special">{</span>
+ <span class="keyword">try</span>
+ <span class="special">{</span>
+ <span class="identifier">pool_type</span> <span class="identifier">pool</span><span class="special">(</span> <span class="identifier">tp</span><span class="special">::</span><span class="identifier">poolsize</span><span class="special">(</span> <span class="number">3</span><span class="special">)</span> <span class="special">);</span>
+ <span class="identifier">fibo</span> <span class="identifier">fib</span><span class="special">(</span> <span class="number">5</span><span class="special">);</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span> <span class="identifier">tp</span><span class="special">::</span><span class="identifier">task</span><span class="special">&lt;</span> <span class="keyword">int</span> <span class="special">&gt;</span> <span class="special">&gt;</span> <span class="identifier">results</span><span class="special">;</span>
+ <span class="identifier">results</span><span class="special">.</span><span class="identifier">reserve</span><span class="special">(</span> <span class="number">40</span><span class="special">);</span>
+
+ <span class="identifier">pt</span><span class="special">::</span><span class="identifier">ptime</span> <span class="identifier">start</span><span class="special">(</span> <span class="identifier">pt</span><span class="special">::</span><span class="identifier">microsec_clock</span><span class="special">::</span><span class="identifier">universal_time</span><span class="special">()</span> <span class="special">);</span>
+
+ <span class="keyword">for</span> <span class="special">(</span> <span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special">&lt;</span> <span class="number">32</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span>
+ <span class="identifier">results</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span>
+ <span class="identifier">pool</span><span class="special">.</span><span class="identifier">submit</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">bind</span><span class="special">(</span>
+ <span class="special">&amp;</span> <span class="identifier">fibo</span><span class="special">::</span><span class="identifier">execute</span><span class="special">,</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">ref</span><span class="special">(</span> <span class="identifier">fib</span><span class="special">),</span>
+ <span class="identifier">i</span><span class="special">)</span> <span class="special">)</span> <span class="special">);</span>
+
+ <span class="keyword">int</span> <span class="identifier">k</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span> <span class="identifier">tp</span><span class="special">::</span><span class="identifier">task</span><span class="special">&lt;</span> <span class="keyword">int</span> <span class="special">&gt;</span> <span class="special">&gt;::</span><span class="identifier">iterator</span> <span class="identifier">e</span><span class="special">(</span> <span class="identifier">results</span><span class="special">.</span><span class="identifier">end</span><span class="special">()</span> <span class="special">);</span>
+ <span class="keyword">for</span> <span class="special">(</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span> <span class="identifier">tp</span><span class="special">::</span><span class="identifier">task</span><span class="special">&lt;</span> <span class="keyword">int</span> <span class="special">&gt;</span> <span class="special">&gt;::</span><span class="identifier">iterator</span> <span class="identifier">i</span><span class="special">(</span> <span class="identifier">results</span><span class="special">.</span><span class="identifier">begin</span><span class="special">()</span> <span class="special">);</span>
+ <span class="identifier">i</span> <span class="special">!=</span> <span class="identifier">e</span><span class="special">;</span>
+ <span class="special">++</span><span class="identifier">i</span><span class="special">)</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"fibonacci "</span> <span class="special">&lt;&lt;</span> <span class="identifier">k</span><span class="special">++</span> <span class="special">&lt;&lt;</span> <span class="string">" == "</span> <span class="special">&lt;&lt;</span> <span class="identifier">i</span><span class="special">-&gt;</span><span class="identifier">get</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
+
+ <span class="identifier">pt</span><span class="special">::</span><span class="identifier">ptime</span> <span class="identifier">stop</span><span class="special">(</span> <span class="identifier">pt</span><span class="special">::</span><span class="identifier">microsec_clock</span><span class="special">::</span><span class="identifier">universal_time</span><span class="special">()</span> <span class="special">);</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="special">(</span> <span class="identifier">stop</span> <span class="special">-</span> <span class="identifier">start</span><span class="special">).</span><span class="identifier">total_milliseconds</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="string">" milli seconds"</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
+
+ <span class="keyword">return</span> <span class="identifier">EXIT_SUCCESS</span><span class="special">;</span>
+ <span class="special">}</span>
+ <span class="keyword">catch</span> <span class="special">(</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">exception</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">e</span><span class="special">)</span>
+ <span class="special">{</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cerr</span> <span class="special">&lt;&lt;</span> <span class="string">"exception: "</span> <span class="special">&lt;&lt;</span> <span class="identifier">e</span><span class="special">.</span><span class="identifier">what</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="special">}</span>
+ <span class="keyword">catch</span> <span class="special">(</span> <span class="special">...</span> <span class="special">)</span>
+ <span class="special">{</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cerr</span> <span class="special">&lt;&lt;</span> <span class="string">"unhandled"</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="special">}</span>
+
+ <span class="keyword">return</span> <span class="identifier">EXIT_FAILURE</span><span class="special">;</span>
+<span class="special">}</span>
+</pre>
+<p>
+ class fibo { private: int offset_;
+ </p>
+<pre class="programlisting"> <span class="keyword">int</span> <span class="identifier">seq_</span><span class="special">(</span> <span class="keyword">int</span> <span class="identifier">n</span><span class="special">)</span>
+ <span class="special">{</span>
+ <span class="keyword">if</span> <span class="special">(</span> <span class="identifier">n</span> <span class="special">&lt;=</span> <span class="number">1</span><span class="special">)</span> <span class="keyword">return</span> <span class="identifier">n</span><span class="special">;</span>
+ <span class="keyword">else</span> <span class="keyword">return</span> <span class="identifier">seq_</span><span class="special">(</span> <span class="identifier">n</span> <span class="special">-</span> <span class="number">2</span><span class="special">)</span> <span class="special">+</span> <span class="identifier">seq_</span><span class="special">(</span> <span class="identifier">n</span> <span class="special">-</span> <span class="number">1</span><span class="special">);</span>
+ <span class="special">}</span>
+
+ <span class="keyword">int</span> <span class="identifier">par_</span><span class="special">(</span> <span class="keyword">int</span> <span class="identifier">n</span><span class="special">)</span>
+ <span class="special">{</span>
+ <span class="keyword">if</span> <span class="special">(</span> <span class="identifier">n</span> <span class="special">&lt;=</span> <span class="identifier">offset_</span><span class="special">)</span> <span class="keyword">return</span> <span class="identifier">seq_</span><span class="special">(</span> <span class="identifier">n</span><span class="special">);</span>
+ <span class="keyword">else</span>
+ <span class="special">{</span>
+ <span class="identifier">tp</span><span class="special">::</span><span class="identifier">task</span><span class="special">&lt;</span> <span class="keyword">int</span> <span class="special">&gt;</span> <span class="identifier">t1</span><span class="special">(</span>
+ <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">&lt;</span> <span class="identifier">pool_type</span> <span class="special">&gt;().</span><span class="identifier">submit</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">bind</span><span class="special">(</span>
+ <span class="special">&amp;</span> <span class="identifier">fibo</span><span class="special">::</span><span class="identifier">par_</span><span class="special">,</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">ref</span><span class="special">(</span> <span class="special">*</span> <span class="keyword">this</span><span class="special">),</span>
+ <span class="identifier">n</span> <span class="special">-</span> <span class="number">1</span><span class="special">)</span> <span class="special">)</span> <span class="special">);</span>
+ <span class="identifier">tp</span><span class="special">::</span><span class="identifier">task</span><span class="special">&lt;</span> <span class="keyword">int</span> <span class="special">&gt;</span> <span class="identifier">t2</span><span class="special">(</span>
+ <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">&lt;</span> <span class="identifier">pool_type</span> <span class="special">&gt;().</span><span class="identifier">submit</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">bind</span><span class="special">(</span>
+ <span class="special">&amp;</span> <span class="identifier">fibo</span><span class="special">::</span><span class="identifier">par_</span><span class="special">,</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">ref</span><span class="special">(</span> <span class="special">*</span> <span class="keyword">this</span><span class="special">),</span>
+ <span class="identifier">n</span> <span class="special">-</span> <span class="number">2</span><span class="special">)</span> <span class="special">)</span> <span class="special">);</span>
+ <span class="keyword">return</span> <span class="identifier">t1</span><span class="special">.</span><span class="identifier">get</span><span class="special">()</span> <span class="special">+</span> <span class="identifier">t2</span><span class="special">.</span><span class="identifier">get</span><span class="special">();</span>
+ <span class="special">}</span>
+ <span class="special">}</span>
+
+<span class="keyword">public</span><span class="special">:</span>
+ <span class="identifier">fibo</span><span class="special">(</span> <span class="keyword">int</span> <span class="identifier">offset</span><span class="special">)</span>
+ <span class="special">:</span> <span class="identifier">offset_</span><span class="special">(</span> <span class="identifier">offset</span><span class="special">)</span>
+ <span class="special">{}</span>
+
+ <span class="keyword">int</span> <span class="identifier">execute</span><span class="special">(</span> <span class="keyword">int</span> <span class="identifier">n</span><span class="special">)</span>
+ <span class="special">{</span>
+ <span class="keyword">int</span> <span class="identifier">result</span><span class="special">(</span> <span class="identifier">par_</span><span class="special">(</span> <span class="identifier">n</span><span class="special">)</span> <span class="special">);</span>
+ <span class="keyword">return</span> <span class="identifier">result</span><span class="special">;</span>
+ <span class="special">}</span>
+<span class="special">};</span>
+
+<span class="keyword">int</span> <span class="identifier">main</span><span class="special">(</span> <span class="keyword">int</span> <span class="identifier">argc</span><span class="special">,</span> <span class="keyword">char</span> <span class="special">*</span><span class="identifier">argv</span><span class="special">[])</span>
+<span class="special">{</span>
+ <span class="keyword">try</span>
+ <span class="special">{</span>
+ <span class="identifier">pool_type</span> <span class="identifier">pool</span><span class="special">(</span> <span class="identifier">tp</span><span class="special">::</span><span class="identifier">poolsize</span><span class="special">(</span> <span class="number">3</span><span class="special">)</span> <span class="special">);</span>
+ <span class="identifier">fibo</span> <span class="identifier">fib</span><span class="special">(</span> <span class="number">5</span><span class="special">);</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span> <span class="identifier">tp</span><span class="special">::</span><span class="identifier">task</span><span class="special">&lt;</span> <span class="keyword">int</span> <span class="special">&gt;</span> <span class="special">&gt;</span> <span class="identifier">results</span><span class="special">;</span>
+ <span class="identifier">results</span><span class="special">.</span><span class="identifier">reserve</span><span class="special">(</span> <span class="number">40</span><span class="special">);</span>
+
+ <span class="identifier">pt</span><span class="special">::</span><span class="identifier">ptime</span> <span class="identifier">start</span><span class="special">(</span> <span class="identifier">pt</span><span class="special">::</span><span class="identifier">microsec_clock</span><span class="special">::</span><span class="identifier">universal_time</span><span class="special">()</span> <span class="special">);</span>
+
+ <span class="keyword">for</span> <span class="special">(</span> <span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special">&lt;</span> <span class="number">32</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span>
+ <span class="identifier">results</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span>
+ <span class="identifier">pool</span><span class="special">.</span><span class="identifier">submit</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">bind</span><span class="special">(</span>
+ <span class="special">&amp;</span> <span class="identifier">fibo</span><span class="special">::</span><span class="identifier">execute</span><span class="special">,</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">ref</span><span class="special">(</span> <span class="identifier">fib</span><span class="special">),</span>
+ <span class="identifier">i</span><span class="special">)</span> <span class="special">)</span> <span class="special">);</span>
+
+ <span class="keyword">int</span> <span class="identifier">k</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span> <span class="identifier">tp</span><span class="special">::</span><span class="identifier">task</span><span class="special">&lt;</span> <span class="keyword">int</span> <span class="special">&gt;</span> <span class="special">&gt;::</span><span class="identifier">iterator</span> <span class="identifier">e</span><span class="special">(</span> <span class="identifier">results</span><span class="special">.</span><span class="identifier">end</span><span class="special">()</span> <span class="special">);</span>
+ <span class="keyword">for</span> <span class="special">(</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span> <span class="identifier">tp</span><span class="special">::</span><span class="identifier">task</span><span class="special">&lt;</span> <span class="keyword">int</span> <span class="special">&gt;</span> <span class="special">&gt;::</span><span class="identifier">iterator</span> <span class="identifier">i</span><span class="special">(</span> <span class="identifier">results</span><span class="special">.</span><span class="identifier">begin</span><span class="special">()</span> <span class="special">);</span>
+ <span class="identifier">i</span> <span class="special">!=</span> <span class="identifier">e</span><span class="special">;</span>
+ <span class="special">++</span><span class="identifier">i</span><span class="special">)</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"fibonacci "</span> <span class="special">&lt;&lt;</span> <span class="identifier">k</span><span class="special">++</span> <span class="special">&lt;&lt;</span> <span class="string">" == "</span> <span class="special">&lt;&lt;</span> <span class="identifier">i</span><span class="special">-&gt;</span><span class="identifier">get</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
+
+ <span class="identifier">pt</span><span class="special">::</span><span class="identifier">ptime</span> <span class="identifier">stop</span><span class="special">(</span> <span class="identifier">pt</span><span class="special">::</span><span class="identifier">microsec_clock</span><span class="special">::</span><span class="identifier">universal_time</span><span class="special">()</span> <span class="special">);</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="special">(</span> <span class="identifier">stop</span> <span class="special">-</span> <span class="identifier">start</span><span class="special">).</span><span class="identifier">total_milliseconds</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="string">" milli seconds"</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
+
+ <span class="keyword">return</span> <span class="identifier">EXIT_SUCCESS</span><span class="special">;</span>
+ <span class="special">}</span>
+ <span class="keyword">catch</span> <span class="special">(</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">exception</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">e</span><span class="special">)</span>
+ <span class="special">{</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cerr</span> <span class="special">&lt;&lt;</span> <span class="string">"exception: "</span> <span class="special">&lt;&lt;</span> <span class="identifier">e</span><span class="special">.</span><span class="identifier">what</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="special">}</span>
+ <span class="keyword">catch</span> <span class="special">(</span> <span class="special">...</span> <span class="special">)</span>
+ <span class="special">{</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cerr</span> <span class="special">&lt;&lt;</span> <span class="string">"unhandled"</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="special">}</span>
+
+ <span class="keyword">return</span> <span class="identifier">EXIT_FAILURE</span><span class="special">;</span>
+<span class="special">}</span>
+</pre>
+<p>
+ int seq<span class="underline">( int n) { if ( n &lt;= 1) return n; else
+ return seq</span>( n - 2) + seq_( n - 1); }
+ </p>
+<pre class="programlisting"> <span class="keyword">int</span> <span class="identifier">par_</span><span class="special">(</span> <span class="keyword">int</span> <span class="identifier">n</span><span class="special">)</span>
+ <span class="special">{</span>
+ <span class="keyword">if</span> <span class="special">(</span> <span class="identifier">n</span> <span class="special">&lt;=</span> <span class="identifier">offset_</span><span class="special">)</span> <span class="keyword">return</span> <span class="identifier">seq_</span><span class="special">(</span> <span class="identifier">n</span><span class="special">);</span>
+ <span class="keyword">else</span>
+ <span class="special">{</span>
+ <span class="identifier">tp</span><span class="special">::</span><span class="identifier">task</span><span class="special">&lt;</span> <span class="keyword">int</span> <span class="special">&gt;</span> <span class="identifier">t1</span><span class="special">(</span>
+ <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">&lt;</span> <span class="identifier">pool_type</span> <span class="special">&gt;().</span><span class="identifier">submit</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">bind</span><span class="special">(</span>
+ <span class="special">&amp;</span> <span class="identifier">fibo</span><span class="special">::</span><span class="identifier">par_</span><span class="special">,</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">ref</span><span class="special">(</span> <span class="special">*</span> <span class="keyword">this</span><span class="special">),</span>
+ <span class="identifier">n</span> <span class="special">-</span> <span class="number">1</span><span class="special">)</span> <span class="special">)</span> <span class="special">);</span>
+ <span class="identifier">tp</span><span class="special">::</span><span class="identifier">task</span><span class="special">&lt;</span> <span class="keyword">int</span> <span class="special">&gt;</span> <span class="identifier">t2</span><span class="special">(</span>
+ <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">&lt;</span> <span class="identifier">pool_type</span> <span class="special">&gt;().</span><span class="identifier">submit</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">bind</span><span class="special">(</span>
+ <span class="special">&amp;</span> <span class="identifier">fibo</span><span class="special">::</span><span class="identifier">par_</span><span class="special">,</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">ref</span><span class="special">(</span> <span class="special">*</span> <span class="keyword">this</span><span class="special">),</span>
+ <span class="identifier">n</span> <span class="special">-</span> <span class="number">2</span><span class="special">)</span> <span class="special">)</span> <span class="special">);</span>
+ <span class="keyword">return</span> <span class="identifier">t1</span><span class="special">.</span><span class="identifier">get</span><span class="special">()</span> <span class="special">+</span> <span class="identifier">t2</span><span class="special">.</span><span class="identifier">get</span><span class="special">();</span>
+ <span class="special">}</span>
+ <span class="special">}</span>
 
- <span class="keyword">int</span> <span class="identifier">seq_</span><span class="special">(</span> <span class="keyword">int</span> <span class="identifier">n</span><span class="special">)</span>
- <span class="special">{</span>
- <span class="keyword">if</span> <span class="special">(</span> <span class="identifier">n</span> <span class="special">&lt;=</span> <span class="number">1</span><span class="special">)</span> <span class="keyword">return</span> <span class="identifier">n</span><span class="special">;</span>
- <span class="keyword">else</span> <span class="keyword">return</span> <span class="identifier">seq_</span><span class="special">(</span> <span class="identifier">n</span> <span class="special">-</span> <span class="number">2</span><span class="special">)</span> <span class="special">+</span> <span class="identifier">seq_</span><span class="special">(</span> <span class="identifier">n</span> <span class="special">-</span> <span class="number">1</span><span class="special">);</span>
- <span class="special">}</span>
-
- <span class="keyword">int</span> <span class="identifier">par_</span><span class="special">(</span> <span class="keyword">int</span> <span class="identifier">n</span><span class="special">)</span>
- <span class="special">{</span>
- <span class="keyword">if</span> <span class="special">(</span> <span class="identifier">n</span> <span class="special">&lt;=</span> <span class="identifier">cutoff_</span><span class="special">)</span> <span class="keyword">return</span> <span class="identifier">seq_</span><span class="special">(</span> <span class="identifier">n</span><span class="special">);</span>
- <span class="keyword">else</span>
- <span class="special">{</span>
- <span class="comment">// fork a new sub-action t1 in pool
-</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">tp</span><span class="special">::</span><span class="identifier">task</span><span class="special">&lt;</span> <span class="keyword">int</span> <span class="special">&gt;</span> <span class="identifier">t1</span><span class="special">(</span>
- <span class="identifier">pool_</span><span class="special">.</span><span class="identifier">submit</span><span class="special">(</span>
- <span class="identifier">boost</span><span class="special">::</span><span class="identifier">bind</span><span class="special">(</span>
- <span class="special">&amp;</span> <span class="identifier">fibo</span><span class="special">::</span><span class="identifier">par_</span><span class="special">,</span>
- <span class="identifier">boost</span><span class="special">::</span><span class="identifier">ref</span><span class="special">(</span> <span class="special">*</span> <span class="keyword">this</span><span class="special">),</span>
- <span class="identifier">n</span> <span class="special">-</span> <span class="number">1</span><span class="special">)</span> <span class="special">)</span> <span class="special">);</span>
-
- <span class="comment">// fork a new sub-action t2 in pool
-</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">tp</span><span class="special">::</span><span class="identifier">task</span><span class="special">&lt;</span> <span class="keyword">int</span> <span class="special">&gt;</span> <span class="identifier">t1</span><span class="special">(</span>
- <span class="identifier">pool_</span><span class="special">.</span><span class="identifier">submit</span><span class="special">(</span>
- <span class="identifier">boost</span><span class="special">::</span><span class="identifier">bind</span><span class="special">(</span>
- <span class="special">&amp;</span> <span class="identifier">fibo</span><span class="special">::</span><span class="identifier">par_</span><span class="special">,</span>
- <span class="identifier">boost</span><span class="special">::</span><span class="identifier">ref</span><span class="special">(</span> <span class="special">*</span> <span class="keyword">this</span><span class="special">),</span>
- <span class="identifier">n</span> <span class="special">-</span> <span class="number">2</span><span class="special">)</span> <span class="special">)</span> <span class="special">);</span>
-
- <span class="comment">// joining the result of sub-action t1 and t2
-</span> <span class="keyword">return</span> <span class="identifier">t1</span><span class="special">.</span><span class="identifier">get</span><span class="special">()</span> <span class="special">+</span> <span class="identifier">t2</span><span class="special">.</span><span class="identifier">get</span><span class="special">();</span>
- <span class="special">}</span>
- <span class="special">}</span>
 <span class="keyword">public</span><span class="special">:</span>
- <span class="identifier">fibo</span><span class="special">(</span> <span class="identifier">pool_type</span> <span class="special">&amp;</span> <span class="identifier">pool</span><span class="special">,</span> <span class="keyword">int</span> <span class="identifier">cutoff</span><span class="special">)</span>
- <span class="special">:</span> <span class="identifier">pool_</span><span class="special">(</span> <span class="identifier">pool</span><span class="special">),</span> <span class="identifier">cutoff_</span><span class="special">(</span> <span class="identifier">cutoff</span><span class="special">)</span>
- <span class="special">{}</span>
-
- <span class="keyword">int</span> <span class="identifier">execute</span><span class="special">(</span> <span class="keyword">int</span> <span class="identifier">n</span><span class="special">)</span>
- <span class="special">{</span>
- <span class="keyword">int</span> <span class="identifier">result</span><span class="special">(</span> <span class="identifier">par_</span><span class="special">(</span> <span class="identifier">n</span><span class="special">)</span> <span class="special">);</span>
- <span class="keyword">return</span> <span class="identifier">result</span><span class="special">;</span>
- <span class="special">}</span>
-<span class="special">};</span>
-
-<span class="comment">// creates a threadpool with two worker-threads
-</span><span class="identifier">pool_type</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">poolsize</span><span class="special">(</span> <span class="number">2</span><span class="special">)</span> <span class="special">);</span>
-
-<span class="identifier">fibo</span> <span class="identifier">fib</span><span class="special">(</span> <span class="identifier">pool</span><span class="special">,</span> <span class="number">1</span><span class="special">);</span>
-
-<span class="comment">// submit an action
-</span><span class="comment">// which calculates the fibonacci number of 10
-</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">tp</span><span class="special">::</span><span class="identifier">task</span><span class="special">&lt;</span> <span class="keyword">int</span> <span class="special">&gt;</span> <span class="identifier">t</span><span class="special">(</span>
- <span class="identifier">pool</span><span class="special">.</span><span class="identifier">submit</span><span class="special">(</span>
- <span class="identifier">boost</span><span class="special">::</span><span class="identifier">bind</span><span class="special">(</span>
- <span class="special">&amp;</span> <span class="identifier">fibo</span><span class="special">::</span><span class="identifier">execute</span><span class="special">,</span>
- <span class="identifier">boost</span><span class="special">::</span><span class="identifier">ref</span><span class="special">(</span> <span class="identifier">fib</span><span class="special">),</span>
- <span class="number">10</span><span class="special">)</span> <span class="special">)</span> <span class="special">);</span>
+ <span class="identifier">fibo</span><span class="special">(</span> <span class="keyword">int</span> <span class="identifier">offset</span><span class="special">)</span>
+ <span class="special">:</span> <span class="identifier">offset_</span><span class="special">(</span> <span class="identifier">offset</span><span class="special">)</span>
+ <span class="special">{}</span>
+
+ <span class="keyword">int</span> <span class="identifier">execute</span><span class="special">(</span> <span class="keyword">int</span> <span class="identifier">n</span><span class="special">)</span>
+ <span class="special">{</span>
+ <span class="keyword">int</span> <span class="identifier">result</span><span class="special">(</span> <span class="identifier">par_</span><span class="special">(</span> <span class="identifier">n</span><span class="special">)</span> <span class="special">);</span>
+ <span class="keyword">return</span> <span class="identifier">result</span><span class="special">;</span>
+ <span class="special">}</span>
+<span class="special">};</span>
+
+<span class="keyword">int</span> <span class="identifier">main</span><span class="special">(</span> <span class="keyword">int</span> <span class="identifier">argc</span><span class="special">,</span> <span class="keyword">char</span> <span class="special">*</span><span class="identifier">argv</span><span class="special">[])</span>
+<span class="special">{</span>
+ <span class="keyword">try</span>
+ <span class="special">{</span>
+ <span class="identifier">pool_type</span> <span class="identifier">pool</span><span class="special">(</span> <span class="identifier">tp</span><span class="special">::</span><span class="identifier">poolsize</span><span class="special">(</span> <span class="number">3</span><span class="special">)</span> <span class="special">);</span>
+ <span class="identifier">fibo</span> <span class="identifier">fib</span><span class="special">(</span> <span class="number">5</span><span class="special">);</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span> <span class="identifier">tp</span><span class="special">::</span><span class="identifier">task</span><span class="special">&lt;</span> <span class="keyword">int</span> <span class="special">&gt;</span> <span class="special">&gt;</span> <span class="identifier">results</span><span class="special">;</span>
+ <span class="identifier">results</span><span class="special">.</span><span class="identifier">reserve</span><span class="special">(</span> <span class="number">40</span><span class="special">);</span>
+
+ <span class="identifier">pt</span><span class="special">::</span><span class="identifier">ptime</span> <span class="identifier">start</span><span class="special">(</span> <span class="identifier">pt</span><span class="special">::</span><span class="identifier">microsec_clock</span><span class="special">::</span><span class="identifier">universal_time</span><span class="special">()</span> <span class="special">);</span>
+
+ <span class="keyword">for</span> <span class="special">(</span> <span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special">&lt;</span> <span class="number">32</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span>
+ <span class="identifier">results</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span>
+ <span class="identifier">pool</span><span class="special">.</span><span class="identifier">submit</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">bind</span><span class="special">(</span>
+ <span class="special">&amp;</span> <span class="identifier">fibo</span><span class="special">::</span><span class="identifier">execute</span><span class="special">,</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">ref</span><span class="special">(</span> <span class="identifier">fib</span><span class="special">),</span>
+ <span class="identifier">i</span><span class="special">)</span> <span class="special">)</span> <span class="special">);</span>
+
+ <span class="keyword">int</span> <span class="identifier">k</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span> <span class="identifier">tp</span><span class="special">::</span><span class="identifier">task</span><span class="special">&lt;</span> <span class="keyword">int</span> <span class="special">&gt;</span> <span class="special">&gt;::</span><span class="identifier">iterator</span> <span class="identifier">e</span><span class="special">(</span> <span class="identifier">results</span><span class="special">.</span><span class="identifier">end</span><span class="special">()</span> <span class="special">);</span>
+ <span class="keyword">for</span> <span class="special">(</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span> <span class="identifier">tp</span><span class="special">::</span><span class="identifier">task</span><span class="special">&lt;</span> <span class="keyword">int</span> <span class="special">&gt;</span> <span class="special">&gt;::</span><span class="identifier">iterator</span> <span class="identifier">i</span><span class="special">(</span> <span class="identifier">results</span><span class="special">.</span><span class="identifier">begin</span><span class="special">()</span> <span class="special">);</span>
+ <span class="identifier">i</span> <span class="special">!=</span> <span class="identifier">e</span><span class="special">;</span>
+ <span class="special">++</span><span class="identifier">i</span><span class="special">)</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"fibonacci "</span> <span class="special">&lt;&lt;</span> <span class="identifier">k</span><span class="special">++</span> <span class="special">&lt;&lt;</span> <span class="string">" == "</span> <span class="special">&lt;&lt;</span> <span class="identifier">i</span><span class="special">-&gt;</span><span class="identifier">get</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
+
+ <span class="identifier">pt</span><span class="special">::</span><span class="identifier">ptime</span> <span class="identifier">stop</span><span class="special">(</span> <span class="identifier">pt</span><span class="special">::</span><span class="identifier">microsec_clock</span><span class="special">::</span><span class="identifier">universal_time</span><span class="special">()</span> <span class="special">);</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="special">(</span> <span class="identifier">stop</span> <span class="special">-</span> <span class="identifier">start</span><span class="special">).</span><span class="identifier">total_milliseconds</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="string">" milli seconds"</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
+
+ <span class="keyword">return</span> <span class="identifier">EXIT_SUCCESS</span><span class="special">;</span>
+ <span class="special">}</span>
+ <span class="keyword">catch</span> <span class="special">(</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">exception</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">e</span><span class="special">)</span>
+ <span class="special">{</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cerr</span> <span class="special">&lt;&lt;</span> <span class="string">"exception: "</span> <span class="special">&lt;&lt;</span> <span class="identifier">e</span><span class="special">.</span><span class="identifier">what</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="special">}</span>
+ <span class="keyword">catch</span> <span class="special">(</span> <span class="special">...</span> <span class="special">)</span>
+ <span class="special">{</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cerr</span> <span class="special">&lt;&lt;</span> <span class="string">"unhandled"</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="special">}</span>
+
+ <span class="keyword">return</span> <span class="identifier">EXIT_FAILURE</span><span class="special">;</span>
+<span class="special">}</span>
+</pre>
+<p>
+ int par<span class="underline">( int n) { if ( n &lt;= offset</span>)
+ return seq_( n); else { tp::task&lt; int &gt; t1( boost::this_task::get_thread_pool&lt;
+ pool<span class="underline">type &gt;().submit( boost::bind( &amp; fibo::par</span>,
+ boost::ref( * this), n - 1) ) ); tp::task&lt; int &gt; t2( boost::this_task::get_thread_pool&lt;
+ pool<span class="underline">type &gt;().submit( boost::bind( &amp; fibo::par</span>,
+ boost::ref( * this), n - 2) ) ); return t1.get() + t2.get(); } }
+ </p>
+<pre class="programlisting"><span class="keyword">public</span><span class="special">:</span>
+ <span class="identifier">fibo</span><span class="special">(</span> <span class="keyword">int</span> <span class="identifier">offset</span><span class="special">)</span>
+ <span class="special">:</span> <span class="identifier">offset_</span><span class="special">(</span> <span class="identifier">offset</span><span class="special">)</span>
+ <span class="special">{}</span>
+
+ <span class="keyword">int</span> <span class="identifier">execute</span><span class="special">(</span> <span class="keyword">int</span> <span class="identifier">n</span><span class="special">)</span>
+ <span class="special">{</span>
+ <span class="keyword">int</span> <span class="identifier">result</span><span class="special">(</span> <span class="identifier">par_</span><span class="special">(</span> <span class="identifier">n</span><span class="special">)</span> <span class="special">);</span>
+ <span class="keyword">return</span> <span class="identifier">result</span><span class="special">;</span>
+ <span class="special">}</span>
+<span class="special">};</span>
+
+<span class="keyword">int</span> <span class="identifier">main</span><span class="special">(</span> <span class="keyword">int</span> <span class="identifier">argc</span><span class="special">,</span> <span class="keyword">char</span> <span class="special">*</span><span class="identifier">argv</span><span class="special">[])</span>
+<span class="special">{</span>
+ <span class="keyword">try</span>
+ <span class="special">{</span>
+ <span class="identifier">pool_type</span> <span class="identifier">pool</span><span class="special">(</span> <span class="identifier">tp</span><span class="special">::</span><span class="identifier">poolsize</span><span class="special">(</span> <span class="number">3</span><span class="special">)</span> <span class="special">);</span>
+ <span class="identifier">fibo</span> <span class="identifier">fib</span><span class="special">(</span> <span class="number">5</span><span class="special">);</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span> <span class="identifier">tp</span><span class="special">::</span><span class="identifier">task</span><span class="special">&lt;</span> <span class="keyword">int</span> <span class="special">&gt;</span> <span class="special">&gt;</span> <span class="identifier">results</span><span class="special">;</span>
+ <span class="identifier">results</span><span class="special">.</span><span class="identifier">reserve</span><span class="special">(</span> <span class="number">40</span><span class="special">);</span>
+
+ <span class="identifier">pt</span><span class="special">::</span><span class="identifier">ptime</span> <span class="identifier">start</span><span class="special">(</span> <span class="identifier">pt</span><span class="special">::</span><span class="identifier">microsec_clock</span><span class="special">::</span><span class="identifier">universal_time</span><span class="special">()</span> <span class="special">);</span>
+
+ <span class="keyword">for</span> <span class="special">(</span> <span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special">&lt;</span> <span class="number">32</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span>
+ <span class="identifier">results</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span>
+ <span class="identifier">pool</span><span class="special">.</span><span class="identifier">submit</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">bind</span><span class="special">(</span>
+ <span class="special">&amp;</span> <span class="identifier">fibo</span><span class="special">::</span><span class="identifier">execute</span><span class="special">,</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">ref</span><span class="special">(</span> <span class="identifier">fib</span><span class="special">),</span>
+ <span class="identifier">i</span><span class="special">)</span> <span class="special">)</span> <span class="special">);</span>
+
+ <span class="keyword">int</span> <span class="identifier">k</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span> <span class="identifier">tp</span><span class="special">::</span><span class="identifier">task</span><span class="special">&lt;</span> <span class="keyword">int</span> <span class="special">&gt;</span> <span class="special">&gt;::</span><span class="identifier">iterator</span> <span class="identifier">e</span><span class="special">(</span> <span class="identifier">results</span><span class="special">.</span><span class="identifier">end</span><span class="special">()</span> <span class="special">);</span>
+ <span class="keyword">for</span> <span class="special">(</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span> <span class="identifier">tp</span><span class="special">::</span><span class="identifier">task</span><span class="special">&lt;</span> <span class="keyword">int</span> <span class="special">&gt;</span> <span class="special">&gt;::</span><span class="identifier">iterator</span> <span class="identifier">i</span><span class="special">(</span> <span class="identifier">results</span><span class="special">.</span><span class="identifier">begin</span><span class="special">()</span> <span class="special">);</span>
+ <span class="identifier">i</span> <span class="special">!=</span> <span class="identifier">e</span><span class="special">;</span>
+ <span class="special">++</span><span class="identifier">i</span><span class="special">)</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"fibonacci "</span> <span class="special">&lt;&lt;</span> <span class="identifier">k</span><span class="special">++</span> <span class="special">&lt;&lt;</span> <span class="string">" == "</span> <span class="special">&lt;&lt;</span> <span class="identifier">i</span><span class="special">-&gt;</span><span class="identifier">get</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
+
+ <span class="identifier">pt</span><span class="special">::</span><span class="identifier">ptime</span> <span class="identifier">stop</span><span class="special">(</span> <span class="identifier">pt</span><span class="special">::</span><span class="identifier">microsec_clock</span><span class="special">::</span><span class="identifier">universal_time</span><span class="special">()</span> <span class="special">);</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="special">(</span> <span class="identifier">stop</span> <span class="special">-</span> <span class="identifier">start</span><span class="special">).</span><span class="identifier">total_milliseconds</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="string">" milli seconds"</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
+
+ <span class="keyword">return</span> <span class="identifier">EXIT_SUCCESS</span><span class="special">;</span>
+ <span class="special">}</span>
+ <span class="keyword">catch</span> <span class="special">(</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">exception</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">e</span><span class="special">)</span>
+ <span class="special">{</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cerr</span> <span class="special">&lt;&lt;</span> <span class="string">"exception: "</span> <span class="special">&lt;&lt;</span> <span class="identifier">e</span><span class="special">.</span><span class="identifier">what</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="special">}</span>
+ <span class="keyword">catch</span> <span class="special">(</span> <span class="special">...</span> <span class="special">)</span>
+ <span class="special">{</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cerr</span> <span class="special">&lt;&lt;</span> <span class="string">"unhandled"</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="special">}</span>
+
+ <span class="keyword">return</span> <span class="identifier">EXIT_FAILURE</span><span class="special">;</span>
+<span class="special">}</span>
+</pre>
+<p>
+ public: fibo( int offset) : offset_( offset) {}
+ </p>
+<pre class="programlisting"> <span class="keyword">int</span> <span class="identifier">execute</span><span class="special">(</span> <span class="keyword">int</span> <span class="identifier">n</span><span class="special">)</span>
+ <span class="special">{</span>
+ <span class="keyword">int</span> <span class="identifier">result</span><span class="special">(</span> <span class="identifier">par_</span><span class="special">(</span> <span class="identifier">n</span><span class="special">)</span> <span class="special">);</span>
+ <span class="keyword">return</span> <span class="identifier">result</span><span class="special">;</span>
+ <span class="special">}</span>
+<span class="special">};</span>
+
+<span class="keyword">int</span> <span class="identifier">main</span><span class="special">(</span> <span class="keyword">int</span> <span class="identifier">argc</span><span class="special">,</span> <span class="keyword">char</span> <span class="special">*</span><span class="identifier">argv</span><span class="special">[])</span>
+<span class="special">{</span>
+ <span class="keyword">try</span>
+ <span class="special">{</span>
+ <span class="identifier">pool_type</span> <span class="identifier">pool</span><span class="special">(</span> <span class="identifier">tp</span><span class="special">::</span><span class="identifier">poolsize</span><span class="special">(</span> <span class="number">3</span><span class="special">)</span> <span class="special">);</span>
+ <span class="identifier">fibo</span> <span class="identifier">fib</span><span class="special">(</span> <span class="number">5</span><span class="special">);</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span> <span class="identifier">tp</span><span class="special">::</span><span class="identifier">task</span><span class="special">&lt;</span> <span class="keyword">int</span> <span class="special">&gt;</span> <span class="special">&gt;</span> <span class="identifier">results</span><span class="special">;</span>
+ <span class="identifier">results</span><span class="special">.</span><span class="identifier">reserve</span><span class="special">(</span> <span class="number">40</span><span class="special">);</span>
+
+ <span class="identifier">pt</span><span class="special">::</span><span class="identifier">ptime</span> <span class="identifier">start</span><span class="special">(</span> <span class="identifier">pt</span><span class="special">::</span><span class="identifier">microsec_clock</span><span class="special">::</span><span class="identifier">universal_time</span><span class="special">()</span> <span class="special">);</span>
+
+ <span class="keyword">for</span> <span class="special">(</span> <span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special">&lt;</span> <span class="number">32</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span>
+ <span class="identifier">results</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span>
+ <span class="identifier">pool</span><span class="special">.</span><span class="identifier">submit</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">bind</span><span class="special">(</span>
+ <span class="special">&amp;</span> <span class="identifier">fibo</span><span class="special">::</span><span class="identifier">execute</span><span class="special">,</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">ref</span><span class="special">(</span> <span class="identifier">fib</span><span class="special">),</span>
+ <span class="identifier">i</span><span class="special">)</span> <span class="special">)</span> <span class="special">);</span>
+
+ <span class="keyword">int</span> <span class="identifier">k</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span> <span class="identifier">tp</span><span class="special">::</span><span class="identifier">task</span><span class="special">&lt;</span> <span class="keyword">int</span> <span class="special">&gt;</span> <span class="special">&gt;::</span><span class="identifier">iterator</span> <span class="identifier">e</span><span class="special">(</span> <span class="identifier">results</span><span class="special">.</span><span class="identifier">end</span><span class="special">()</span> <span class="special">);</span>
+ <span class="keyword">for</span> <span class="special">(</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span> <span class="identifier">tp</span><span class="special">::</span><span class="identifier">task</span><span class="special">&lt;</span> <span class="keyword">int</span> <span class="special">&gt;</span> <span class="special">&gt;::</span><span class="identifier">iterator</span> <span class="identifier">i</span><span class="special">(</span> <span class="identifier">results</span><span class="special">.</span><span class="identifier">begin</span><span class="special">()</span> <span class="special">);</span>
+ <span class="identifier">i</span> <span class="special">!=</span> <span class="identifier">e</span><span class="special">;</span>
+ <span class="special">++</span><span class="identifier">i</span><span class="special">)</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"fibonacci "</span> <span class="special">&lt;&lt;</span> <span class="identifier">k</span><span class="special">++</span> <span class="special">&lt;&lt;</span> <span class="string">" == "</span> <span class="special">&lt;&lt;</span> <span class="identifier">i</span><span class="special">-&gt;</span><span class="identifier">get</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
+
+ <span class="identifier">pt</span><span class="special">::</span><span class="identifier">ptime</span> <span class="identifier">stop</span><span class="special">(</span> <span class="identifier">pt</span><span class="special">::</span><span class="identifier">microsec_clock</span><span class="special">::</span><span class="identifier">universal_time</span><span class="special">()</span> <span class="special">);</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="special">(</span> <span class="identifier">stop</span> <span class="special">-</span> <span class="identifier">start</span><span class="special">).</span><span class="identifier">total_milliseconds</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="string">" milli seconds"</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
+
+ <span class="keyword">return</span> <span class="identifier">EXIT_SUCCESS</span><span class="special">;</span>
+ <span class="special">}</span>
+ <span class="keyword">catch</span> <span class="special">(</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">exception</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">e</span><span class="special">)</span>
+ <span class="special">{</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cerr</span> <span class="special">&lt;&lt;</span> <span class="string">"exception: "</span> <span class="special">&lt;&lt;</span> <span class="identifier">e</span><span class="special">.</span><span class="identifier">what</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="special">}</span>
+ <span class="keyword">catch</span> <span class="special">(</span> <span class="special">...</span> <span class="special">)</span>
+ <span class="special">{</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cerr</span> <span class="special">&lt;&lt;</span> <span class="string">"unhandled"</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="special">}</span>
 
-<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">t</span><span class="special">.</span><span class="identifier">get</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="comment">// prints 55
-</span></pre>
+ <span class="keyword">return</span> <span class="identifier">EXIT_FAILURE</span><span class="special">;</span>
+<span class="special">}</span>
+</pre>
+<p>
+ int execute( int n) { int result( par_( n) ); return result; } };
+ </p>
+<pre class="programlisting"><span class="keyword">int</span> <span class="identifier">main</span><span class="special">(</span> <span class="keyword">int</span> <span class="identifier">argc</span><span class="special">,</span> <span class="keyword">char</span> <span class="special">*</span><span class="identifier">argv</span><span class="special">[])</span>
+<span class="special">{</span>
+ <span class="keyword">try</span>
+ <span class="special">{</span>
+ <span class="identifier">pool_type</span> <span class="identifier">pool</span><span class="special">(</span> <span class="identifier">tp</span><span class="special">::</span><span class="identifier">poolsize</span><span class="special">(</span> <span class="number">3</span><span class="special">)</span> <span class="special">);</span>
+ <span class="identifier">fibo</span> <span class="identifier">fib</span><span class="special">(</span> <span class="number">5</span><span class="special">);</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span> <span class="identifier">tp</span><span class="special">::</span><span class="identifier">task</span><span class="special">&lt;</span> <span class="keyword">int</span> <span class="special">&gt;</span> <span class="special">&gt;</span> <span class="identifier">results</span><span class="special">;</span>
+ <span class="identifier">results</span><span class="special">.</span><span class="identifier">reserve</span><span class="special">(</span> <span class="number">40</span><span class="special">);</span>
+
+ <span class="identifier">pt</span><span class="special">::</span><span class="identifier">ptime</span> <span class="identifier">start</span><span class="special">(</span> <span class="identifier">pt</span><span class="special">::</span><span class="identifier">microsec_clock</span><span class="special">::</span><span class="identifier">universal_time</span><span class="special">()</span> <span class="special">);</span>
+
+ <span class="keyword">for</span> <span class="special">(</span> <span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special">&lt;</span> <span class="number">32</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span>
+ <span class="identifier">results</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span>
+ <span class="identifier">pool</span><span class="special">.</span><span class="identifier">submit</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">bind</span><span class="special">(</span>
+ <span class="special">&amp;</span> <span class="identifier">fibo</span><span class="special">::</span><span class="identifier">execute</span><span class="special">,</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">ref</span><span class="special">(</span> <span class="identifier">fib</span><span class="special">),</span>
+ <span class="identifier">i</span><span class="special">)</span> <span class="special">)</span> <span class="special">);</span>
+
+ <span class="keyword">int</span> <span class="identifier">k</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span> <span class="identifier">tp</span><span class="special">::</span><span class="identifier">task</span><span class="special">&lt;</span> <span class="keyword">int</span> <span class="special">&gt;</span> <span class="special">&gt;::</span><span class="identifier">iterator</span> <span class="identifier">e</span><span class="special">(</span> <span class="identifier">results</span><span class="special">.</span><span class="identifier">end</span><span class="special">()</span> <span class="special">);</span>
+ <span class="keyword">for</span> <span class="special">(</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span> <span class="identifier">tp</span><span class="special">::</span><span class="identifier">task</span><span class="special">&lt;</span> <span class="keyword">int</span> <span class="special">&gt;</span> <span class="special">&gt;::</span><span class="identifier">iterator</span> <span class="identifier">i</span><span class="special">(</span> <span class="identifier">results</span><span class="special">.</span><span class="identifier">begin</span><span class="special">()</span> <span class="special">);</span>
+ <span class="identifier">i</span> <span class="special">!=</span> <span class="identifier">e</span><span class="special">;</span>
+ <span class="special">++</span><span class="identifier">i</span><span class="special">)</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"fibonacci "</span> <span class="special">&lt;&lt;</span> <span class="identifier">k</span><span class="special">++</span> <span class="special">&lt;&lt;</span> <span class="string">" == "</span> <span class="special">&lt;&lt;</span> <span class="identifier">i</span><span class="special">-&gt;</span><span class="identifier">get</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
+
+ <span class="identifier">pt</span><span class="special">::</span><span class="identifier">ptime</span> <span class="identifier">stop</span><span class="special">(</span> <span class="identifier">pt</span><span class="special">::</span><span class="identifier">microsec_clock</span><span class="special">::</span><span class="identifier">universal_time</span><span class="special">()</span> <span class="special">);</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="special">(</span> <span class="identifier">stop</span> <span class="special">-</span> <span class="identifier">start</span><span class="special">).</span><span class="identifier">total_milliseconds</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="string">" milli seconds"</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
+
+ <span class="keyword">return</span> <span class="identifier">EXIT_SUCCESS</span><span class="special">;</span>
+ <span class="special">}</span>
+ <span class="keyword">catch</span> <span class="special">(</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">exception</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">e</span><span class="special">)</span>
+ <span class="special">{</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cerr</span> <span class="special">&lt;&lt;</span> <span class="string">"exception: "</span> <span class="special">&lt;&lt;</span> <span class="identifier">e</span><span class="special">.</span><span class="identifier">what</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="special">}</span>
+ <span class="keyword">catch</span> <span class="special">(</span> <span class="special">...</span> <span class="special">)</span>
+ <span class="special">{</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cerr</span> <span class="special">&lt;&lt;</span> <span class="string">"unhandled"</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="special">}</span>
+
+ <span class="keyword">return</span> <span class="identifier">EXIT_FAILURE</span><span class="special">;</span>
+<span class="special">}</span>
+</pre>
+<p>
+ int main( int argc, char *argv[]) { try { pool_type pool( tp::poolsize( 3)
+ ); fibo fib( 5); std::vector&lt; tp::task&lt; int &gt; &gt; results; results.reserve(
+ 40);
+ </p>
+<pre class="programlisting"> <span class="identifier">pt</span><span class="special">::</span><span class="identifier">ptime</span> <span class="identifier">start</span><span class="special">(</span> <span class="identifier">pt</span><span class="special">::</span><span class="identifier">microsec_clock</span><span class="special">::</span><span class="identifier">universal_time</span><span class="special">()</span> <span class="special">);</span>
+
+ <span class="keyword">for</span> <span class="special">(</span> <span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special">&lt;</span> <span class="number">32</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span>
+ <span class="identifier">results</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span>
+ <span class="identifier">pool</span><span class="special">.</span><span class="identifier">submit</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">bind</span><span class="special">(</span>
+ <span class="special">&amp;</span> <span class="identifier">fibo</span><span class="special">::</span><span class="identifier">execute</span><span class="special">,</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">ref</span><span class="special">(</span> <span class="identifier">fib</span><span class="special">),</span>
+ <span class="identifier">i</span><span class="special">)</span> <span class="special">)</span> <span class="special">);</span>
+
+ <span class="keyword">int</span> <span class="identifier">k</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span> <span class="identifier">tp</span><span class="special">::</span><span class="identifier">task</span><span class="special">&lt;</span> <span class="keyword">int</span> <span class="special">&gt;</span> <span class="special">&gt;::</span><span class="identifier">iterator</span> <span class="identifier">e</span><span class="special">(</span> <span class="identifier">results</span><span class="special">.</span><span class="identifier">end</span><span class="special">()</span> <span class="special">);</span>
+ <span class="keyword">for</span> <span class="special">(</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span> <span class="identifier">tp</span><span class="special">::</span><span class="identifier">task</span><span class="special">&lt;</span> <span class="keyword">int</span> <span class="special">&gt;</span> <span class="special">&gt;::</span><span class="identifier">iterator</span> <span class="identifier">i</span><span class="special">(</span> <span class="identifier">results</span><span class="special">.</span><span class="identifier">begin</span><span class="special">()</span> <span class="special">);</span>
+ <span class="identifier">i</span> <span class="special">!=</span> <span class="identifier">e</span><span class="special">;</span>
+ <span class="special">++</span><span class="identifier">i</span><span class="special">)</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"fibonacci "</span> <span class="special">&lt;&lt;</span> <span class="identifier">k</span><span class="special">++</span> <span class="special">&lt;&lt;</span> <span class="string">" == "</span> <span class="special">&lt;&lt;</span> <span class="identifier">i</span><span class="special">-&gt;</span><span class="identifier">get</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
+
+ <span class="identifier">pt</span><span class="special">::</span><span class="identifier">ptime</span> <span class="identifier">stop</span><span class="special">(</span> <span class="identifier">pt</span><span class="special">::</span><span class="identifier">microsec_clock</span><span class="special">::</span><span class="identifier">universal_time</span><span class="special">()</span> <span class="special">);</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="special">(</span> <span class="identifier">stop</span> <span class="special">-</span> <span class="identifier">start</span><span class="special">).</span><span class="identifier">total_milliseconds</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="string">" milli seconds"</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
+
+ <span class="keyword">return</span> <span class="identifier">EXIT_SUCCESS</span><span class="special">;</span>
+ <span class="special">}</span>
+ <span class="keyword">catch</span> <span class="special">(</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">exception</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">e</span><span class="special">)</span>
+ <span class="special">{</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cerr</span> <span class="special">&lt;&lt;</span> <span class="string">"exception: "</span> <span class="special">&lt;&lt;</span> <span class="identifier">e</span><span class="special">.</span><span class="identifier">what</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="special">}</span>
+ <span class="keyword">catch</span> <span class="special">(</span> <span class="special">...</span> <span class="special">)</span>
+ <span class="special">{</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cerr</span> <span class="special">&lt;&lt;</span> <span class="string">"unhandled"</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="special">}</span>
+
+ <span class="keyword">return</span> <span class="identifier">EXIT_FAILURE</span><span class="special">;</span>
+<span class="special">}</span>
+</pre>
+<p>
+ pt::ptime start( pt::microsec_clock::universal_time() );
+ </p>
+<pre class="programlisting"> <span class="keyword">for</span> <span class="special">(</span> <span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special">&lt;</span> <span class="number">32</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span>
+ <span class="identifier">results</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span>
+ <span class="identifier">pool</span><span class="special">.</span><span class="identifier">submit</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">bind</span><span class="special">(</span>
+ <span class="special">&amp;</span> <span class="identifier">fibo</span><span class="special">::</span><span class="identifier">execute</span><span class="special">,</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">ref</span><span class="special">(</span> <span class="identifier">fib</span><span class="special">),</span>
+ <span class="identifier">i</span><span class="special">)</span> <span class="special">)</span> <span class="special">);</span>
+
+ <span class="keyword">int</span> <span class="identifier">k</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span> <span class="identifier">tp</span><span class="special">::</span><span class="identifier">task</span><span class="special">&lt;</span> <span class="keyword">int</span> <span class="special">&gt;</span> <span class="special">&gt;::</span><span class="identifier">iterator</span> <span class="identifier">e</span><span class="special">(</span> <span class="identifier">results</span><span class="special">.</span><span class="identifier">end</span><span class="special">()</span> <span class="special">);</span>
+ <span class="keyword">for</span> <span class="special">(</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span> <span class="identifier">tp</span><span class="special">::</span><span class="identifier">task</span><span class="special">&lt;</span> <span class="keyword">int</span> <span class="special">&gt;</span> <span class="special">&gt;::</span><span class="identifier">iterator</span> <span class="identifier">i</span><span class="special">(</span> <span class="identifier">results</span><span class="special">.</span><span class="identifier">begin</span><span class="special">()</span> <span class="special">);</span>
+ <span class="identifier">i</span> <span class="special">!=</span> <span class="identifier">e</span><span class="special">;</span>
+ <span class="special">++</span><span class="identifier">i</span><span class="special">)</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"fibonacci "</span> <span class="special">&lt;&lt;</span> <span class="identifier">k</span><span class="special">++</span> <span class="special">&lt;&lt;</span> <span class="string">" == "</span> <span class="special">&lt;&lt;</span> <span class="identifier">i</span><span class="special">-&gt;</span><span class="identifier">get</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
+
+ <span class="identifier">pt</span><span class="special">::</span><span class="identifier">ptime</span> <span class="identifier">stop</span><span class="special">(</span> <span class="identifier">pt</span><span class="special">::</span><span class="identifier">microsec_clock</span><span class="special">::</span><span class="identifier">universal_time</span><span class="special">()</span> <span class="special">);</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="special">(</span> <span class="identifier">stop</span> <span class="special">-</span> <span class="identifier">start</span><span class="special">).</span><span class="identifier">total_milliseconds</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="string">" milli seconds"</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
+
+ <span class="keyword">return</span> <span class="identifier">EXIT_SUCCESS</span><span class="special">;</span>
+ <span class="special">}</span>
+ <span class="keyword">catch</span> <span class="special">(</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">exception</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">e</span><span class="special">)</span>
+ <span class="special">{</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cerr</span> <span class="special">&lt;&lt;</span> <span class="string">"exception: "</span> <span class="special">&lt;&lt;</span> <span class="identifier">e</span><span class="special">.</span><span class="identifier">what</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="special">}</span>
+ <span class="keyword">catch</span> <span class="special">(</span> <span class="special">...</span> <span class="special">)</span>
+ <span class="special">{</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cerr</span> <span class="special">&lt;&lt;</span> <span class="string">"unhandled"</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="special">}</span>
+
+ <span class="keyword">return</span> <span class="identifier">EXIT_FAILURE</span><span class="special">;</span>
+<span class="special">}</span>
+</pre>
+<p>
+ for ( int i = 0; i &lt; 32; ++i) results.push_back( pool.submit( boost::bind(
+ &amp; fibo::execute, boost::ref( fib), i) ) );
+ </p>
+<pre class="programlisting"> <span class="keyword">int</span> <span class="identifier">k</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span> <span class="identifier">tp</span><span class="special">::</span><span class="identifier">task</span><span class="special">&lt;</span> <span class="keyword">int</span> <span class="special">&gt;</span> <span class="special">&gt;::</span><span class="identifier">iterator</span> <span class="identifier">e</span><span class="special">(</span> <span class="identifier">results</span><span class="special">.</span><span class="identifier">end</span><span class="special">()</span> <span class="special">);</span>
+ <span class="keyword">for</span> <span class="special">(</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span> <span class="identifier">tp</span><span class="special">::</span><span class="identifier">task</span><span class="special">&lt;</span> <span class="keyword">int</span> <span class="special">&gt;</span> <span class="special">&gt;::</span><span class="identifier">iterator</span> <span class="identifier">i</span><span class="special">(</span> <span class="identifier">results</span><span class="special">.</span><span class="identifier">begin</span><span class="special">()</span> <span class="special">);</span>
+ <span class="identifier">i</span> <span class="special">!=</span> <span class="identifier">e</span><span class="special">;</span>
+ <span class="special">++</span><span class="identifier">i</span><span class="special">)</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"fibonacci "</span> <span class="special">&lt;&lt;</span> <span class="identifier">k</span><span class="special">++</span> <span class="special">&lt;&lt;</span> <span class="string">" == "</span> <span class="special">&lt;&lt;</span> <span class="identifier">i</span><span class="special">-&gt;</span><span class="identifier">get</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
+
+ <span class="identifier">pt</span><span class="special">::</span><span class="identifier">ptime</span> <span class="identifier">stop</span><span class="special">(</span> <span class="identifier">pt</span><span class="special">::</span><span class="identifier">microsec_clock</span><span class="special">::</span><span class="identifier">universal_time</span><span class="special">()</span> <span class="special">);</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="special">(</span> <span class="identifier">stop</span> <span class="special">-</span> <span class="identifier">start</span><span class="special">).</span><span class="identifier">total_milliseconds</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="string">" milli seconds"</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
+
+ <span class="keyword">return</span> <span class="identifier">EXIT_SUCCESS</span><span class="special">;</span>
+ <span class="special">}</span>
+ <span class="keyword">catch</span> <span class="special">(</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">exception</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">e</span><span class="special">)</span>
+ <span class="special">{</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cerr</span> <span class="special">&lt;&lt;</span> <span class="string">"exception: "</span> <span class="special">&lt;&lt;</span> <span class="identifier">e</span><span class="special">.</span><span class="identifier">what</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="special">}</span>
+ <span class="keyword">catch</span> <span class="special">(</span> <span class="special">...</span> <span class="special">)</span>
+ <span class="special">{</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cerr</span> <span class="special">&lt;&lt;</span> <span class="string">"unhandled"</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="special">}</span>
+
+ <span class="keyword">return</span> <span class="identifier">EXIT_FAILURE</span><span class="special">;</span>
+<span class="special">}</span>
+</pre>
+<p>
+ int k = 0; std::vector&lt; tp::task&lt; int &gt; &gt;::iterator e( results.end()
+ ); for ( std::vector&lt; tp::task&lt; int &gt; &gt;::iterator i( results.begin()
+ ); i != e; ++i) std::cout &lt;&lt; "fibonacci " &lt;&lt; k++ &lt;&lt;
+ " == " &lt;&lt; i-&gt;get() &lt;&lt; std::endl;
+ </p>
+<pre class="programlisting"> <span class="identifier">pt</span><span class="special">::</span><span class="identifier">ptime</span> <span class="identifier">stop</span><span class="special">(</span> <span class="identifier">pt</span><span class="special">::</span><span class="identifier">microsec_clock</span><span class="special">::</span><span class="identifier">universal_time</span><span class="special">()</span> <span class="special">);</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="special">(</span> <span class="identifier">stop</span> <span class="special">-</span> <span class="identifier">start</span><span class="special">).</span><span class="identifier">total_milliseconds</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="string">" milli seconds"</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
+
+ <span class="keyword">return</span> <span class="identifier">EXIT_SUCCESS</span><span class="special">;</span>
+ <span class="special">}</span>
+ <span class="keyword">catch</span> <span class="special">(</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">exception</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">e</span><span class="special">)</span>
+ <span class="special">{</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cerr</span> <span class="special">&lt;&lt;</span> <span class="string">"exception: "</span> <span class="special">&lt;&lt;</span> <span class="identifier">e</span><span class="special">.</span><span class="identifier">what</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="special">}</span>
+ <span class="keyword">catch</span> <span class="special">(</span> <span class="special">...</span> <span class="special">)</span>
+ <span class="special">{</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cerr</span> <span class="special">&lt;&lt;</span> <span class="string">"unhandled"</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="special">}</span>
+
+ <span class="keyword">return</span> <span class="identifier">EXIT_FAILURE</span><span class="special">;</span>
+<span class="special">}</span>
+</pre>
+<p>
+ pt::ptime stop( pt::microsec_clock::universal_time() ); std::cout &lt;&lt;
+ ( stop - start).total_milliseconds() &lt;&lt; " milli seconds" &lt;&lt;
+ std::endl;
+ </p>
+<pre class="programlisting"> <span class="keyword">return</span> <span class="identifier">EXIT_SUCCESS</span><span class="special">;</span>
+ <span class="special">}</span>
+ <span class="keyword">catch</span> <span class="special">(</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">exception</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">e</span><span class="special">)</span>
+ <span class="special">{</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cerr</span> <span class="special">&lt;&lt;</span> <span class="string">"exception: "</span> <span class="special">&lt;&lt;</span> <span class="identifier">e</span><span class="special">.</span><span class="identifier">what</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="special">}</span>
+ <span class="keyword">catch</span> <span class="special">(</span> <span class="special">...</span> <span class="special">)</span>
+ <span class="special">{</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cerr</span> <span class="special">&lt;&lt;</span> <span class="string">"unhandled"</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="special">}</span>
+
+ <span class="keyword">return</span> <span class="identifier">EXIT_FAILURE</span><span class="special">;</span>
+<span class="special">}</span>
+</pre>
+<p>
+ return EXIT_SUCCESS; } catch ( std::exception const&amp; e) { std::cerr &lt;&lt;
+ "exception: " &lt;&lt; e.what() &lt;&lt; std::endl; } catch ( ...
+ ) { std::cerr &lt;&lt; "unhandled" &lt;&lt; std::endl; }
+ </p>
+<pre class="programlisting"> <span class="keyword">return</span> <span class="identifier">EXIT_FAILURE</span><span class="special">;</span>
+<span class="special">}</span>
+</pre>
+<p>
+ return EXIT_FAILURE; }
+ </p>
 </div>
 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
 <td align="left"></td>

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-01 03:20:12 EST (Sun, 01 Mar 2009)
@@ -32,8 +32,10 @@
       function <code class="computeroutput"><span class="identifier">wait_for_all</span></code></a></span></dt>
 <dt><span class="section"><a href="reference.html#boost_threadpool.reference.wait_for_any"> Non-member
       function <code class="computeroutput"><span class="identifier">wait_for_any</span></code></a></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>
 <dt><span class="section"><a href="reference.html#boost_threadpool.reference.get_thread_pool"> Non-member
- templated 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></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>
@@ -1110,8 +1112,40 @@
 </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 templated function get_thread_pool"> Non-member
- templated function <code class="computeroutput"><span class="identifier">get_thread_pool</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></code></a>
+</h3></div></div></div>
+<pre class="programlisting"> <span class="preprocessor">#include</span> <span class="special">&lt;</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">&gt;</span>
+
+<span class="keyword">template</span><span class="special">&lt;</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">&gt;</span>
+<span class="keyword">void</span> <span class="identifier">reschedule_until</span><span class="special">(</span> <span class="identifier">jss</span><span class="special">::</span><span class="identifier">future</span><span class="special">&lt;</span> <span class="identifier">R</span> <span class="special">&gt;</span> <span class="keyword">const</span><span class="special">&amp;);</span>
+</pre>
+<div class="variablelist">
+<p class="title"><b></b></p>
+<dl>
+<dt><span class="term">Effects:</span></dt>
+<dd>
+<p>
+ Reschedules current task until passed future becomes ready.
+ </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.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>
 </h3></div></div></div>
 <pre class="programlisting"> <span class="preprocessor">#include</span> <span class="special">&lt;</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">&gt;</span>
 

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-01 03:20:12 EST (Sun, 01 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="id372284"></a>
+<a name="id372347"></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="id372316"></a>
+<a name="id372380"></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="id372349"></a>
+<a name="id372412"></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">&lt;</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">&lt;</span> <span class="identifier">Attr</span> <span class="special">&gt;</span> <span class="special">&gt;</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="id372455"></a>
+<a name="id372518"></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">&lt;</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">&gt;</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-01 03:20:12 EST (Sun, 01 Mar 2009)
@@ -27,10 +27,13 @@
 <a name="boost_threadpool.this_task"></a><a class="link" href="this_task.html" title="Namespace this_task"> Namespace this_task</a>
 </h2></div></div></div>
 <p>
- The __thread<span class="underline">pool</span>_ 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">&lt;</span>
+ 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">jss</span><span class="special">::</span><span class="identifier">future</span><span class="special">&lt;</span> <span class="identifier">R</span> <span class="special">&gt;</span> <span class="keyword">const</span><span class="special">&amp;)</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">&lt;</span>
       <span class="identifier">Pool</span> <span class="special">&gt;()</span></code>
- ifthe calling code is executed by a worker thread.
+ if the calling code is executed by a worker thread.
     </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-01 03:20:12 EST (Sun, 01 Mar 2009)
@@ -52,8 +52,10 @@
       function <code class="computeroutput"><span class="identifier">wait_for_all</span></code></a></span></dt>
 <dt><span class="section"><a href="boost_threadpool/reference.html#boost_threadpool.reference.wait_for_any"> Non-member
       function <code class="computeroutput"><span class="identifier">wait_for_any</span></code></a></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>
 <dt><span class="section"><a href="boost_threadpool/reference.html#boost_threadpool.reference.get_thread_pool"> Non-member
- templated 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></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>
@@ -144,7 +146,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: February 28, 2009 at 14:20:16 GMT</small></p></td>
+<td align="left"><p><small>Last revised: March 01, 2009 at 08:18:32 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-01 03:20:12 EST (Sun, 01 Mar 2009)
@@ -6,6 +6,9 @@
 ]
 
 [section:this_task Namespace this_task]
-The pool can be accessed via `boost::this_task::get_thread_pool< Pool >()` ifthe calling code is executed by a __worker_thread__.
+In the function `boost::this_task::reschedule_until( jss::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.
+The pool can be accessed via `boost::this_task::get_thread_pool< Pool >()` if the calling code is executed by a __worker_thread__.
 
 [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-01 03:20:12 EST (Sun, 01 Mar 2009)
@@ -5,6 +5,21 @@
   http://www.boost.org/LICENSE_1_0.txt).
 ]
 
+[section:reschedule_until Non-member function `reschedule_until`]
+
+ #include <boost/tp/pool.hpp>
+
+ template< typename Pool, typename R >
+ void reschedule_until( jss::future< R > const&);
+
+[variablelist
+[[Effects:] [Reschedules current task until passed future becomes ready.]
+[[Throws:] [Nothing.]]
+[[Note:] [This function resides in namespace `boost::this_task`.]]
+]
+
+[endsect]
+
 [section:get_thread_pool Non-member function `get_thread_pool`]
 
     #include <boost/tp/pool.hpp>

Modified: sandbox/threadpool/libs/tp/doc/threadpool.xml
==============================================================================
--- sandbox/threadpool/libs/tp/doc/threadpool.xml (original)
+++ sandbox/threadpool/libs/tp/doc/threadpool.xml 2009-03-01 03:20:12 EST (Sun, 01 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/02/28 14:27:32 $" xmlns:xi="http://www.w3.org/2001/XInclude">
+last-revision="$Date: 2009/03/01 08:18:28 $" xmlns:xi="http://www.w3.org/2001/XInclude">
   <libraryinfo>
     <authorgroup>
     <author>
@@ -621,12 +621,20 @@
   <section id="boost_threadpool.this_task">
     <title><link linkend="boost_threadpool.this_task"> Namespace this_task</link></title>
     <para>
- The pool can be accessed via <code><phrase role="identifier">boost</phrase><phrase
- role="special">::</phrase><phrase role="identifier">this_task</phrase><phrase
- role="special">::</phrase><phrase role="identifier">get_thread_pool</phrase><phrase
- role="special">&lt;</phrase> <phrase role="identifier">Pool</phrase> <phrase
- role="special">&gt;()</phrase></code> ifthe calling code is executed by a worker
- thread.
+ In the function <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">this_task</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">reschedule_until</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">jss</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">future</phrase><phrase role="special">&lt;</phrase> <phrase
+ role="identifier">R</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase><phrase
+ role="special">&amp;)</phrase></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><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">this_task</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">get_thread_pool</phrase><phrase role="special">&lt;</phrase>
+ <phrase role="identifier">Pool</phrase> <phrase role="special">&gt;()</phrase></code>
+ if the calling code is executed by a worker thread.
     </para>
   </section>
   <section id="boost_threadpool.channel">
@@ -786,76 +794,736 @@
       queue</emphasis></link>.
     </para>
     
-<programlisting><phrase role="comment">// defines the threadpool type
-</phrase><phrase role="keyword">typedef</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">&lt;</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">&lt;</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">&gt;</phrase>
-<phrase role="special">&gt;</phrase> <phrase role="identifier">pool_type</phrase><phrase role="special">;</phrase>
+<programlisting> <phrase role="comment">// defines the threadpool type
+</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">pt</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">posix_time</phrase><phrase role="special">;</phrase>
+<phrase role="keyword">namespace</phrase> <phrase role="identifier">tp</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="keyword">typedef</phrase> <phrase role="identifier">tp</phrase><phrase role="special">::</phrase><phrase role="identifier">pool</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">tp</phrase><phrase role="special">::</phrase><phrase role="identifier">unbounded_channel</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">tp</phrase><phrase role="special">::</phrase><phrase role="identifier">fifo</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">pool_type</phrase><phrase role="special">;</phrase>
 
 <phrase role="keyword">class</phrase> <phrase role="identifier">fibo</phrase>
 <phrase role="special">{</phrase>
 <phrase role="keyword">private</phrase><phrase role="special">:</phrase>
- <phrase role="identifier">pool_type</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">pool_</phrase><phrase role="special">;</phrase>
- <phrase role="keyword">int</phrase> <phrase role="identifier">cutoff_</phrase><phrase role="special">;</phrase>
+ <phrase role="keyword">int</phrase> <phrase role="identifier">offset_</phrase><phrase role="special">;</phrase>
+
+ <phrase role="keyword">int</phrase> <phrase role="identifier">seq_</phrase><phrase role="special">(</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">n</phrase><phrase role="special">)</phrase>
+ <phrase role="special">{</phrase>
+ <phrase role="keyword">if</phrase> <phrase role="special">(</phrase> <phrase role="identifier">n</phrase> <phrase role="special">&lt;=</phrase> <phrase role="number">1</phrase><phrase role="special">)</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">n</phrase><phrase role="special">;</phrase>
+ <phrase role="keyword">else</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">seq_</phrase><phrase role="special">(</phrase> <phrase role="identifier">n</phrase> <phrase role="special">-</phrase> <phrase role="number">2</phrase><phrase role="special">)</phrase> <phrase role="special">+</phrase> <phrase role="identifier">seq_</phrase><phrase role="special">(</phrase> <phrase role="identifier">n</phrase> <phrase role="special">-</phrase> <phrase role="number">1</phrase><phrase role="special">);</phrase>
+ <phrase role="special">}</phrase>
+
+ <phrase role="keyword">int</phrase> <phrase role="identifier">par_</phrase><phrase role="special">(</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">n</phrase><phrase role="special">)</phrase>
+ <phrase role="special">{</phrase>
+ <phrase role="keyword">if</phrase> <phrase role="special">(</phrase> <phrase role="identifier">n</phrase> <phrase role="special">&lt;=</phrase> <phrase role="identifier">offset_</phrase><phrase role="special">)</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">seq_</phrase><phrase role="special">(</phrase> <phrase role="identifier">n</phrase><phrase role="special">);</phrase>
+ <phrase role="keyword">else</phrase>
+ <phrase role="special">{</phrase>
+ <phrase role="identifier">tp</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">int</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">t1</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">this_task</phrase><phrase role="special">::</phrase><phrase role="identifier">get_thread_pool</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">pool_type</phrase> <phrase role="special">&gt;().</phrase><phrase role="identifier">submit</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">bind</phrase><phrase role="special">(</phrase>
+ <phrase role="special">&amp;</phrase> <phrase role="identifier">fibo</phrase><phrase role="special">::</phrase><phrase role="identifier">par_</phrase><phrase role="special">,</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">ref</phrase><phrase role="special">(</phrase> <phrase role="special">*</phrase> <phrase role="keyword">this</phrase><phrase role="special">),</phrase>
+ <phrase role="identifier">n</phrase> <phrase role="special">-</phrase> <phrase role="number">1</phrase><phrase role="special">)</phrase> <phrase role="special">)</phrase> <phrase role="special">);</phrase>
+ <phrase role="identifier">tp</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">int</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">t2</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">this_task</phrase><phrase role="special">::</phrase><phrase role="identifier">get_thread_pool</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">pool_type</phrase> <phrase role="special">&gt;().</phrase><phrase role="identifier">submit</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">bind</phrase><phrase role="special">(</phrase>
+ <phrase role="special">&amp;</phrase> <phrase role="identifier">fibo</phrase><phrase role="special">::</phrase><phrase role="identifier">par_</phrase><phrase role="special">,</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">ref</phrase><phrase role="special">(</phrase> <phrase role="special">*</phrase> <phrase role="keyword">this</phrase><phrase role="special">),</phrase>
+ <phrase role="identifier">n</phrase> <phrase role="special">-</phrase> <phrase role="number">2</phrase><phrase role="special">)</phrase> <phrase role="special">)</phrase> <phrase role="special">);</phrase>
+ <phrase role="keyword">return</phrase> <phrase role="identifier">t1</phrase><phrase role="special">.</phrase><phrase role="identifier">get</phrase><phrase role="special">()</phrase> <phrase role="special">+</phrase> <phrase role="identifier">t2</phrase><phrase role="special">.</phrase><phrase role="identifier">get</phrase><phrase role="special">();</phrase>
+ <phrase role="special">}</phrase>
+ <phrase role="special">}</phrase>
 
- <phrase role="keyword">int</phrase> <phrase role="identifier">seq_</phrase><phrase role="special">(</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">n</phrase><phrase role="special">)</phrase>
- <phrase role="special">{</phrase>
- <phrase role="keyword">if</phrase> <phrase role="special">(</phrase> <phrase role="identifier">n</phrase> <phrase role="special">&lt;=</phrase> <phrase role="number">1</phrase><phrase role="special">)</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">n</phrase><phrase role="special">;</phrase>
- <phrase role="keyword">else</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">seq_</phrase><phrase role="special">(</phrase> <phrase role="identifier">n</phrase> <phrase role="special">-</phrase> <phrase role="number">2</phrase><phrase role="special">)</phrase> <phrase role="special">+</phrase> <phrase role="identifier">seq_</phrase><phrase role="special">(</phrase> <phrase role="identifier">n</phrase> <phrase role="special">-</phrase> <phrase role="number">1</phrase><phrase role="special">);</phrase>
- <phrase role="special">}</phrase>
-
- <phrase role="keyword">int</phrase> <phrase role="identifier">par_</phrase><phrase role="special">(</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">n</phrase><phrase role="special">)</phrase>
- <phrase role="special">{</phrase>
- <phrase role="keyword">if</phrase> <phrase role="special">(</phrase> <phrase role="identifier">n</phrase> <phrase role="special">&lt;=</phrase> <phrase role="identifier">cutoff_</phrase><phrase role="special">)</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">seq_</phrase><phrase role="special">(</phrase> <phrase role="identifier">n</phrase><phrase role="special">);</phrase>
- <phrase role="keyword">else</phrase>
- <phrase role="special">{</phrase>
- <phrase role="comment">// fork a new sub-action t1 in pool
-</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">tp</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">int</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">t1</phrase><phrase role="special">(</phrase>
- <phrase role="identifier">pool_</phrase><phrase role="special">.</phrase><phrase role="identifier">submit</phrase><phrase role="special">(</phrase>
- <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">bind</phrase><phrase role="special">(</phrase>
- <phrase role="special">&amp;</phrase> <phrase role="identifier">fibo</phrase><phrase role="special">::</phrase><phrase role="identifier">par_</phrase><phrase role="special">,</phrase>
- <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">ref</phrase><phrase role="special">(</phrase> <phrase role="special">*</phrase> <phrase role="keyword">this</phrase><phrase role="special">),</phrase>
- <phrase role="identifier">n</phrase> <phrase role="special">-</phrase> <phrase role="number">1</phrase><phrase role="special">)</phrase> <phrase role="special">)</phrase> <phrase role="special">);</phrase>
-
- <phrase role="comment">// fork a new sub-action t2 in pool
-</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">tp</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">int</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">t1</phrase><phrase role="special">(</phrase>
- <phrase role="identifier">pool_</phrase><phrase role="special">.</phrase><phrase role="identifier">submit</phrase><phrase role="special">(</phrase>
- <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">bind</phrase><phrase role="special">(</phrase>
- <phrase role="special">&amp;</phrase> <phrase role="identifier">fibo</phrase><phrase role="special">::</phrase><phrase role="identifier">par_</phrase><phrase role="special">,</phrase>
- <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">ref</phrase><phrase role="special">(</phrase> <phrase role="special">*</phrase> <phrase role="keyword">this</phrase><phrase role="special">),</phrase>
- <phrase role="identifier">n</phrase> <phrase role="special">-</phrase> <phrase role="number">2</phrase><phrase role="special">)</phrase> <phrase role="special">)</phrase> <phrase role="special">);</phrase>
-
- <phrase role="comment">// joining the result of sub-action t1 and t2
-</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">t1</phrase><phrase role="special">.</phrase><phrase role="identifier">get</phrase><phrase role="special">()</phrase> <phrase role="special">+</phrase> <phrase role="identifier">t2</phrase><phrase role="special">.</phrase><phrase role="identifier">get</phrase><phrase role="special">();</phrase>
- <phrase role="special">}</phrase>
- <phrase role="special">}</phrase>
 <phrase role="keyword">public</phrase><phrase role="special">:</phrase>
- <phrase role="identifier">fibo</phrase><phrase role="special">(</phrase> <phrase role="identifier">pool_type</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">pool</phrase><phrase role="special">,</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">cutoff</phrase><phrase role="special">)</phrase>
- <phrase role="special">:</phrase> <phrase role="identifier">pool_</phrase><phrase role="special">(</phrase> <phrase role="identifier">pool</phrase><phrase role="special">),</phrase> <phrase role="identifier">cutoff_</phrase><phrase role="special">(</phrase> <phrase role="identifier">cutoff</phrase><phrase role="special">)</phrase>
- <phrase role="special">{}</phrase>
-
- <phrase role="keyword">int</phrase> <phrase role="identifier">execute</phrase><phrase role="special">(</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">n</phrase><phrase role="special">)</phrase>
- <phrase role="special">{</phrase>
- <phrase role="keyword">int</phrase> <phrase role="identifier">result</phrase><phrase role="special">(</phrase> <phrase role="identifier">par_</phrase><phrase role="special">(</phrase> <phrase role="identifier">n</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase>
- <phrase role="keyword">return</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
- <phrase role="special">}</phrase>
+ <phrase role="identifier">fibo</phrase><phrase role="special">(</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">offset</phrase><phrase role="special">)</phrase>
+ <phrase role="special">:</phrase> <phrase role="identifier">offset_</phrase><phrase role="special">(</phrase> <phrase role="identifier">offset</phrase><phrase role="special">)</phrase>
+ <phrase role="special">{}</phrase>
+
+ <phrase role="keyword">int</phrase> <phrase role="identifier">execute</phrase><phrase role="special">(</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">n</phrase><phrase role="special">)</phrase>
+ <phrase role="special">{</phrase>
+ <phrase role="keyword">int</phrase> <phrase role="identifier">result</phrase><phrase role="special">(</phrase> <phrase role="identifier">par_</phrase><phrase role="special">(</phrase> <phrase role="identifier">n</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase>
+ <phrase role="keyword">return</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
+ <phrase role="special">}</phrase>
 <phrase role="special">};</phrase>
 
-<phrase role="comment">// creates a threadpool with two worker-threads
-</phrase><phrase role="identifier">pool_type</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">poolsize</phrase><phrase role="special">(</phrase> <phrase role="number">2</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase>
+<phrase role="keyword">int</phrase> <phrase role="identifier">main</phrase><phrase role="special">(</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">argc</phrase><phrase role="special">,</phrase> <phrase role="keyword">char</phrase> <phrase role="special">*</phrase><phrase role="identifier">argv</phrase><phrase role="special">[])</phrase>
+<phrase role="special">{</phrase>
+ <phrase role="keyword">try</phrase>
+ <phrase role="special">{</phrase>
+ <phrase role="identifier">pool_type</phrase> <phrase role="identifier">pool</phrase><phrase role="special">(</phrase> <phrase role="identifier">tp</phrase><phrase role="special">::</phrase><phrase role="identifier">poolsize</phrase><phrase role="special">(</phrase> <phrase role="number">3</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase>
+ <phrase role="identifier">fibo</phrase> <phrase role="identifier">fib</phrase><phrase role="special">(</phrase> <phrase role="number">5</phrase><phrase role="special">);</phrase>
+ <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">tp</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">int</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">results</phrase><phrase role="special">;</phrase>
+ <phrase role="identifier">results</phrase><phrase role="special">.</phrase><phrase role="identifier">reserve</phrase><phrase role="special">(</phrase> <phrase role="number">40</phrase><phrase role="special">);</phrase>
+
+ <phrase role="identifier">pt</phrase><phrase role="special">::</phrase><phrase role="identifier">ptime</phrase> <phrase role="identifier">start</phrase><phrase role="special">(</phrase> <phrase role="identifier">pt</phrase><phrase role="special">::</phrase><phrase role="identifier">microsec_clock</phrase><phrase role="special">::</phrase><phrase role="identifier">universal_time</phrase><phrase role="special">()</phrase> <phrase role="special">);</phrase>
+
+ <phrase role="keyword">for</phrase> <phrase role="special">(</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">i</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase> <phrase role="identifier">i</phrase> <phrase role="special">&lt;</phrase> <phrase role="number">32</phrase><phrase role="special">;</phrase> <phrase role="special">++</phrase><phrase role="identifier">i</phrase><phrase role="special">)</phrase>
+ <phrase role="identifier">results</phrase><phrase role="special">.</phrase><phrase role="identifier">push_back</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">pool</phrase><phrase role="special">.</phrase><phrase role="identifier">submit</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">bind</phrase><phrase role="special">(</phrase>
+ <phrase role="special">&amp;</phrase> <phrase role="identifier">fibo</phrase><phrase role="special">::</phrase><phrase role="identifier">execute</phrase><phrase role="special">,</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">ref</phrase><phrase role="special">(</phrase> <phrase role="identifier">fib</phrase><phrase role="special">),</phrase>
+ <phrase role="identifier">i</phrase><phrase role="special">)</phrase> <phrase role="special">)</phrase> <phrase role="special">);</phrase>
+
+ <phrase role="keyword">int</phrase> <phrase role="identifier">k</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase>
+ <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">tp</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">int</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&gt;::</phrase><phrase role="identifier">iterator</phrase> <phrase role="identifier">e</phrase><phrase role="special">(</phrase> <phrase role="identifier">results</phrase><phrase role="special">.</phrase><phrase role="identifier">end</phrase><phrase role="special">()</phrase> <phrase role="special">);</phrase>
+ <phrase role="keyword">for</phrase> <phrase role="special">(</phrase>
+ <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">tp</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">int</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&gt;::</phrase><phrase role="identifier">iterator</phrase> <phrase role="identifier">i</phrase><phrase role="special">(</phrase> <phrase role="identifier">results</phrase><phrase role="special">.</phrase><phrase role="identifier">begin</phrase><phrase role="special">()</phrase> <phrase role="special">);</phrase>
+ <phrase role="identifier">i</phrase> <phrase role="special">!=</phrase> <phrase role="identifier">e</phrase><phrase role="special">;</phrase>
+ <phrase role="special">++</phrase><phrase role="identifier">i</phrase><phrase role="special">)</phrase>
+ <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;fibonacci &quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">k</phrase><phrase role="special">++</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot; == &quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">i</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">get</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase>
+
+ <phrase role="identifier">pt</phrase><phrase role="special">::</phrase><phrase role="identifier">ptime</phrase> <phrase role="identifier">stop</phrase><phrase role="special">(</phrase> <phrase role="identifier">pt</phrase><phrase role="special">::</phrase><phrase role="identifier">microsec_clock</phrase><phrase role="special">::</phrase><phrase role="identifier">universal_time</phrase><phrase role="special">()</phrase> <phrase role="special">);</phrase>
+ <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="special">(</phrase> <phrase role="identifier">stop</phrase> <phrase role="special">-</phrase> <phrase role="identifier">start</phrase><phrase role="special">).</phrase><phrase role="identifier">total_milliseconds</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot; milli seconds&quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase>
+
+ <phrase role="keyword">return</phrase> <phrase role="identifier">EXIT_SUCCESS</phrase><phrase role="special">;</phrase>
+ <phrase role="special">}</phrase>
+ <phrase role="keyword">catch</phrase> <phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">exception</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">e</phrase><phrase role="special">)</phrase>
+ <phrase role="special">{</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cerr</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;exception: &quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">e</phrase><phrase role="special">.</phrase><phrase role="identifier">what</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase>
+ <phrase role="keyword">catch</phrase> <phrase role="special">(</phrase> <phrase role="special">...</phrase> <phrase role="special">)</phrase>
+ <phrase role="special">{</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cerr</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;unhandled&quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase>
 
-<phrase role="identifier">fibo</phrase> <phrase role="identifier">fib</phrase><phrase role="special">(</phrase> <phrase role="identifier">pool</phrase><phrase role="special">,</phrase> <phrase role="number">1</phrase><phrase role="special">);</phrase>
+ <phrase role="keyword">return</phrase> <phrase role="identifier">EXIT_FAILURE</phrase><phrase role="special">;</phrase>
+<phrase role="special">}</phrase>
+</programlisting>
+ <para>
+ // defines the threadpool type namespace pt = boost::posix_time; namespace
+ tp = boost::tp;
+ </para>
+
+<programlisting><phrase role="keyword">typedef</phrase> <phrase role="identifier">tp</phrase><phrase role="special">::</phrase><phrase role="identifier">pool</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">tp</phrase><phrase role="special">::</phrase><phrase role="identifier">unbounded_channel</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">tp</phrase><phrase role="special">::</phrase><phrase role="identifier">fifo</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">pool_type</phrase><phrase role="special">;</phrase>
 
-<phrase role="comment">// submit an action
-</phrase><phrase role="comment">// which calculates the fibonacci number of 10
-</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">tp</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">int</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">t</phrase><phrase role="special">(</phrase>
- <phrase role="identifier">pool</phrase><phrase role="special">.</phrase><phrase role="identifier">submit</phrase><phrase role="special">(</phrase>
- <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">bind</phrase><phrase role="special">(</phrase>
- <phrase role="special">&amp;</phrase> <phrase role="identifier">fibo</phrase><phrase role="special">::</phrase><phrase role="identifier">execute</phrase><phrase role="special">,</phrase>
- <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">ref</phrase><phrase role="special">(</phrase> <phrase role="identifier">fib</phrase><phrase role="special">),</phrase>
- <phrase role="number">10</phrase><phrase role="special">)</phrase> <phrase role="special">)</phrase> <phrase role="special">);</phrase>
+<phrase role="keyword">class</phrase> <phrase role="identifier">fibo</phrase>
+<phrase role="special">{</phrase>
+<phrase role="keyword">private</phrase><phrase role="special">:</phrase>
+ <phrase role="keyword">int</phrase> <phrase role="identifier">offset_</phrase><phrase role="special">;</phrase>
 
-<phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">t</phrase><phrase role="special">.</phrase><phrase role="identifier">get</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase> <phrase role="comment">// prints 55
-</phrase></programlisting>
+ <phrase role="keyword">int</phrase> <phrase role="identifier">seq_</phrase><phrase role="special">(</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">n</phrase><phrase role="special">)</phrase>
+ <phrase role="special">{</phrase>
+ <phrase role="keyword">if</phrase> <phrase role="special">(</phrase> <phrase role="identifier">n</phrase> <phrase role="special">&lt;=</phrase> <phrase role="number">1</phrase><phrase role="special">)</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">n</phrase><phrase role="special">;</phrase>
+ <phrase role="keyword">else</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">seq_</phrase><phrase role="special">(</phrase> <phrase role="identifier">n</phrase> <phrase role="special">-</phrase> <phrase role="number">2</phrase><phrase role="special">)</phrase> <phrase role="special">+</phrase> <phrase role="identifier">seq_</phrase><phrase role="special">(</phrase> <phrase role="identifier">n</phrase> <phrase role="special">-</phrase> <phrase role="number">1</phrase><phrase role="special">);</phrase>
+ <phrase role="special">}</phrase>
+
+ <phrase role="keyword">int</phrase> <phrase role="identifier">par_</phrase><phrase role="special">(</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">n</phrase><phrase role="special">)</phrase>
+ <phrase role="special">{</phrase>
+ <phrase role="keyword">if</phrase> <phrase role="special">(</phrase> <phrase role="identifier">n</phrase> <phrase role="special">&lt;=</phrase> <phrase role="identifier">offset_</phrase><phrase role="special">)</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">seq_</phrase><phrase role="special">(</phrase> <phrase role="identifier">n</phrase><phrase role="special">);</phrase>
+ <phrase role="keyword">else</phrase>
+ <phrase role="special">{</phrase>
+ <phrase role="identifier">tp</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">int</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">t1</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">this_task</phrase><phrase role="special">::</phrase><phrase role="identifier">get_thread_pool</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">pool_type</phrase> <phrase role="special">&gt;().</phrase><phrase role="identifier">submit</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">bind</phrase><phrase role="special">(</phrase>
+ <phrase role="special">&amp;</phrase> <phrase role="identifier">fibo</phrase><phrase role="special">::</phrase><phrase role="identifier">par_</phrase><phrase role="special">,</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">ref</phrase><phrase role="special">(</phrase> <phrase role="special">*</phrase> <phrase role="keyword">this</phrase><phrase role="special">),</phrase>
+ <phrase role="identifier">n</phrase> <phrase role="special">-</phrase> <phrase role="number">1</phrase><phrase role="special">)</phrase> <phrase role="special">)</phrase> <phrase role="special">);</phrase>
+ <phrase role="identifier">tp</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">int</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">t2</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">this_task</phrase><phrase role="special">::</phrase><phrase role="identifier">get_thread_pool</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">pool_type</phrase> <phrase role="special">&gt;().</phrase><phrase role="identifier">submit</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">bind</phrase><phrase role="special">(</phrase>
+ <phrase role="special">&amp;</phrase> <phrase role="identifier">fibo</phrase><phrase role="special">::</phrase><phrase role="identifier">par_</phrase><phrase role="special">,</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">ref</phrase><phrase role="special">(</phrase> <phrase role="special">*</phrase> <phrase role="keyword">this</phrase><phrase role="special">),</phrase>
+ <phrase role="identifier">n</phrase> <phrase role="special">-</phrase> <phrase role="number">2</phrase><phrase role="special">)</phrase> <phrase role="special">)</phrase> <phrase role="special">);</phrase>
+ <phrase role="keyword">return</phrase> <phrase role="identifier">t1</phrase><phrase role="special">.</phrase><phrase role="identifier">get</phrase><phrase role="special">()</phrase> <phrase role="special">+</phrase> <phrase role="identifier">t2</phrase><phrase role="special">.</phrase><phrase role="identifier">get</phrase><phrase role="special">();</phrase>
+ <phrase role="special">}</phrase>
+ <phrase role="special">}</phrase>
+
+<phrase role="keyword">public</phrase><phrase role="special">:</phrase>
+ <phrase role="identifier">fibo</phrase><phrase role="special">(</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">offset</phrase><phrase role="special">)</phrase>
+ <phrase role="special">:</phrase> <phrase role="identifier">offset_</phrase><phrase role="special">(</phrase> <phrase role="identifier">offset</phrase><phrase role="special">)</phrase>
+ <phrase role="special">{}</phrase>
+
+ <phrase role="keyword">int</phrase> <phrase role="identifier">execute</phrase><phrase role="special">(</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">n</phrase><phrase role="special">)</phrase>
+ <phrase role="special">{</phrase>
+ <phrase role="keyword">int</phrase> <phrase role="identifier">result</phrase><phrase role="special">(</phrase> <phrase role="identifier">par_</phrase><phrase role="special">(</phrase> <phrase role="identifier">n</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase>
+ <phrase role="keyword">return</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
+ <phrase role="special">}</phrase>
+<phrase role="special">};</phrase>
+
+<phrase role="keyword">int</phrase> <phrase role="identifier">main</phrase><phrase role="special">(</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">argc</phrase><phrase role="special">,</phrase> <phrase role="keyword">char</phrase> <phrase role="special">*</phrase><phrase role="identifier">argv</phrase><phrase role="special">[])</phrase>
+<phrase role="special">{</phrase>
+ <phrase role="keyword">try</phrase>
+ <phrase role="special">{</phrase>
+ <phrase role="identifier">pool_type</phrase> <phrase role="identifier">pool</phrase><phrase role="special">(</phrase> <phrase role="identifier">tp</phrase><phrase role="special">::</phrase><phrase role="identifier">poolsize</phrase><phrase role="special">(</phrase> <phrase role="number">3</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase>
+ <phrase role="identifier">fibo</phrase> <phrase role="identifier">fib</phrase><phrase role="special">(</phrase> <phrase role="number">5</phrase><phrase role="special">);</phrase>
+ <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">tp</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">int</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">results</phrase><phrase role="special">;</phrase>
+ <phrase role="identifier">results</phrase><phrase role="special">.</phrase><phrase role="identifier">reserve</phrase><phrase role="special">(</phrase> <phrase role="number">40</phrase><phrase role="special">);</phrase>
+
+ <phrase role="identifier">pt</phrase><phrase role="special">::</phrase><phrase role="identifier">ptime</phrase> <phrase role="identifier">start</phrase><phrase role="special">(</phrase> <phrase role="identifier">pt</phrase><phrase role="special">::</phrase><phrase role="identifier">microsec_clock</phrase><phrase role="special">::</phrase><phrase role="identifier">universal_time</phrase><phrase role="special">()</phrase> <phrase role="special">);</phrase>
+
+ <phrase role="keyword">for</phrase> <phrase role="special">(</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">i</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase> <phrase role="identifier">i</phrase> <phrase role="special">&lt;</phrase> <phrase role="number">32</phrase><phrase role="special">;</phrase> <phrase role="special">++</phrase><phrase role="identifier">i</phrase><phrase role="special">)</phrase>
+ <phrase role="identifier">results</phrase><phrase role="special">.</phrase><phrase role="identifier">push_back</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">pool</phrase><phrase role="special">.</phrase><phrase role="identifier">submit</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">bind</phrase><phrase role="special">(</phrase>
+ <phrase role="special">&amp;</phrase> <phrase role="identifier">fibo</phrase><phrase role="special">::</phrase><phrase role="identifier">execute</phrase><phrase role="special">,</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">ref</phrase><phrase role="special">(</phrase> <phrase role="identifier">fib</phrase><phrase role="special">),</phrase>
+ <phrase role="identifier">i</phrase><phrase role="special">)</phrase> <phrase role="special">)</phrase> <phrase role="special">);</phrase>
+
+ <phrase role="keyword">int</phrase> <phrase role="identifier">k</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase>
+ <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">tp</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">int</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&gt;::</phrase><phrase role="identifier">iterator</phrase> <phrase role="identifier">e</phrase><phrase role="special">(</phrase> <phrase role="identifier">results</phrase><phrase role="special">.</phrase><phrase role="identifier">end</phrase><phrase role="special">()</phrase> <phrase role="special">);</phrase>
+ <phrase role="keyword">for</phrase> <phrase role="special">(</phrase>
+ <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">tp</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">int</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&gt;::</phrase><phrase role="identifier">iterator</phrase> <phrase role="identifier">i</phrase><phrase role="special">(</phrase> <phrase role="identifier">results</phrase><phrase role="special">.</phrase><phrase role="identifier">begin</phrase><phrase role="special">()</phrase> <phrase role="special">);</phrase>
+ <phrase role="identifier">i</phrase> <phrase role="special">!=</phrase> <phrase role="identifier">e</phrase><phrase role="special">;</phrase>
+ <phrase role="special">++</phrase><phrase role="identifier">i</phrase><phrase role="special">)</phrase>
+ <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;fibonacci &quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">k</phrase><phrase role="special">++</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot; == &quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">i</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">get</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase>
+
+ <phrase role="identifier">pt</phrase><phrase role="special">::</phrase><phrase role="identifier">ptime</phrase> <phrase role="identifier">stop</phrase><phrase role="special">(</phrase> <phrase role="identifier">pt</phrase><phrase role="special">::</phrase><phrase role="identifier">microsec_clock</phrase><phrase role="special">::</phrase><phrase role="identifier">universal_time</phrase><phrase role="special">()</phrase> <phrase role="special">);</phrase>
+ <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="special">(</phrase> <phrase role="identifier">stop</phrase> <phrase role="special">-</phrase> <phrase role="identifier">start</phrase><phrase role="special">).</phrase><phrase role="identifier">total_milliseconds</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot; milli seconds&quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase>
+
+ <phrase role="keyword">return</phrase> <phrase role="identifier">EXIT_SUCCESS</phrase><phrase role="special">;</phrase>
+ <phrase role="special">}</phrase>
+ <phrase role="keyword">catch</phrase> <phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">exception</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">e</phrase><phrase role="special">)</phrase>
+ <phrase role="special">{</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cerr</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;exception: &quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">e</phrase><phrase role="special">.</phrase><phrase role="identifier">what</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase>
+ <phrase role="keyword">catch</phrase> <phrase role="special">(</phrase> <phrase role="special">...</phrase> <phrase role="special">)</phrase>
+ <phrase role="special">{</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cerr</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;unhandled&quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase>
+
+ <phrase role="keyword">return</phrase> <phrase role="identifier">EXIT_FAILURE</phrase><phrase role="special">;</phrase>
+<phrase role="special">}</phrase>
+</programlisting>
+ <para>
+ typedef tp::pool&lt; tp::unbounded_channel&lt; tp::fifo &gt; &gt; pool_type;
+ </para>
+
+<programlisting><phrase role="keyword">class</phrase> <phrase role="identifier">fibo</phrase>
+<phrase role="special">{</phrase>
+<phrase role="keyword">private</phrase><phrase role="special">:</phrase>
+ <phrase role="keyword">int</phrase> <phrase role="identifier">offset_</phrase><phrase role="special">;</phrase>
+
+ <phrase role="keyword">int</phrase> <phrase role="identifier">seq_</phrase><phrase role="special">(</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">n</phrase><phrase role="special">)</phrase>
+ <phrase role="special">{</phrase>
+ <phrase role="keyword">if</phrase> <phrase role="special">(</phrase> <phrase role="identifier">n</phrase> <phrase role="special">&lt;=</phrase> <phrase role="number">1</phrase><phrase role="special">)</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">n</phrase><phrase role="special">;</phrase>
+ <phrase role="keyword">else</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">seq_</phrase><phrase role="special">(</phrase> <phrase role="identifier">n</phrase> <phrase role="special">-</phrase> <phrase role="number">2</phrase><phrase role="special">)</phrase> <phrase role="special">+</phrase> <phrase role="identifier">seq_</phrase><phrase role="special">(</phrase> <phrase role="identifier">n</phrase> <phrase role="special">-</phrase> <phrase role="number">1</phrase><phrase role="special">);</phrase>
+ <phrase role="special">}</phrase>
+
+ <phrase role="keyword">int</phrase> <phrase role="identifier">par_</phrase><phrase role="special">(</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">n</phrase><phrase role="special">)</phrase>
+ <phrase role="special">{</phrase>
+ <phrase role="keyword">if</phrase> <phrase role="special">(</phrase> <phrase role="identifier">n</phrase> <phrase role="special">&lt;=</phrase> <phrase role="identifier">offset_</phrase><phrase role="special">)</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">seq_</phrase><phrase role="special">(</phrase> <phrase role="identifier">n</phrase><phrase role="special">);</phrase>
+ <phrase role="keyword">else</phrase>
+ <phrase role="special">{</phrase>
+ <phrase role="identifier">tp</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">int</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">t1</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">this_task</phrase><phrase role="special">::</phrase><phrase role="identifier">get_thread_pool</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">pool_type</phrase> <phrase role="special">&gt;().</phrase><phrase role="identifier">submit</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">bind</phrase><phrase role="special">(</phrase>
+ <phrase role="special">&amp;</phrase> <phrase role="identifier">fibo</phrase><phrase role="special">::</phrase><phrase role="identifier">par_</phrase><phrase role="special">,</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">ref</phrase><phrase role="special">(</phrase> <phrase role="special">*</phrase> <phrase role="keyword">this</phrase><phrase role="special">),</phrase>
+ <phrase role="identifier">n</phrase> <phrase role="special">-</phrase> <phrase role="number">1</phrase><phrase role="special">)</phrase> <phrase role="special">)</phrase> <phrase role="special">);</phrase>
+ <phrase role="identifier">tp</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">int</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">t2</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">this_task</phrase><phrase role="special">::</phrase><phrase role="identifier">get_thread_pool</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">pool_type</phrase> <phrase role="special">&gt;().</phrase><phrase role="identifier">submit</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">bind</phrase><phrase role="special">(</phrase>
+ <phrase role="special">&amp;</phrase> <phrase role="identifier">fibo</phrase><phrase role="special">::</phrase><phrase role="identifier">par_</phrase><phrase role="special">,</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">ref</phrase><phrase role="special">(</phrase> <phrase role="special">*</phrase> <phrase role="keyword">this</phrase><phrase role="special">),</phrase>
+ <phrase role="identifier">n</phrase> <phrase role="special">-</phrase> <phrase role="number">2</phrase><phrase role="special">)</phrase> <phrase role="special">)</phrase> <phrase role="special">);</phrase>
+ <phrase role="keyword">return</phrase> <phrase role="identifier">t1</phrase><phrase role="special">.</phrase><phrase role="identifier">get</phrase><phrase role="special">()</phrase> <phrase role="special">+</phrase> <phrase role="identifier">t2</phrase><phrase role="special">.</phrase><phrase role="identifier">get</phrase><phrase role="special">();</phrase>
+ <phrase role="special">}</phrase>
+ <phrase role="special">}</phrase>
+
+<phrase role="keyword">public</phrase><phrase role="special">:</phrase>
+ <phrase role="identifier">fibo</phrase><phrase role="special">(</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">offset</phrase><phrase role="special">)</phrase>
+ <phrase role="special">:</phrase> <phrase role="identifier">offset_</phrase><phrase role="special">(</phrase> <phrase role="identifier">offset</phrase><phrase role="special">)</phrase>
+ <phrase role="special">{}</phrase>
+
+ <phrase role="keyword">int</phrase> <phrase role="identifier">execute</phrase><phrase role="special">(</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">n</phrase><phrase role="special">)</phrase>
+ <phrase role="special">{</phrase>
+ <phrase role="keyword">int</phrase> <phrase role="identifier">result</phrase><phrase role="special">(</phrase> <phrase role="identifier">par_</phrase><phrase role="special">(</phrase> <phrase role="identifier">n</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase>
+ <phrase role="keyword">return</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
+ <phrase role="special">}</phrase>
+<phrase role="special">};</phrase>
+
+<phrase role="keyword">int</phrase> <phrase role="identifier">main</phrase><phrase role="special">(</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">argc</phrase><phrase role="special">,</phrase> <phrase role="keyword">char</phrase> <phrase role="special">*</phrase><phrase role="identifier">argv</phrase><phrase role="special">[])</phrase>
+<phrase role="special">{</phrase>
+ <phrase role="keyword">try</phrase>
+ <phrase role="special">{</phrase>
+ <phrase role="identifier">pool_type</phrase> <phrase role="identifier">pool</phrase><phrase role="special">(</phrase> <phrase role="identifier">tp</phrase><phrase role="special">::</phrase><phrase role="identifier">poolsize</phrase><phrase role="special">(</phrase> <phrase role="number">3</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase>
+ <phrase role="identifier">fibo</phrase> <phrase role="identifier">fib</phrase><phrase role="special">(</phrase> <phrase role="number">5</phrase><phrase role="special">);</phrase>
+ <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">tp</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">int</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">results</phrase><phrase role="special">;</phrase>
+ <phrase role="identifier">results</phrase><phrase role="special">.</phrase><phrase role="identifier">reserve</phrase><phrase role="special">(</phrase> <phrase role="number">40</phrase><phrase role="special">);</phrase>
+
+ <phrase role="identifier">pt</phrase><phrase role="special">::</phrase><phrase role="identifier">ptime</phrase> <phrase role="identifier">start</phrase><phrase role="special">(</phrase> <phrase role="identifier">pt</phrase><phrase role="special">::</phrase><phrase role="identifier">microsec_clock</phrase><phrase role="special">::</phrase><phrase role="identifier">universal_time</phrase><phrase role="special">()</phrase> <phrase role="special">);</phrase>
+
+ <phrase role="keyword">for</phrase> <phrase role="special">(</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">i</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase> <phrase role="identifier">i</phrase> <phrase role="special">&lt;</phrase> <phrase role="number">32</phrase><phrase role="special">;</phrase> <phrase role="special">++</phrase><phrase role="identifier">i</phrase><phrase role="special">)</phrase>
+ <phrase role="identifier">results</phrase><phrase role="special">.</phrase><phrase role="identifier">push_back</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">pool</phrase><phrase role="special">.</phrase><phrase role="identifier">submit</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">bind</phrase><phrase role="special">(</phrase>
+ <phrase role="special">&amp;</phrase> <phrase role="identifier">fibo</phrase><phrase role="special">::</phrase><phrase role="identifier">execute</phrase><phrase role="special">,</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">ref</phrase><phrase role="special">(</phrase> <phrase role="identifier">fib</phrase><phrase role="special">),</phrase>
+ <phrase role="identifier">i</phrase><phrase role="special">)</phrase> <phrase role="special">)</phrase> <phrase role="special">);</phrase>
+
+ <phrase role="keyword">int</phrase> <phrase role="identifier">k</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase>
+ <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">tp</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">int</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&gt;::</phrase><phrase role="identifier">iterator</phrase> <phrase role="identifier">e</phrase><phrase role="special">(</phrase> <phrase role="identifier">results</phrase><phrase role="special">.</phrase><phrase role="identifier">end</phrase><phrase role="special">()</phrase> <phrase role="special">);</phrase>
+ <phrase role="keyword">for</phrase> <phrase role="special">(</phrase>
+ <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">tp</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">int</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&gt;::</phrase><phrase role="identifier">iterator</phrase> <phrase role="identifier">i</phrase><phrase role="special">(</phrase> <phrase role="identifier">results</phrase><phrase role="special">.</phrase><phrase role="identifier">begin</phrase><phrase role="special">()</phrase> <phrase role="special">);</phrase>
+ <phrase role="identifier">i</phrase> <phrase role="special">!=</phrase> <phrase role="identifier">e</phrase><phrase role="special">;</phrase>
+ <phrase role="special">++</phrase><phrase role="identifier">i</phrase><phrase role="special">)</phrase>
+ <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;fibonacci &quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">k</phrase><phrase role="special">++</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot; == &quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">i</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">get</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase>
+
+ <phrase role="identifier">pt</phrase><phrase role="special">::</phrase><phrase role="identifier">ptime</phrase> <phrase role="identifier">stop</phrase><phrase role="special">(</phrase> <phrase role="identifier">pt</phrase><phrase role="special">::</phrase><phrase role="identifier">microsec_clock</phrase><phrase role="special">::</phrase><phrase role="identifier">universal_time</phrase><phrase role="special">()</phrase> <phrase role="special">);</phrase>
+ <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="special">(</phrase> <phrase role="identifier">stop</phrase> <phrase role="special">-</phrase> <phrase role="identifier">start</phrase><phrase role="special">).</phrase><phrase role="identifier">total_milliseconds</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot; milli seconds&quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase>
+
+ <phrase role="keyword">return</phrase> <phrase role="identifier">EXIT_SUCCESS</phrase><phrase role="special">;</phrase>
+ <phrase role="special">}</phrase>
+ <phrase role="keyword">catch</phrase> <phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">exception</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">e</phrase><phrase role="special">)</phrase>
+ <phrase role="special">{</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cerr</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;exception: &quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">e</phrase><phrase role="special">.</phrase><phrase role="identifier">what</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase>
+ <phrase role="keyword">catch</phrase> <phrase role="special">(</phrase> <phrase role="special">...</phrase> <phrase role="special">)</phrase>
+ <phrase role="special">{</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cerr</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;unhandled&quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase>
+
+ <phrase role="keyword">return</phrase> <phrase role="identifier">EXIT_FAILURE</phrase><phrase role="special">;</phrase>
+<phrase role="special">}</phrase>
+</programlisting>
+ <para>
+ class fibo { private: int offset_;
+ </para>
+
+<programlisting> <phrase role="keyword">int</phrase> <phrase role="identifier">seq_</phrase><phrase role="special">(</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">n</phrase><phrase role="special">)</phrase>
+ <phrase role="special">{</phrase>
+ <phrase role="keyword">if</phrase> <phrase role="special">(</phrase> <phrase role="identifier">n</phrase> <phrase role="special">&lt;=</phrase> <phrase role="number">1</phrase><phrase role="special">)</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">n</phrase><phrase role="special">;</phrase>
+ <phrase role="keyword">else</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">seq_</phrase><phrase role="special">(</phrase> <phrase role="identifier">n</phrase> <phrase role="special">-</phrase> <phrase role="number">2</phrase><phrase role="special">)</phrase> <phrase role="special">+</phrase> <phrase role="identifier">seq_</phrase><phrase role="special">(</phrase> <phrase role="identifier">n</phrase> <phrase role="special">-</phrase> <phrase role="number">1</phrase><phrase role="special">);</phrase>
+ <phrase role="special">}</phrase>
+
+ <phrase role="keyword">int</phrase> <phrase role="identifier">par_</phrase><phrase role="special">(</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">n</phrase><phrase role="special">)</phrase>
+ <phrase role="special">{</phrase>
+ <phrase role="keyword">if</phrase> <phrase role="special">(</phrase> <phrase role="identifier">n</phrase> <phrase role="special">&lt;=</phrase> <phrase role="identifier">offset_</phrase><phrase role="special">)</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">seq_</phrase><phrase role="special">(</phrase> <phrase role="identifier">n</phrase><phrase role="special">);</phrase>
+ <phrase role="keyword">else</phrase>
+ <phrase role="special">{</phrase>
+ <phrase role="identifier">tp</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">int</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">t1</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">this_task</phrase><phrase role="special">::</phrase><phrase role="identifier">get_thread_pool</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">pool_type</phrase> <phrase role="special">&gt;().</phrase><phrase role="identifier">submit</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">bind</phrase><phrase role="special">(</phrase>
+ <phrase role="special">&amp;</phrase> <phrase role="identifier">fibo</phrase><phrase role="special">::</phrase><phrase role="identifier">par_</phrase><phrase role="special">,</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">ref</phrase><phrase role="special">(</phrase> <phrase role="special">*</phrase> <phrase role="keyword">this</phrase><phrase role="special">),</phrase>
+ <phrase role="identifier">n</phrase> <phrase role="special">-</phrase> <phrase role="number">1</phrase><phrase role="special">)</phrase> <phrase role="special">)</phrase> <phrase role="special">);</phrase>
+ <phrase role="identifier">tp</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">int</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">t2</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">this_task</phrase><phrase role="special">::</phrase><phrase role="identifier">get_thread_pool</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">pool_type</phrase> <phrase role="special">&gt;().</phrase><phrase role="identifier">submit</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">bind</phrase><phrase role="special">(</phrase>
+ <phrase role="special">&amp;</phrase> <phrase role="identifier">fibo</phrase><phrase role="special">::</phrase><phrase role="identifier">par_</phrase><phrase role="special">,</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">ref</phrase><phrase role="special">(</phrase> <phrase role="special">*</phrase> <phrase role="keyword">this</phrase><phrase role="special">),</phrase>
+ <phrase role="identifier">n</phrase> <phrase role="special">-</phrase> <phrase role="number">2</phrase><phrase role="special">)</phrase> <phrase role="special">)</phrase> <phrase role="special">);</phrase>
+ <phrase role="keyword">return</phrase> <phrase role="identifier">t1</phrase><phrase role="special">.</phrase><phrase role="identifier">get</phrase><phrase role="special">()</phrase> <phrase role="special">+</phrase> <phrase role="identifier">t2</phrase><phrase role="special">.</phrase><phrase role="identifier">get</phrase><phrase role="special">();</phrase>
+ <phrase role="special">}</phrase>
+ <phrase role="special">}</phrase>
+
+<phrase role="keyword">public</phrase><phrase role="special">:</phrase>
+ <phrase role="identifier">fibo</phrase><phrase role="special">(</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">offset</phrase><phrase role="special">)</phrase>
+ <phrase role="special">:</phrase> <phrase role="identifier">offset_</phrase><phrase role="special">(</phrase> <phrase role="identifier">offset</phrase><phrase role="special">)</phrase>
+ <phrase role="special">{}</phrase>
+
+ <phrase role="keyword">int</phrase> <phrase role="identifier">execute</phrase><phrase role="special">(</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">n</phrase><phrase role="special">)</phrase>
+ <phrase role="special">{</phrase>
+ <phrase role="keyword">int</phrase> <phrase role="identifier">result</phrase><phrase role="special">(</phrase> <phrase role="identifier">par_</phrase><phrase role="special">(</phrase> <phrase role="identifier">n</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase>
+ <phrase role="keyword">return</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
+ <phrase role="special">}</phrase>
+<phrase role="special">};</phrase>
+
+<phrase role="keyword">int</phrase> <phrase role="identifier">main</phrase><phrase role="special">(</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">argc</phrase><phrase role="special">,</phrase> <phrase role="keyword">char</phrase> <phrase role="special">*</phrase><phrase role="identifier">argv</phrase><phrase role="special">[])</phrase>
+<phrase role="special">{</phrase>
+ <phrase role="keyword">try</phrase>
+ <phrase role="special">{</phrase>
+ <phrase role="identifier">pool_type</phrase> <phrase role="identifier">pool</phrase><phrase role="special">(</phrase> <phrase role="identifier">tp</phrase><phrase role="special">::</phrase><phrase role="identifier">poolsize</phrase><phrase role="special">(</phrase> <phrase role="number">3</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase>
+ <phrase role="identifier">fibo</phrase> <phrase role="identifier">fib</phrase><phrase role="special">(</phrase> <phrase role="number">5</phrase><phrase role="special">);</phrase>
+ <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">tp</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">int</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">results</phrase><phrase role="special">;</phrase>
+ <phrase role="identifier">results</phrase><phrase role="special">.</phrase><phrase role="identifier">reserve</phrase><phrase role="special">(</phrase> <phrase role="number">40</phrase><phrase role="special">);</phrase>
+
+ <phrase role="identifier">pt</phrase><phrase role="special">::</phrase><phrase role="identifier">ptime</phrase> <phrase role="identifier">start</phrase><phrase role="special">(</phrase> <phrase role="identifier">pt</phrase><phrase role="special">::</phrase><phrase role="identifier">microsec_clock</phrase><phrase role="special">::</phrase><phrase role="identifier">universal_time</phrase><phrase role="special">()</phrase> <phrase role="special">);</phrase>
+
+ <phrase role="keyword">for</phrase> <phrase role="special">(</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">i</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase> <phrase role="identifier">i</phrase> <phrase role="special">&lt;</phrase> <phrase role="number">32</phrase><phrase role="special">;</phrase> <phrase role="special">++</phrase><phrase role="identifier">i</phrase><phrase role="special">)</phrase>
+ <phrase role="identifier">results</phrase><phrase role="special">.</phrase><phrase role="identifier">push_back</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">pool</phrase><phrase role="special">.</phrase><phrase role="identifier">submit</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">bind</phrase><phrase role="special">(</phrase>
+ <phrase role="special">&amp;</phrase> <phrase role="identifier">fibo</phrase><phrase role="special">::</phrase><phrase role="identifier">execute</phrase><phrase role="special">,</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">ref</phrase><phrase role="special">(</phrase> <phrase role="identifier">fib</phrase><phrase role="special">),</phrase>
+ <phrase role="identifier">i</phrase><phrase role="special">)</phrase> <phrase role="special">)</phrase> <phrase role="special">);</phrase>
+
+ <phrase role="keyword">int</phrase> <phrase role="identifier">k</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase>
+ <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">tp</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">int</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&gt;::</phrase><phrase role="identifier">iterator</phrase> <phrase role="identifier">e</phrase><phrase role="special">(</phrase> <phrase role="identifier">results</phrase><phrase role="special">.</phrase><phrase role="identifier">end</phrase><phrase role="special">()</phrase> <phrase role="special">);</phrase>
+ <phrase role="keyword">for</phrase> <phrase role="special">(</phrase>
+ <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">tp</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">int</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&gt;::</phrase><phrase role="identifier">iterator</phrase> <phrase role="identifier">i</phrase><phrase role="special">(</phrase> <phrase role="identifier">results</phrase><phrase role="special">.</phrase><phrase role="identifier">begin</phrase><phrase role="special">()</phrase> <phrase role="special">);</phrase>
+ <phrase role="identifier">i</phrase> <phrase role="special">!=</phrase> <phrase role="identifier">e</phrase><phrase role="special">;</phrase>
+ <phrase role="special">++</phrase><phrase role="identifier">i</phrase><phrase role="special">)</phrase>
+ <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;fibonacci &quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">k</phrase><phrase role="special">++</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot; == &quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">i</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">get</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase>
+
+ <phrase role="identifier">pt</phrase><phrase role="special">::</phrase><phrase role="identifier">ptime</phrase> <phrase role="identifier">stop</phrase><phrase role="special">(</phrase> <phrase role="identifier">pt</phrase><phrase role="special">::</phrase><phrase role="identifier">microsec_clock</phrase><phrase role="special">::</phrase><phrase role="identifier">universal_time</phrase><phrase role="special">()</phrase> <phrase role="special">);</phrase>
+ <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="special">(</phrase> <phrase role="identifier">stop</phrase> <phrase role="special">-</phrase> <phrase role="identifier">start</phrase><phrase role="special">).</phrase><phrase role="identifier">total_milliseconds</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot; milli seconds&quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase>
+
+ <phrase role="keyword">return</phrase> <phrase role="identifier">EXIT_SUCCESS</phrase><phrase role="special">;</phrase>
+ <phrase role="special">}</phrase>
+ <phrase role="keyword">catch</phrase> <phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">exception</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">e</phrase><phrase role="special">)</phrase>
+ <phrase role="special">{</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cerr</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;exception: &quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">e</phrase><phrase role="special">.</phrase><phrase role="identifier">what</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase>
+ <phrase role="keyword">catch</phrase> <phrase role="special">(</phrase> <phrase role="special">...</phrase> <phrase role="special">)</phrase>
+ <phrase role="special">{</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cerr</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;unhandled&quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase>
+
+ <phrase role="keyword">return</phrase> <phrase role="identifier">EXIT_FAILURE</phrase><phrase role="special">;</phrase>
+<phrase role="special">}</phrase>
+</programlisting>
+ <para>
+ int seq<emphasis role="underline">( int n) { if ( n &lt;= 1) return n; else
+ return seq</emphasis>( n - 2) + seq_( n - 1); }
+ </para>
+
+<programlisting> <phrase role="keyword">int</phrase> <phrase role="identifier">par_</phrase><phrase role="special">(</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">n</phrase><phrase role="special">)</phrase>
+ <phrase role="special">{</phrase>
+ <phrase role="keyword">if</phrase> <phrase role="special">(</phrase> <phrase role="identifier">n</phrase> <phrase role="special">&lt;=</phrase> <phrase role="identifier">offset_</phrase><phrase role="special">)</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">seq_</phrase><phrase role="special">(</phrase> <phrase role="identifier">n</phrase><phrase role="special">);</phrase>
+ <phrase role="keyword">else</phrase>
+ <phrase role="special">{</phrase>
+ <phrase role="identifier">tp</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">int</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">t1</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">this_task</phrase><phrase role="special">::</phrase><phrase role="identifier">get_thread_pool</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">pool_type</phrase> <phrase role="special">&gt;().</phrase><phrase role="identifier">submit</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">bind</phrase><phrase role="special">(</phrase>
+ <phrase role="special">&amp;</phrase> <phrase role="identifier">fibo</phrase><phrase role="special">::</phrase><phrase role="identifier">par_</phrase><phrase role="special">,</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">ref</phrase><phrase role="special">(</phrase> <phrase role="special">*</phrase> <phrase role="keyword">this</phrase><phrase role="special">),</phrase>
+ <phrase role="identifier">n</phrase> <phrase role="special">-</phrase> <phrase role="number">1</phrase><phrase role="special">)</phrase> <phrase role="special">)</phrase> <phrase role="special">);</phrase>
+ <phrase role="identifier">tp</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">int</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">t2</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">this_task</phrase><phrase role="special">::</phrase><phrase role="identifier">get_thread_pool</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">pool_type</phrase> <phrase role="special">&gt;().</phrase><phrase role="identifier">submit</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">bind</phrase><phrase role="special">(</phrase>
+ <phrase role="special">&amp;</phrase> <phrase role="identifier">fibo</phrase><phrase role="special">::</phrase><phrase role="identifier">par_</phrase><phrase role="special">,</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">ref</phrase><phrase role="special">(</phrase> <phrase role="special">*</phrase> <phrase role="keyword">this</phrase><phrase role="special">),</phrase>
+ <phrase role="identifier">n</phrase> <phrase role="special">-</phrase> <phrase role="number">2</phrase><phrase role="special">)</phrase> <phrase role="special">)</phrase> <phrase role="special">);</phrase>
+ <phrase role="keyword">return</phrase> <phrase role="identifier">t1</phrase><phrase role="special">.</phrase><phrase role="identifier">get</phrase><phrase role="special">()</phrase> <phrase role="special">+</phrase> <phrase role="identifier">t2</phrase><phrase role="special">.</phrase><phrase role="identifier">get</phrase><phrase role="special">();</phrase>
+ <phrase role="special">}</phrase>
+ <phrase role="special">}</phrase>
+
+<phrase role="keyword">public</phrase><phrase role="special">:</phrase>
+ <phrase role="identifier">fibo</phrase><phrase role="special">(</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">offset</phrase><phrase role="special">)</phrase>
+ <phrase role="special">:</phrase> <phrase role="identifier">offset_</phrase><phrase role="special">(</phrase> <phrase role="identifier">offset</phrase><phrase role="special">)</phrase>
+ <phrase role="special">{}</phrase>
+
+ <phrase role="keyword">int</phrase> <phrase role="identifier">execute</phrase><phrase role="special">(</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">n</phrase><phrase role="special">)</phrase>
+ <phrase role="special">{</phrase>
+ <phrase role="keyword">int</phrase> <phrase role="identifier">result</phrase><phrase role="special">(</phrase> <phrase role="identifier">par_</phrase><phrase role="special">(</phrase> <phrase role="identifier">n</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase>
+ <phrase role="keyword">return</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
+ <phrase role="special">}</phrase>
+<phrase role="special">};</phrase>
+
+<phrase role="keyword">int</phrase> <phrase role="identifier">main</phrase><phrase role="special">(</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">argc</phrase><phrase role="special">,</phrase> <phrase role="keyword">char</phrase> <phrase role="special">*</phrase><phrase role="identifier">argv</phrase><phrase role="special">[])</phrase>
+<phrase role="special">{</phrase>
+ <phrase role="keyword">try</phrase>
+ <phrase role="special">{</phrase>
+ <phrase role="identifier">pool_type</phrase> <phrase role="identifier">pool</phrase><phrase role="special">(</phrase> <phrase role="identifier">tp</phrase><phrase role="special">::</phrase><phrase role="identifier">poolsize</phrase><phrase role="special">(</phrase> <phrase role="number">3</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase>
+ <phrase role="identifier">fibo</phrase> <phrase role="identifier">fib</phrase><phrase role="special">(</phrase> <phrase role="number">5</phrase><phrase role="special">);</phrase>
+ <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">tp</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">int</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">results</phrase><phrase role="special">;</phrase>
+ <phrase role="identifier">results</phrase><phrase role="special">.</phrase><phrase role="identifier">reserve</phrase><phrase role="special">(</phrase> <phrase role="number">40</phrase><phrase role="special">);</phrase>
+
+ <phrase role="identifier">pt</phrase><phrase role="special">::</phrase><phrase role="identifier">ptime</phrase> <phrase role="identifier">start</phrase><phrase role="special">(</phrase> <phrase role="identifier">pt</phrase><phrase role="special">::</phrase><phrase role="identifier">microsec_clock</phrase><phrase role="special">::</phrase><phrase role="identifier">universal_time</phrase><phrase role="special">()</phrase> <phrase role="special">);</phrase>
+
+ <phrase role="keyword">for</phrase> <phrase role="special">(</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">i</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase> <phrase role="identifier">i</phrase> <phrase role="special">&lt;</phrase> <phrase role="number">32</phrase><phrase role="special">;</phrase> <phrase role="special">++</phrase><phrase role="identifier">i</phrase><phrase role="special">)</phrase>
+ <phrase role="identifier">results</phrase><phrase role="special">.</phrase><phrase role="identifier">push_back</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">pool</phrase><phrase role="special">.</phrase><phrase role="identifier">submit</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">bind</phrase><phrase role="special">(</phrase>
+ <phrase role="special">&amp;</phrase> <phrase role="identifier">fibo</phrase><phrase role="special">::</phrase><phrase role="identifier">execute</phrase><phrase role="special">,</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">ref</phrase><phrase role="special">(</phrase> <phrase role="identifier">fib</phrase><phrase role="special">),</phrase>
+ <phrase role="identifier">i</phrase><phrase role="special">)</phrase> <phrase role="special">)</phrase> <phrase role="special">);</phrase>
+
+ <phrase role="keyword">int</phrase> <phrase role="identifier">k</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase>
+ <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">tp</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">int</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&gt;::</phrase><phrase role="identifier">iterator</phrase> <phrase role="identifier">e</phrase><phrase role="special">(</phrase> <phrase role="identifier">results</phrase><phrase role="special">.</phrase><phrase role="identifier">end</phrase><phrase role="special">()</phrase> <phrase role="special">);</phrase>
+ <phrase role="keyword">for</phrase> <phrase role="special">(</phrase>
+ <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">tp</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">int</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&gt;::</phrase><phrase role="identifier">iterator</phrase> <phrase role="identifier">i</phrase><phrase role="special">(</phrase> <phrase role="identifier">results</phrase><phrase role="special">.</phrase><phrase role="identifier">begin</phrase><phrase role="special">()</phrase> <phrase role="special">);</phrase>
+ <phrase role="identifier">i</phrase> <phrase role="special">!=</phrase> <phrase role="identifier">e</phrase><phrase role="special">;</phrase>
+ <phrase role="special">++</phrase><phrase role="identifier">i</phrase><phrase role="special">)</phrase>
+ <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;fibonacci &quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">k</phrase><phrase role="special">++</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot; == &quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">i</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">get</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase>
+
+ <phrase role="identifier">pt</phrase><phrase role="special">::</phrase><phrase role="identifier">ptime</phrase> <phrase role="identifier">stop</phrase><phrase role="special">(</phrase> <phrase role="identifier">pt</phrase><phrase role="special">::</phrase><phrase role="identifier">microsec_clock</phrase><phrase role="special">::</phrase><phrase role="identifier">universal_time</phrase><phrase role="special">()</phrase> <phrase role="special">);</phrase>
+ <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="special">(</phrase> <phrase role="identifier">stop</phrase> <phrase role="special">-</phrase> <phrase role="identifier">start</phrase><phrase role="special">).</phrase><phrase role="identifier">total_milliseconds</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot; milli seconds&quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase>
+
+ <phrase role="keyword">return</phrase> <phrase role="identifier">EXIT_SUCCESS</phrase><phrase role="special">;</phrase>
+ <phrase role="special">}</phrase>
+ <phrase role="keyword">catch</phrase> <phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">exception</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">e</phrase><phrase role="special">)</phrase>
+ <phrase role="special">{</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cerr</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;exception: &quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">e</phrase><phrase role="special">.</phrase><phrase role="identifier">what</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase>
+ <phrase role="keyword">catch</phrase> <phrase role="special">(</phrase> <phrase role="special">...</phrase> <phrase role="special">)</phrase>
+ <phrase role="special">{</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cerr</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;unhandled&quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase>
+
+ <phrase role="keyword">return</phrase> <phrase role="identifier">EXIT_FAILURE</phrase><phrase role="special">;</phrase>
+<phrase role="special">}</phrase>
+</programlisting>
+ <para>
+ int par<emphasis role="underline">( int n) { if ( n &lt;= offset</emphasis>)
+ return seq_( n); else { tp::task&lt; int &gt; t1( boost::this_task::get_thread_pool&lt;
+ pool<emphasis role="underline">type &gt;().submit( boost::bind( &amp; fibo::par</emphasis>,
+ boost::ref( * this), n - 1) ) ); tp::task&lt; int &gt; t2( boost::this_task::get_thread_pool&lt;
+ pool<emphasis role="underline">type &gt;().submit( boost::bind( &amp; fibo::par</emphasis>,
+ boost::ref( * this), n - 2) ) ); return t1.get() + t2.get(); } }
+ </para>
+
+<programlisting><phrase role="keyword">public</phrase><phrase role="special">:</phrase>
+ <phrase role="identifier">fibo</phrase><phrase role="special">(</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">offset</phrase><phrase role="special">)</phrase>
+ <phrase role="special">:</phrase> <phrase role="identifier">offset_</phrase><phrase role="special">(</phrase> <phrase role="identifier">offset</phrase><phrase role="special">)</phrase>
+ <phrase role="special">{}</phrase>
+
+ <phrase role="keyword">int</phrase> <phrase role="identifier">execute</phrase><phrase role="special">(</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">n</phrase><phrase role="special">)</phrase>
+ <phrase role="special">{</phrase>
+ <phrase role="keyword">int</phrase> <phrase role="identifier">result</phrase><phrase role="special">(</phrase> <phrase role="identifier">par_</phrase><phrase role="special">(</phrase> <phrase role="identifier">n</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase>
+ <phrase role="keyword">return</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
+ <phrase role="special">}</phrase>
+<phrase role="special">};</phrase>
+
+<phrase role="keyword">int</phrase> <phrase role="identifier">main</phrase><phrase role="special">(</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">argc</phrase><phrase role="special">,</phrase> <phrase role="keyword">char</phrase> <phrase role="special">*</phrase><phrase role="identifier">argv</phrase><phrase role="special">[])</phrase>
+<phrase role="special">{</phrase>
+ <phrase role="keyword">try</phrase>
+ <phrase role="special">{</phrase>
+ <phrase role="identifier">pool_type</phrase> <phrase role="identifier">pool</phrase><phrase role="special">(</phrase> <phrase role="identifier">tp</phrase><phrase role="special">::</phrase><phrase role="identifier">poolsize</phrase><phrase role="special">(</phrase> <phrase role="number">3</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase>
+ <phrase role="identifier">fibo</phrase> <phrase role="identifier">fib</phrase><phrase role="special">(</phrase> <phrase role="number">5</phrase><phrase role="special">);</phrase>
+ <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">tp</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">int</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">results</phrase><phrase role="special">;</phrase>
+ <phrase role="identifier">results</phrase><phrase role="special">.</phrase><phrase role="identifier">reserve</phrase><phrase role="special">(</phrase> <phrase role="number">40</phrase><phrase role="special">);</phrase>
+
+ <phrase role="identifier">pt</phrase><phrase role="special">::</phrase><phrase role="identifier">ptime</phrase> <phrase role="identifier">start</phrase><phrase role="special">(</phrase> <phrase role="identifier">pt</phrase><phrase role="special">::</phrase><phrase role="identifier">microsec_clock</phrase><phrase role="special">::</phrase><phrase role="identifier">universal_time</phrase><phrase role="special">()</phrase> <phrase role="special">);</phrase>
+
+ <phrase role="keyword">for</phrase> <phrase role="special">(</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">i</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase> <phrase role="identifier">i</phrase> <phrase role="special">&lt;</phrase> <phrase role="number">32</phrase><phrase role="special">;</phrase> <phrase role="special">++</phrase><phrase role="identifier">i</phrase><phrase role="special">)</phrase>
+ <phrase role="identifier">results</phrase><phrase role="special">.</phrase><phrase role="identifier">push_back</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">pool</phrase><phrase role="special">.</phrase><phrase role="identifier">submit</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">bind</phrase><phrase role="special">(</phrase>
+ <phrase role="special">&amp;</phrase> <phrase role="identifier">fibo</phrase><phrase role="special">::</phrase><phrase role="identifier">execute</phrase><phrase role="special">,</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">ref</phrase><phrase role="special">(</phrase> <phrase role="identifier">fib</phrase><phrase role="special">),</phrase>
+ <phrase role="identifier">i</phrase><phrase role="special">)</phrase> <phrase role="special">)</phrase> <phrase role="special">);</phrase>
+
+ <phrase role="keyword">int</phrase> <phrase role="identifier">k</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase>
+ <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">tp</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">int</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&gt;::</phrase><phrase role="identifier">iterator</phrase> <phrase role="identifier">e</phrase><phrase role="special">(</phrase> <phrase role="identifier">results</phrase><phrase role="special">.</phrase><phrase role="identifier">end</phrase><phrase role="special">()</phrase> <phrase role="special">);</phrase>
+ <phrase role="keyword">for</phrase> <phrase role="special">(</phrase>
+ <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">tp</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">int</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&gt;::</phrase><phrase role="identifier">iterator</phrase> <phrase role="identifier">i</phrase><phrase role="special">(</phrase> <phrase role="identifier">results</phrase><phrase role="special">.</phrase><phrase role="identifier">begin</phrase><phrase role="special">()</phrase> <phrase role="special">);</phrase>
+ <phrase role="identifier">i</phrase> <phrase role="special">!=</phrase> <phrase role="identifier">e</phrase><phrase role="special">;</phrase>
+ <phrase role="special">++</phrase><phrase role="identifier">i</phrase><phrase role="special">)</phrase>
+ <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;fibonacci &quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">k</phrase><phrase role="special">++</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot; == &quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">i</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">get</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase>
+
+ <phrase role="identifier">pt</phrase><phrase role="special">::</phrase><phrase role="identifier">ptime</phrase> <phrase role="identifier">stop</phrase><phrase role="special">(</phrase> <phrase role="identifier">pt</phrase><phrase role="special">::</phrase><phrase role="identifier">microsec_clock</phrase><phrase role="special">::</phrase><phrase role="identifier">universal_time</phrase><phrase role="special">()</phrase> <phrase role="special">);</phrase>
+ <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="special">(</phrase> <phrase role="identifier">stop</phrase> <phrase role="special">-</phrase> <phrase role="identifier">start</phrase><phrase role="special">).</phrase><phrase role="identifier">total_milliseconds</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot; milli seconds&quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase>
+
+ <phrase role="keyword">return</phrase> <phrase role="identifier">EXIT_SUCCESS</phrase><phrase role="special">;</phrase>
+ <phrase role="special">}</phrase>
+ <phrase role="keyword">catch</phrase> <phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">exception</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">e</phrase><phrase role="special">)</phrase>
+ <phrase role="special">{</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cerr</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;exception: &quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">e</phrase><phrase role="special">.</phrase><phrase role="identifier">what</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase>
+ <phrase role="keyword">catch</phrase> <phrase role="special">(</phrase> <phrase role="special">...</phrase> <phrase role="special">)</phrase>
+ <phrase role="special">{</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cerr</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;unhandled&quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase>
+
+ <phrase role="keyword">return</phrase> <phrase role="identifier">EXIT_FAILURE</phrase><phrase role="special">;</phrase>
+<phrase role="special">}</phrase>
+</programlisting>
+ <para>
+ public: fibo( int offset) : offset_( offset) {}
+ </para>
+
+<programlisting> <phrase role="keyword">int</phrase> <phrase role="identifier">execute</phrase><phrase role="special">(</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">n</phrase><phrase role="special">)</phrase>
+ <phrase role="special">{</phrase>
+ <phrase role="keyword">int</phrase> <phrase role="identifier">result</phrase><phrase role="special">(</phrase> <phrase role="identifier">par_</phrase><phrase role="special">(</phrase> <phrase role="identifier">n</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase>
+ <phrase role="keyword">return</phrase> <phrase role="identifier">result</phrase><phrase role="special">;</phrase>
+ <phrase role="special">}</phrase>
+<phrase role="special">};</phrase>
+
+<phrase role="keyword">int</phrase> <phrase role="identifier">main</phrase><phrase role="special">(</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">argc</phrase><phrase role="special">,</phrase> <phrase role="keyword">char</phrase> <phrase role="special">*</phrase><phrase role="identifier">argv</phrase><phrase role="special">[])</phrase>
+<phrase role="special">{</phrase>
+ <phrase role="keyword">try</phrase>
+ <phrase role="special">{</phrase>
+ <phrase role="identifier">pool_type</phrase> <phrase role="identifier">pool</phrase><phrase role="special">(</phrase> <phrase role="identifier">tp</phrase><phrase role="special">::</phrase><phrase role="identifier">poolsize</phrase><phrase role="special">(</phrase> <phrase role="number">3</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase>
+ <phrase role="identifier">fibo</phrase> <phrase role="identifier">fib</phrase><phrase role="special">(</phrase> <phrase role="number">5</phrase><phrase role="special">);</phrase>
+ <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">tp</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">int</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">results</phrase><phrase role="special">;</phrase>
+ <phrase role="identifier">results</phrase><phrase role="special">.</phrase><phrase role="identifier">reserve</phrase><phrase role="special">(</phrase> <phrase role="number">40</phrase><phrase role="special">);</phrase>
+
+ <phrase role="identifier">pt</phrase><phrase role="special">::</phrase><phrase role="identifier">ptime</phrase> <phrase role="identifier">start</phrase><phrase role="special">(</phrase> <phrase role="identifier">pt</phrase><phrase role="special">::</phrase><phrase role="identifier">microsec_clock</phrase><phrase role="special">::</phrase><phrase role="identifier">universal_time</phrase><phrase role="special">()</phrase> <phrase role="special">);</phrase>
+
+ <phrase role="keyword">for</phrase> <phrase role="special">(</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">i</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase> <phrase role="identifier">i</phrase> <phrase role="special">&lt;</phrase> <phrase role="number">32</phrase><phrase role="special">;</phrase> <phrase role="special">++</phrase><phrase role="identifier">i</phrase><phrase role="special">)</phrase>
+ <phrase role="identifier">results</phrase><phrase role="special">.</phrase><phrase role="identifier">push_back</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">pool</phrase><phrase role="special">.</phrase><phrase role="identifier">submit</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">bind</phrase><phrase role="special">(</phrase>
+ <phrase role="special">&amp;</phrase> <phrase role="identifier">fibo</phrase><phrase role="special">::</phrase><phrase role="identifier">execute</phrase><phrase role="special">,</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">ref</phrase><phrase role="special">(</phrase> <phrase role="identifier">fib</phrase><phrase role="special">),</phrase>
+ <phrase role="identifier">i</phrase><phrase role="special">)</phrase> <phrase role="special">)</phrase> <phrase role="special">);</phrase>
+
+ <phrase role="keyword">int</phrase> <phrase role="identifier">k</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase>
+ <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">tp</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">int</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&gt;::</phrase><phrase role="identifier">iterator</phrase> <phrase role="identifier">e</phrase><phrase role="special">(</phrase> <phrase role="identifier">results</phrase><phrase role="special">.</phrase><phrase role="identifier">end</phrase><phrase role="special">()</phrase> <phrase role="special">);</phrase>
+ <phrase role="keyword">for</phrase> <phrase role="special">(</phrase>
+ <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">tp</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">int</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&gt;::</phrase><phrase role="identifier">iterator</phrase> <phrase role="identifier">i</phrase><phrase role="special">(</phrase> <phrase role="identifier">results</phrase><phrase role="special">.</phrase><phrase role="identifier">begin</phrase><phrase role="special">()</phrase> <phrase role="special">);</phrase>
+ <phrase role="identifier">i</phrase> <phrase role="special">!=</phrase> <phrase role="identifier">e</phrase><phrase role="special">;</phrase>
+ <phrase role="special">++</phrase><phrase role="identifier">i</phrase><phrase role="special">)</phrase>
+ <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;fibonacci &quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">k</phrase><phrase role="special">++</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot; == &quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">i</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">get</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase>
+
+ <phrase role="identifier">pt</phrase><phrase role="special">::</phrase><phrase role="identifier">ptime</phrase> <phrase role="identifier">stop</phrase><phrase role="special">(</phrase> <phrase role="identifier">pt</phrase><phrase role="special">::</phrase><phrase role="identifier">microsec_clock</phrase><phrase role="special">::</phrase><phrase role="identifier">universal_time</phrase><phrase role="special">()</phrase> <phrase role="special">);</phrase>
+ <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="special">(</phrase> <phrase role="identifier">stop</phrase> <phrase role="special">-</phrase> <phrase role="identifier">start</phrase><phrase role="special">).</phrase><phrase role="identifier">total_milliseconds</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot; milli seconds&quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase>
+
+ <phrase role="keyword">return</phrase> <phrase role="identifier">EXIT_SUCCESS</phrase><phrase role="special">;</phrase>
+ <phrase role="special">}</phrase>
+ <phrase role="keyword">catch</phrase> <phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">exception</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">e</phrase><phrase role="special">)</phrase>
+ <phrase role="special">{</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cerr</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;exception: &quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">e</phrase><phrase role="special">.</phrase><phrase role="identifier">what</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase>
+ <phrase role="keyword">catch</phrase> <phrase role="special">(</phrase> <phrase role="special">...</phrase> <phrase role="special">)</phrase>
+ <phrase role="special">{</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cerr</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;unhandled&quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase>
+
+ <phrase role="keyword">return</phrase> <phrase role="identifier">EXIT_FAILURE</phrase><phrase role="special">;</phrase>
+<phrase role="special">}</phrase>
+</programlisting>
+ <para>
+ int execute( int n) { int result( par_( n) ); return result; } };
+ </para>
+
+<programlisting><phrase role="keyword">int</phrase> <phrase role="identifier">main</phrase><phrase role="special">(</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">argc</phrase><phrase role="special">,</phrase> <phrase role="keyword">char</phrase> <phrase role="special">*</phrase><phrase role="identifier">argv</phrase><phrase role="special">[])</phrase>
+<phrase role="special">{</phrase>
+ <phrase role="keyword">try</phrase>
+ <phrase role="special">{</phrase>
+ <phrase role="identifier">pool_type</phrase> <phrase role="identifier">pool</phrase><phrase role="special">(</phrase> <phrase role="identifier">tp</phrase><phrase role="special">::</phrase><phrase role="identifier">poolsize</phrase><phrase role="special">(</phrase> <phrase role="number">3</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase>
+ <phrase role="identifier">fibo</phrase> <phrase role="identifier">fib</phrase><phrase role="special">(</phrase> <phrase role="number">5</phrase><phrase role="special">);</phrase>
+ <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">tp</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">int</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">results</phrase><phrase role="special">;</phrase>
+ <phrase role="identifier">results</phrase><phrase role="special">.</phrase><phrase role="identifier">reserve</phrase><phrase role="special">(</phrase> <phrase role="number">40</phrase><phrase role="special">);</phrase>
+
+ <phrase role="identifier">pt</phrase><phrase role="special">::</phrase><phrase role="identifier">ptime</phrase> <phrase role="identifier">start</phrase><phrase role="special">(</phrase> <phrase role="identifier">pt</phrase><phrase role="special">::</phrase><phrase role="identifier">microsec_clock</phrase><phrase role="special">::</phrase><phrase role="identifier">universal_time</phrase><phrase role="special">()</phrase> <phrase role="special">);</phrase>
+
+ <phrase role="keyword">for</phrase> <phrase role="special">(</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">i</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase> <phrase role="identifier">i</phrase> <phrase role="special">&lt;</phrase> <phrase role="number">32</phrase><phrase role="special">;</phrase> <phrase role="special">++</phrase><phrase role="identifier">i</phrase><phrase role="special">)</phrase>
+ <phrase role="identifier">results</phrase><phrase role="special">.</phrase><phrase role="identifier">push_back</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">pool</phrase><phrase role="special">.</phrase><phrase role="identifier">submit</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">bind</phrase><phrase role="special">(</phrase>
+ <phrase role="special">&amp;</phrase> <phrase role="identifier">fibo</phrase><phrase role="special">::</phrase><phrase role="identifier">execute</phrase><phrase role="special">,</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">ref</phrase><phrase role="special">(</phrase> <phrase role="identifier">fib</phrase><phrase role="special">),</phrase>
+ <phrase role="identifier">i</phrase><phrase role="special">)</phrase> <phrase role="special">)</phrase> <phrase role="special">);</phrase>
+
+ <phrase role="keyword">int</phrase> <phrase role="identifier">k</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase>
+ <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">tp</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">int</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&gt;::</phrase><phrase role="identifier">iterator</phrase> <phrase role="identifier">e</phrase><phrase role="special">(</phrase> <phrase role="identifier">results</phrase><phrase role="special">.</phrase><phrase role="identifier">end</phrase><phrase role="special">()</phrase> <phrase role="special">);</phrase>
+ <phrase role="keyword">for</phrase> <phrase role="special">(</phrase>
+ <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">tp</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">int</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&gt;::</phrase><phrase role="identifier">iterator</phrase> <phrase role="identifier">i</phrase><phrase role="special">(</phrase> <phrase role="identifier">results</phrase><phrase role="special">.</phrase><phrase role="identifier">begin</phrase><phrase role="special">()</phrase> <phrase role="special">);</phrase>
+ <phrase role="identifier">i</phrase> <phrase role="special">!=</phrase> <phrase role="identifier">e</phrase><phrase role="special">;</phrase>
+ <phrase role="special">++</phrase><phrase role="identifier">i</phrase><phrase role="special">)</phrase>
+ <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;fibonacci &quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">k</phrase><phrase role="special">++</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot; == &quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">i</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">get</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase>
+
+ <phrase role="identifier">pt</phrase><phrase role="special">::</phrase><phrase role="identifier">ptime</phrase> <phrase role="identifier">stop</phrase><phrase role="special">(</phrase> <phrase role="identifier">pt</phrase><phrase role="special">::</phrase><phrase role="identifier">microsec_clock</phrase><phrase role="special">::</phrase><phrase role="identifier">universal_time</phrase><phrase role="special">()</phrase> <phrase role="special">);</phrase>
+ <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="special">(</phrase> <phrase role="identifier">stop</phrase> <phrase role="special">-</phrase> <phrase role="identifier">start</phrase><phrase role="special">).</phrase><phrase role="identifier">total_milliseconds</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot; milli seconds&quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase>
+
+ <phrase role="keyword">return</phrase> <phrase role="identifier">EXIT_SUCCESS</phrase><phrase role="special">;</phrase>
+ <phrase role="special">}</phrase>
+ <phrase role="keyword">catch</phrase> <phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">exception</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">e</phrase><phrase role="special">)</phrase>
+ <phrase role="special">{</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cerr</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;exception: &quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">e</phrase><phrase role="special">.</phrase><phrase role="identifier">what</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase>
+ <phrase role="keyword">catch</phrase> <phrase role="special">(</phrase> <phrase role="special">...</phrase> <phrase role="special">)</phrase>
+ <phrase role="special">{</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cerr</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;unhandled&quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase>
+
+ <phrase role="keyword">return</phrase> <phrase role="identifier">EXIT_FAILURE</phrase><phrase role="special">;</phrase>
+<phrase role="special">}</phrase>
+</programlisting>
+ <para>
+ int main( int argc, char *argv[]) { try { pool_type pool( tp::poolsize( 3)
+ ); fibo fib( 5); std::vector&lt; tp::task&lt; int &gt; &gt; results; results.reserve(
+ 40);
+ </para>
+
+<programlisting> <phrase role="identifier">pt</phrase><phrase role="special">::</phrase><phrase role="identifier">ptime</phrase> <phrase role="identifier">start</phrase><phrase role="special">(</phrase> <phrase role="identifier">pt</phrase><phrase role="special">::</phrase><phrase role="identifier">microsec_clock</phrase><phrase role="special">::</phrase><phrase role="identifier">universal_time</phrase><phrase role="special">()</phrase> <phrase role="special">);</phrase>
+
+ <phrase role="keyword">for</phrase> <phrase role="special">(</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">i</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase> <phrase role="identifier">i</phrase> <phrase role="special">&lt;</phrase> <phrase role="number">32</phrase><phrase role="special">;</phrase> <phrase role="special">++</phrase><phrase role="identifier">i</phrase><phrase role="special">)</phrase>
+ <phrase role="identifier">results</phrase><phrase role="special">.</phrase><phrase role="identifier">push_back</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">pool</phrase><phrase role="special">.</phrase><phrase role="identifier">submit</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">bind</phrase><phrase role="special">(</phrase>
+ <phrase role="special">&amp;</phrase> <phrase role="identifier">fibo</phrase><phrase role="special">::</phrase><phrase role="identifier">execute</phrase><phrase role="special">,</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">ref</phrase><phrase role="special">(</phrase> <phrase role="identifier">fib</phrase><phrase role="special">),</phrase>
+ <phrase role="identifier">i</phrase><phrase role="special">)</phrase> <phrase role="special">)</phrase> <phrase role="special">);</phrase>
+
+ <phrase role="keyword">int</phrase> <phrase role="identifier">k</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase>
+ <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">tp</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">int</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&gt;::</phrase><phrase role="identifier">iterator</phrase> <phrase role="identifier">e</phrase><phrase role="special">(</phrase> <phrase role="identifier">results</phrase><phrase role="special">.</phrase><phrase role="identifier">end</phrase><phrase role="special">()</phrase> <phrase role="special">);</phrase>
+ <phrase role="keyword">for</phrase> <phrase role="special">(</phrase>
+ <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">tp</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">int</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&gt;::</phrase><phrase role="identifier">iterator</phrase> <phrase role="identifier">i</phrase><phrase role="special">(</phrase> <phrase role="identifier">results</phrase><phrase role="special">.</phrase><phrase role="identifier">begin</phrase><phrase role="special">()</phrase> <phrase role="special">);</phrase>
+ <phrase role="identifier">i</phrase> <phrase role="special">!=</phrase> <phrase role="identifier">e</phrase><phrase role="special">;</phrase>
+ <phrase role="special">++</phrase><phrase role="identifier">i</phrase><phrase role="special">)</phrase>
+ <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;fibonacci &quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">k</phrase><phrase role="special">++</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot; == &quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">i</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">get</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase>
+
+ <phrase role="identifier">pt</phrase><phrase role="special">::</phrase><phrase role="identifier">ptime</phrase> <phrase role="identifier">stop</phrase><phrase role="special">(</phrase> <phrase role="identifier">pt</phrase><phrase role="special">::</phrase><phrase role="identifier">microsec_clock</phrase><phrase role="special">::</phrase><phrase role="identifier">universal_time</phrase><phrase role="special">()</phrase> <phrase role="special">);</phrase>
+ <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="special">(</phrase> <phrase role="identifier">stop</phrase> <phrase role="special">-</phrase> <phrase role="identifier">start</phrase><phrase role="special">).</phrase><phrase role="identifier">total_milliseconds</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot; milli seconds&quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase>
+
+ <phrase role="keyword">return</phrase> <phrase role="identifier">EXIT_SUCCESS</phrase><phrase role="special">;</phrase>
+ <phrase role="special">}</phrase>
+ <phrase role="keyword">catch</phrase> <phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">exception</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">e</phrase><phrase role="special">)</phrase>
+ <phrase role="special">{</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cerr</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;exception: &quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">e</phrase><phrase role="special">.</phrase><phrase role="identifier">what</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase>
+ <phrase role="keyword">catch</phrase> <phrase role="special">(</phrase> <phrase role="special">...</phrase> <phrase role="special">)</phrase>
+ <phrase role="special">{</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cerr</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;unhandled&quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase>
+
+ <phrase role="keyword">return</phrase> <phrase role="identifier">EXIT_FAILURE</phrase><phrase role="special">;</phrase>
+<phrase role="special">}</phrase>
+</programlisting>
+ <para>
+ pt::ptime start( pt::microsec_clock::universal_time() );
+ </para>
+
+<programlisting> <phrase role="keyword">for</phrase> <phrase role="special">(</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">i</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase> <phrase role="identifier">i</phrase> <phrase role="special">&lt;</phrase> <phrase role="number">32</phrase><phrase role="special">;</phrase> <phrase role="special">++</phrase><phrase role="identifier">i</phrase><phrase role="special">)</phrase>
+ <phrase role="identifier">results</phrase><phrase role="special">.</phrase><phrase role="identifier">push_back</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">pool</phrase><phrase role="special">.</phrase><phrase role="identifier">submit</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">bind</phrase><phrase role="special">(</phrase>
+ <phrase role="special">&amp;</phrase> <phrase role="identifier">fibo</phrase><phrase role="special">::</phrase><phrase role="identifier">execute</phrase><phrase role="special">,</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">ref</phrase><phrase role="special">(</phrase> <phrase role="identifier">fib</phrase><phrase role="special">),</phrase>
+ <phrase role="identifier">i</phrase><phrase role="special">)</phrase> <phrase role="special">)</phrase> <phrase role="special">);</phrase>
+
+ <phrase role="keyword">int</phrase> <phrase role="identifier">k</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase>
+ <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">tp</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">int</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&gt;::</phrase><phrase role="identifier">iterator</phrase> <phrase role="identifier">e</phrase><phrase role="special">(</phrase> <phrase role="identifier">results</phrase><phrase role="special">.</phrase><phrase role="identifier">end</phrase><phrase role="special">()</phrase> <phrase role="special">);</phrase>
+ <phrase role="keyword">for</phrase> <phrase role="special">(</phrase>
+ <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">tp</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">int</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&gt;::</phrase><phrase role="identifier">iterator</phrase> <phrase role="identifier">i</phrase><phrase role="special">(</phrase> <phrase role="identifier">results</phrase><phrase role="special">.</phrase><phrase role="identifier">begin</phrase><phrase role="special">()</phrase> <phrase role="special">);</phrase>
+ <phrase role="identifier">i</phrase> <phrase role="special">!=</phrase> <phrase role="identifier">e</phrase><phrase role="special">;</phrase>
+ <phrase role="special">++</phrase><phrase role="identifier">i</phrase><phrase role="special">)</phrase>
+ <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;fibonacci &quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">k</phrase><phrase role="special">++</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot; == &quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">i</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">get</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase>
+
+ <phrase role="identifier">pt</phrase><phrase role="special">::</phrase><phrase role="identifier">ptime</phrase> <phrase role="identifier">stop</phrase><phrase role="special">(</phrase> <phrase role="identifier">pt</phrase><phrase role="special">::</phrase><phrase role="identifier">microsec_clock</phrase><phrase role="special">::</phrase><phrase role="identifier">universal_time</phrase><phrase role="special">()</phrase> <phrase role="special">);</phrase>
+ <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="special">(</phrase> <phrase role="identifier">stop</phrase> <phrase role="special">-</phrase> <phrase role="identifier">start</phrase><phrase role="special">).</phrase><phrase role="identifier">total_milliseconds</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot; milli seconds&quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase>
+
+ <phrase role="keyword">return</phrase> <phrase role="identifier">EXIT_SUCCESS</phrase><phrase role="special">;</phrase>
+ <phrase role="special">}</phrase>
+ <phrase role="keyword">catch</phrase> <phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">exception</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">e</phrase><phrase role="special">)</phrase>
+ <phrase role="special">{</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cerr</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;exception: &quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">e</phrase><phrase role="special">.</phrase><phrase role="identifier">what</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase>
+ <phrase role="keyword">catch</phrase> <phrase role="special">(</phrase> <phrase role="special">...</phrase> <phrase role="special">)</phrase>
+ <phrase role="special">{</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cerr</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;unhandled&quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase>
+
+ <phrase role="keyword">return</phrase> <phrase role="identifier">EXIT_FAILURE</phrase><phrase role="special">;</phrase>
+<phrase role="special">}</phrase>
+</programlisting>
+ <para>
+ for ( int i = 0; i &lt; 32; ++i) results.push_back( pool.submit( boost::bind(
+ &amp; fibo::execute, boost::ref( fib), i) ) );
+ </para>
+
+<programlisting> <phrase role="keyword">int</phrase> <phrase role="identifier">k</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase>
+ <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">tp</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">int</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&gt;::</phrase><phrase role="identifier">iterator</phrase> <phrase role="identifier">e</phrase><phrase role="special">(</phrase> <phrase role="identifier">results</phrase><phrase role="special">.</phrase><phrase role="identifier">end</phrase><phrase role="special">()</phrase> <phrase role="special">);</phrase>
+ <phrase role="keyword">for</phrase> <phrase role="special">(</phrase>
+ <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">tp</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">int</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&gt;::</phrase><phrase role="identifier">iterator</phrase> <phrase role="identifier">i</phrase><phrase role="special">(</phrase> <phrase role="identifier">results</phrase><phrase role="special">.</phrase><phrase role="identifier">begin</phrase><phrase role="special">()</phrase> <phrase role="special">);</phrase>
+ <phrase role="identifier">i</phrase> <phrase role="special">!=</phrase> <phrase role="identifier">e</phrase><phrase role="special">;</phrase>
+ <phrase role="special">++</phrase><phrase role="identifier">i</phrase><phrase role="special">)</phrase>
+ <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;fibonacci &quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">k</phrase><phrase role="special">++</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot; == &quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">i</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">get</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase>
+
+ <phrase role="identifier">pt</phrase><phrase role="special">::</phrase><phrase role="identifier">ptime</phrase> <phrase role="identifier">stop</phrase><phrase role="special">(</phrase> <phrase role="identifier">pt</phrase><phrase role="special">::</phrase><phrase role="identifier">microsec_clock</phrase><phrase role="special">::</phrase><phrase role="identifier">universal_time</phrase><phrase role="special">()</phrase> <phrase role="special">);</phrase>
+ <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="special">(</phrase> <phrase role="identifier">stop</phrase> <phrase role="special">-</phrase> <phrase role="identifier">start</phrase><phrase role="special">).</phrase><phrase role="identifier">total_milliseconds</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot; milli seconds&quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase>
+
+ <phrase role="keyword">return</phrase> <phrase role="identifier">EXIT_SUCCESS</phrase><phrase role="special">;</phrase>
+ <phrase role="special">}</phrase>
+ <phrase role="keyword">catch</phrase> <phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">exception</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">e</phrase><phrase role="special">)</phrase>
+ <phrase role="special">{</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cerr</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;exception: &quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">e</phrase><phrase role="special">.</phrase><phrase role="identifier">what</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase>
+ <phrase role="keyword">catch</phrase> <phrase role="special">(</phrase> <phrase role="special">...</phrase> <phrase role="special">)</phrase>
+ <phrase role="special">{</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cerr</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;unhandled&quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase>
+
+ <phrase role="keyword">return</phrase> <phrase role="identifier">EXIT_FAILURE</phrase><phrase role="special">;</phrase>
+<phrase role="special">}</phrase>
+</programlisting>
+ <para>
+ int k = 0; std::vector&lt; tp::task&lt; int &gt; &gt;::iterator e( results.end()
+ ); for ( std::vector&lt; tp::task&lt; int &gt; &gt;::iterator i( results.begin()
+ ); i != e; ++i) std::cout &lt;&lt; &quot;fibonacci &quot; &lt;&lt; k++ &lt;&lt;
+ &quot; == &quot; &lt;&lt; i-&gt;get() &lt;&lt; std::endl;
+ </para>
+
+<programlisting> <phrase role="identifier">pt</phrase><phrase role="special">::</phrase><phrase role="identifier">ptime</phrase> <phrase role="identifier">stop</phrase><phrase role="special">(</phrase> <phrase role="identifier">pt</phrase><phrase role="special">::</phrase><phrase role="identifier">microsec_clock</phrase><phrase role="special">::</phrase><phrase role="identifier">universal_time</phrase><phrase role="special">()</phrase> <phrase role="special">);</phrase>
+ <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="special">(</phrase> <phrase role="identifier">stop</phrase> <phrase role="special">-</phrase> <phrase role="identifier">start</phrase><phrase role="special">).</phrase><phrase role="identifier">total_milliseconds</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot; milli seconds&quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase>
+
+ <phrase role="keyword">return</phrase> <phrase role="identifier">EXIT_SUCCESS</phrase><phrase role="special">;</phrase>
+ <phrase role="special">}</phrase>
+ <phrase role="keyword">catch</phrase> <phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">exception</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">e</phrase><phrase role="special">)</phrase>
+ <phrase role="special">{</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cerr</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;exception: &quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">e</phrase><phrase role="special">.</phrase><phrase role="identifier">what</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase>
+ <phrase role="keyword">catch</phrase> <phrase role="special">(</phrase> <phrase role="special">...</phrase> <phrase role="special">)</phrase>
+ <phrase role="special">{</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cerr</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;unhandled&quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase>
+
+ <phrase role="keyword">return</phrase> <phrase role="identifier">EXIT_FAILURE</phrase><phrase role="special">;</phrase>
+<phrase role="special">}</phrase>
+</programlisting>
+ <para>
+ pt::ptime stop( pt::microsec_clock::universal_time() ); std::cout &lt;&lt;
+ ( stop - start).total_milliseconds() &lt;&lt; &quot; milli seconds&quot; &lt;&lt;
+ std::endl;
+ </para>
+
+<programlisting> <phrase role="keyword">return</phrase> <phrase role="identifier">EXIT_SUCCESS</phrase><phrase role="special">;</phrase>
+ <phrase role="special">}</phrase>
+ <phrase role="keyword">catch</phrase> <phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">exception</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">e</phrase><phrase role="special">)</phrase>
+ <phrase role="special">{</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cerr</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;exception: &quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">e</phrase><phrase role="special">.</phrase><phrase role="identifier">what</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase>
+ <phrase role="keyword">catch</phrase> <phrase role="special">(</phrase> <phrase role="special">...</phrase> <phrase role="special">)</phrase>
+ <phrase role="special">{</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cerr</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;unhandled&quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase>
+
+ <phrase role="keyword">return</phrase> <phrase role="identifier">EXIT_FAILURE</phrase><phrase role="special">;</phrase>
+<phrase role="special">}</phrase>
+</programlisting>
+ <para>
+ return EXIT_SUCCESS; } catch ( std::exception const&amp; e) { std::cerr &lt;&lt;
+ &quot;exception: &quot; &lt;&lt; e.what() &lt;&lt; std::endl; } catch ( ...
+ ) { std::cerr &lt;&lt; &quot;unhandled&quot; &lt;&lt; std::endl; }
+ </para>
+
+<programlisting> <phrase role="keyword">return</phrase> <phrase role="identifier">EXIT_FAILURE</phrase><phrase role="special">;</phrase>
+<phrase role="special">}</phrase>
+</programlisting>
+ <para>
+ return EXIT_FAILURE; }
+ </para>
   </section>
   <section id="boost_threadpool.acknowledgement">
     <title><link linkend="boost_threadpool.acknowledgement"> Acknowledgements</link></title>
@@ -1986,6 +2654,42 @@
         </varlistentry>
       </variablelist>
     </section>
+ <section id="boost_threadpool.reference.reschedule_until">
+ <title><link linkend="boost_threadpool.reference.reschedule_until"> Non-member
+ function <code><phrase role="identifier">reschedule_until</phrase></code></link></title>
+
+<programlisting> <phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</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">&gt;</phrase>
+
+<phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Pool</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">R</phrase> <phrase role="special">&gt;</phrase>
+<phrase role="keyword">void</phrase> <phrase role="identifier">reschedule_until</phrase><phrase role="special">(</phrase> <phrase role="identifier">jss</phrase><phrase role="special">::</phrase><phrase role="identifier">future</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">R</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;);</phrase>
+</programlisting>
+ <variablelist>
+ <title></title> <varlistentry><term>Effects:</term>
+ <listitem>
+ <para>
+ Reschedules current task until passed future becomes ready.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ [Throws:
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Nothing.
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Note:</term>
+ <listitem>
+ <para>
+ This function resides in namespace <code><phrase role="identifier">boost</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">this_task</phrase></code>.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
     <section id="boost_threadpool.reference.get_thread_pool">
       <title><link linkend="boost_threadpool.reference.get_thread_pool"> Non-member
       function <code><phrase role="identifier">get_thread_pool</phrase></code></link></title>


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