Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r53533 - in sandbox/task/libs/task/doc: . html html/boost_task html/images html/images/accumulators html/images/callouts
From: oliver.kowalke_at_[hidden]
Date: 2009-06-01 08:13:07


Author: olli
Date: 2009-06-01 08:13:01 EDT (Mon, 01 Jun 2009)
New Revision: 53533
URL: http://svn.boost.org/trac/boost/changeset/53533

Log:
* documentation

Added:
   sandbox/task/libs/task/doc/boost.png (contents, props changed)
   sandbox/task/libs/task/doc/boost_task.xml (contents, props changed)
   sandbox/task/libs/task/doc/fork_join.qbk (contents, props changed)
   sandbox/task/libs/task/doc/html/
   sandbox/task/libs/task/doc/html/boost_task/
   sandbox/task/libs/task/doc/html/boost_task/appendices.html (contents, props changed)
   sandbox/task/libs/task/doc/html/boost_task/as_sub_task.html (contents, props changed)
   sandbox/task/libs/task/doc/html/boost_task/async_completion_token.html (contents, props changed)
   sandbox/task/libs/task/doc/html/boost_task/async_executor.html (contents, props changed)
   sandbox/task/libs/task/doc/html/boost_task/callable.html (contents, props changed)
   sandbox/task/libs/task/doc/html/boost_task/description.html (contents, props changed)
   sandbox/task/libs/task/doc/html/boost_task/handle.html (contents, props changed)
   sandbox/task/libs/task/doc/html/boost_task/meta_functions.html (contents, props changed)
   sandbox/task/libs/task/doc/html/boost_task/motivation.html (contents, props changed)
   sandbox/task/libs/task/doc/html/boost_task/new_thread.html (contents, props changed)
   sandbox/task/libs/task/doc/html/boost_task/own_thread.html (contents, props changed)
   sandbox/task/libs/task/doc/html/boost_task/pool.html (contents, props changed)
   sandbox/task/libs/task/doc/html/boost_task/reference.html (contents, props changed)
   sandbox/task/libs/task/doc/html/boost_task/task.html (contents, props changed)
   sandbox/task/libs/task/doc/html/boost_task/utilities.html (contents, props changed)
   sandbox/task/libs/task/doc/html/boostbook.css (contents, props changed)
   sandbox/task/libs/task/doc/html/docutils.css (contents, props changed)
   sandbox/task/libs/task/doc/html/images/
   sandbox/task/libs/task/doc/html/images/accumulators/
   sandbox/task/libs/task/doc/html/images/accumulators/doxygen.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_0.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_1.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_10.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_100.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_11.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_12.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_13.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_14.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_15.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_16.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_17.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_18.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_19.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_2.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_20.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_21.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_22.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_23.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_24.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_25.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_26.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_27.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_28.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_29.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_3.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_30.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_31.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_32.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_33.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_34.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_35.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_36.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_37.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_38.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_39.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_4.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_40.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_41.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_42.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_43.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_44.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_45.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_46.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_47.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_48.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_49.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_5.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_50.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_51.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_52.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_53.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_54.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_55.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_56.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_57.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_58.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_59.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_6.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_60.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_61.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_62.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_63.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_64.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_65.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_66.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_67.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_68.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_69.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_7.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_70.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_71.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_72.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_73.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_74.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_75.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_76.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_77.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_78.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_79.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_8.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_80.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_81.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_82.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_83.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_84.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_85.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_86.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_87.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_88.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_89.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_9.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_90.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_91.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_92.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_93.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_94.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_95.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_96.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_97.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_98.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/accumulators/form_99.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/alert.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/blank.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/callouts/
   sandbox/task/libs/task/doc/html/images/callouts/1.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/callouts/10.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/callouts/11.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/callouts/12.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/callouts/13.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/callouts/14.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/callouts/15.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/callouts/2.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/callouts/3.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/callouts/4.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/callouts/5.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/callouts/6.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/callouts/7.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/callouts/8.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/callouts/9.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/caution.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/draft.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/home.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/important.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/next.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/next_disabled.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/note.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/prev.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/prev_disabled.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/smiley.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/tip.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/toc-blank.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/toc-minus.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/toc-plus.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/up.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/up_disabled.png (contents, props changed)
   sandbox/task/libs/task/doc/html/images/warning.png (contents, props changed)
   sandbox/task/libs/task/doc/html/index.html (contents, props changed)
   sandbox/task/libs/task/doc/html/minimal.css (contents, props changed)
   sandbox/task/libs/task/doc/html/reference.css (contents, props changed)
Removed:
   sandbox/task/libs/task/doc/description.qbk
   sandbox/task/libs/task/doc/forkjoin.qbk
Text files modified:
   sandbox/task/libs/task/doc/Jamfile.v2 | 4 +-
   sandbox/task/libs/task/doc/appendices.qbk | 4 +-
   sandbox/task/libs/task/doc/as_sub_task.qbk | 2
   sandbox/task/libs/task/doc/boost_task.qbk | 44 ++++++++++++++++++++++---------------
   sandbox/task/libs/task/doc/channel.qbk | 9 ++++---
   sandbox/task/libs/task/doc/default_pool.qbk | 5 ++-
   sandbox/task/libs/task/doc/handle.qbk | 8 +++++-
   sandbox/task/libs/task/doc/introduction.qbk | 39 +++++++++++++++++---------------
   sandbox/task/libs/task/doc/meta_functions.qbk | 3 +
   sandbox/task/libs/task/doc/new_thread.qbk | 31 ++++++++++++++-----------
   sandbox/task/libs/task/doc/overview.qbk | 26 +++++++++++----------
   sandbox/task/libs/task/doc/own_thread.qbk | 2
   sandbox/task/libs/task/doc/pool.qbk | 10 +++++---
   sandbox/task/libs/task/doc/processor_binding.qbk | 2
   sandbox/task/libs/task/doc/ref_async.qbk | 2
   sandbox/task/libs/task/doc/ref_task.qbk | 2
   sandbox/task/libs/task/doc/scheduler.qbk | 22 ++++++-----------
   sandbox/task/libs/task/doc/shutdown.qbk | 10 ++++----
   sandbox/task/libs/task/doc/static_pool.qbk | 17 +++++++------
   sandbox/task/libs/task/doc/task.qbk | 34 +++++++++++++++-------------
   sandbox/task/libs/task/doc/todo.qbk | 36 ++++++++++++++++++-----------
   sandbox/task/libs/task/doc/utilities.qbk | 10 ++++----
   sandbox/task/libs/task/doc/work_stealing.qbk | 47 ++++++++++++++++++++-------------------
   23 files changed, 200 insertions(+), 169 deletions(-)

Modified: sandbox/task/libs/task/doc/Jamfile.v2
==============================================================================
--- sandbox/task/libs/task/doc/Jamfile.v2 (original)
+++ sandbox/task/libs/task/doc/Jamfile.v2 2009-06-01 08:13:01 EDT (Mon, 01 Jun 2009)
@@ -8,5 +8,5 @@
 
 using quickbook ;
 
-xml threadpool : threadpool.qbk ;
-boostbook standalone : threadpool ;
+xml task : boost_task.qbk ;
+boostbook standalone : task ;

Modified: sandbox/task/libs/task/doc/appendices.qbk
==============================================================================
--- sandbox/task/libs/task/doc/appendices.qbk (original)
+++ sandbox/task/libs/task/doc/appendices.qbk 2009-06-01 08:13:01 EDT (Mon, 01 Jun 2009)
@@ -8,9 +8,9 @@
 
 [section Appendices]
 
-[include rationale.qbk]
-[include acknowledgements.qbk]
+[/ [include rationale.qbk] ]
 [include todo.qbk]
+[include acknowledgements.qbk]
 
 
 [endsect]

Modified: sandbox/task/libs/task/doc/as_sub_task.qbk
==============================================================================
--- sandbox/task/libs/task/doc/as_sub_task.qbk (original)
+++ sandbox/task/libs/task/doc/as_sub_task.qbk 2009-06-01 08:13:01 EDT (Mon, 01 Jun 2009)
@@ -6,7 +6,7 @@
 ]
 
 
-[section:as_sub_task __as_sub_task__]
+[section:as_sub_task Execute as sub-task]
 
 __as_sub_task__ is a convenient way to execute a __sub_task__. If the parent task is executed inside a __thread_pool__ the __sub_task__ is put into the local-queue of the
 __worker_thread__ in the other case the __sub_task__ will be executed in a new thread.

Added: sandbox/task/libs/task/doc/boost.png
==============================================================================
Binary file. No diff available.

Modified: sandbox/task/libs/task/doc/boost_task.qbk
==============================================================================
--- sandbox/task/libs/task/doc/boost_task.qbk (original)
+++ sandbox/task/libs/task/doc/boost_task.qbk 2009-06-01 08:13:01 EDT (Mon, 01 Jun 2009)
@@ -24,16 +24,13 @@
 [def __boost_thread__ [@http://www.boost.org/libs/thread [*Boost.Thread]]]
 [def __boost_future__ [@http://www.justsoftwaresolutions.co.uk/threading/updated-implementation-of-c++-futures-3.html [*Boost.Future]]]
 
-[template link_act[link_text] [link boost_task.async_completion_token [link_text]]]
-[template link_ae[link_text] [link boost_task.async_executor [link_text]]]
-[template link_coop_task[link_text] [link boost_task.task.cooperative [link_text]]]
-[template link_channel[link_text] [link boost_task.async_executor.pool.channel [link_text]]]
-[template link_forkjoin[link_text] [link boost_task.async_executor.pool.forkjoin [link_text]]]
-[template link_handle[link_text] [link boost_task.async_completion_token.handle [link_text]]]
-[template link_own_thread[link_text] [link boost_task.async_executor.own_thread [link_text]]]
-[template link_pool[link_text] [link boost_task.async_executor.pool [link_text]]]
+[template link_channel[link_text] [link boost_task.pool.channel [link_text]]]
+[template link_forkjoin[link_text] [link boost_task.pool.forkjoin [link_text]]]
+[template link_handle[link_text] [link boost_task.handle [link_text]]]
+[template link_own_thread[link_text] [link boost_task.own_thread [link_text]]]
+[template link_pool[link_text] [link boost_task.pool [link_text]]]
 [template link_task[link_text] [link boost_task.task [link_text]]]
-[template link_work_stealing[link_text] [link boost_task.async_executor.pool.work_stealing [link_text]]]
+[template link_work_stealing[link_text] [link boost_task.pool.work_stealing [link_text]]]
 
 [def __thread__ `boost::thread`]
 [def __thread_id__ `boost::thread::id`]
@@ -79,6 +76,7 @@
 
 [def __fn_active__ `active()`]
 [def __fn_closed__ `close()`]
+[def __fn_clear__ `clear()`]
 [def __fn_empty__ `empty()`]
 [def __fn_get__ `get()`]
 [def __fn_get_id__ `get_id()`]
@@ -87,26 +85,28 @@
 [def __fn_has_exception__ `has_exception()`]
 [def __fn_idle__ `idle()`]
 [def __fn_interrupt__ `interrupt()`]
+[def __fn_interrupt_and_wait__ `interrupt_and_wait()`]
 [def __fn_interrupt_and_wait_for__ `interrupt_and_wait_for()`]
 [def __fn_interrupt_and_wait_until__ `interrupt_and_wait_until()`]
 [def __fn_interruption_requested__ `interruption_requested()`]
 [def __fn_is_ready__ `is_ready()`]
 [def __fn_operator__ `operator()()`]
 [def __fn_pending__ `pending()()`]
-[def __fn_size__ size()`]
-[def __fn_shutdown__ shutdown()`]
-[def __fn_shutdown_now__ shutdown_now()`]
+[def __fn_size__ `size()`]
+[def __fn_shutdown__ `shutdown()`]
+[def __fn_shutdown_now__ `shutdown_now()`]
 [def __fn_wait__ `wait()`]
 [def __fn_wait_for__ `wait_for()`]
 [def __fn_wait_until__ `wait_until()`]
 
-[def __act__ `asynchronous-completion-token`]
-[def __ae__ `asynchronous-executor`]
-[def __aes__ `asynchronous-executors`]
+[def __act__ ['asynchronous-completion-token]]
+[def __ae__ ['asynchronous-executor]]
+[def __aes__ ['asynchronous-executors]]
 [def __blocked__ ['blocked]]
 [def __callable__ ['callable]]
-[def __coop_task__ `cooperative task`]
-[def __duration__ `Duration`]
+[def __channel__ ['channel]]
+[def __coop_task__ ['cooperative task]]
+[def __duration__ ['Duration]]
 [def __fork_join__ ['fork/join]]
 [def __interruption_point__ ['interruption-point]]
 [def __interruption_points__ ['interruption-points]]
@@ -124,6 +124,14 @@
 
 
 [include overview.qbk]
-[include description.qbk]
+[include introduction.qbk]
+[include task.qbk]
+[include handle.qbk]
+[include own_thread.qbk]
+[include new_thread.qbk]
+[include pool.qbk]
+[include as_sub_task.qbk]
+[include utilities.qbk]
+[include meta_functions.qbk]
 [include reference.qbk]
 [include appendices.qbk]

Added: sandbox/task/libs/task/doc/boost_task.xml
==============================================================================
--- (empty file)
+++ sandbox/task/libs/task/doc/boost_task.xml 2009-06-01 08:13:01 EDT (Mon, 01 Jun 2009)
@@ -0,0 +1,4225 @@
+<?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_task" name="Boost.Task" dirname="boost_task" last-revision="$Date: 2009/06/01 12:11:53 $"
+ xmlns:xi="http://www.w3.org/2001/XInclude">
+ <libraryinfo>
+ <authorgroup>
+ <author>
+ <firstname>Oliver</firstname> <surname>Kowalke</surname>
+ </author>
+ </authorgroup>
+ <copyright>
+ <year>2009</year> <holder>Oliver Kowalke</holder>
+ </copyright>
+ <legalnotice>
+ <para>
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at <ulink url="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt>)
+ </para>
+ </legalnotice>
+ <librarypurpose>
+ C++ Library for asynchronous execution of tasks
+ </librarypurpose>
+ <librarycategory name="category:text"></librarycategory>
+ </libraryinfo>
+ <title>Boost.Task</title>
+ <section id="boost_task.overview">
+ <title><link linkend="boost_task.overview"> Overview</link></title>
+ <para>
+ <emphasis role="bold">Boost.Task</emphasis> provides an framework for parallel
+ execution of tasks (a task is a small unit of code that can be executed independently).
+ </para>
+ <itemizedlist>
+ <listitem>
+ <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase></code>, <emphasis>callable</emphasis> representing
+ a fine-grained work-item:
+ <itemizedlist>
+ <listitem>
+ <code><phrase role="identifier">get_id</phrase><phrase role="special">()</phrase></code>
+ returning an identifier
+ </listitem>
+ <listitem>
+ <code><phrase role="keyword">operator</phrase><phrase role="special">()()</phrase></code>
+ to execute the fine-grained work-item
+ </listitem>
+ <listitem>
+ <code><phrase role="identifier">get_future</phrase><phrase role="special">()</phrase></code>
+ providing an <emphasis>asynchronous-completion-token</emphasis> in order
+ to pass the result (values, exceptions) back to initiator
+ </listitem>
+ </itemizedlist>
+ </listitem>
+ <listitem>
+ <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">handle</phrase></code>, <emphasis>asynchronous-completion-token</emphasis>
+ of the asynchronously executed task:
+ <itemizedlist>
+ <listitem>
+ <code><phrase role="identifier">get_id</phrase><phrase role="special">()</phrase></code>
+ for identifying associated task
+ </listitem>
+ <listitem>
+ <code><phrase role="identifier">interrupt</phrase><phrase role="special">()</phrase></code>,
+ interrupt_and_wait() allow to cancel an cooperative task
+ </listitem>
+ <listitem>
+ interface of <emphasis>asynchronous-completion-token</emphasis>:
+ <itemizedlist>
+ <listitem>
+ <code><phrase role="identifier">get</phrase><phrase role="special">()</phrase></code>
+ retrieve value or exception of task execution
+ </listitem>
+ <listitem>
+ <code><phrase role="identifier">is_ready</phrase><phrase role="special">()</phrase></code>
+ test if task was executed
+ </listitem>
+ <listitem>
+ <code><phrase role="identifier">wait</phrase><phrase role="special">()</phrase></code>,
+ <code><phrase role="identifier">wait_for</phrase><phrase role="special">()</phrase></code>
+ and <code><phrase role="identifier">wait_until</phrase><phrase role="special">()</phrase></code>
+ block until task is executed and the result is set
+ </listitem>
+ </itemizedlist>
+ </listitem>
+ </itemizedlist>
+ </listitem>
+ <listitem>
+ <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">async</phrase><phrase role="special">()</phrase></code>,
+ executes a task on behalf of <emphasis>asynchronous-executors</emphasis>
+ </listitem>
+ <listitem>
+ <emphasis>asynchronous-executor</emphasis> models:
+ <itemizedlist>
+ <listitem>
+ <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">own_thread</phrase></code>: executes task in current
+ thread.
+ </listitem>
+ <listitem>
+ <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">new_thread</phrase></code>: executes task in a newly
+ created thread (thread will be destroyed after)
+ </listitem>
+ <listitem>
+ <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">default_pool</phrase></code>: task gets executed by
+ a <emphasis>worker-thread</emphasis> of the default <emphasis>thread-pool</emphasis>
+ </listitem>
+ <listitem>
+ <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">as_sub_task</phrase></code>: executes task in newly
+ created thread or in a pool of <emphasis>worker-threads</emphasis> depending
+ on whether current task is already executed in a pool
+ </listitem>
+ <listitem>
+ custom pool: task gets executed by a <emphasis>worker-thread</emphasis>
+ of a custom <emphasis>thread-pool</emphasis>
+ </listitem>
+ </itemizedlist>
+ </listitem>
+ </itemizedlist>
+ <para>
+ References
+ </para>
+ <itemizedlist>
+ <listitem>
+ N2185: Proposed Text for Parallel Task Execution <ulink url="
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2185.html">http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2185.html>
+ written by Peter Dimov.
+ </listitem>
+ <listitem>
+ N2276: Thread Pools and Futures <ulink url="
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2276.html">http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2276.html>
+ written by Anthony Williams.
+ </listitem>
+ <listitem>
+ N2802: A plea to reconsider detach-on-destruction for thread objects <ulink
+ url="
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2802.html">http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2802.html>
+ written by Hans-J. Boehm.
+ </listitem>
+ <listitem>
+ <ulink url="
http://herbsutter.wordpress.com">'Sutter’s Mill'</ulink> by
+ Herb Sutter
+ </listitem>
+ <listitem>
+ mailing list of C++ standard committee's Library Working Group
+ </listitem>
+ </itemizedlist>
+ <note>
+ <para>
+ <emphasis role="bold">Boost.Task</emphasis> uses <ulink url="http://www.justsoftwaresolutions.co.uk/threading/updated-implementation-of-c++-futures-3.html"><emphasis
+ role="bold">Boost.Future</emphasis></ulink> from Anthony Williams (will be
+ integrated in some of the next releases of <ulink url="http://www.boost.org/libs/thread"><emphasis
+ role="bold">Boost.Thread</emphasis></ulink>).
+ </para>
+ </note>
+ <para>
+ In order to use the classes and functions described here, you can either include
+ the specific headers specified by the descriptions of each class or function,
+ or include the master library header:
+ </para>
+
+<programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">task</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase>
+</programlisting>
+ <para>
+ which includes all the other headers in turn.
+ </para>
+ <anchor id="boost_task.overview.tested_platforms"/>
+ <bridgehead renderas="sect3">
+ <link linkend="boost_task.overview.tested_platforms">Tested Platforms</link>
+ </bridgehead>
+ <para>
+ <emphasis role="bold">Boost.Task</emphasis> has been tested on the following
+ platforms and compilers:
+ </para>
+ <itemizedlist>
+ <listitem>
+ Debian GNU/Linux 2.6.29.2 (x86_64), GCC 4.3.3
+ </listitem>
+ <listitem>
+ Ubuntu GNU/Linux 2.6.28.11 (x86), GCC 4.3.3
+ </listitem>
+ <listitem>
+ FreeBSD 7.2 (x86), GCC 4.2.1
+ </listitem>
+ <listitem>
+ OpenSolaris 0811 (x86_64), SunCC 5.10
+ </listitem>
+ <listitem>
+ Windows XP Professional (x86), MSVC 9.0
+ </listitem>
+ </itemizedlist>
+ <anchor id="boost_task.overview.how_to_build"/>
+ <bridgehead renderas="sect3">
+ <link linkend="boost_task.overview.how_to_build">How to build</link>
+ </bridgehead>
+ <itemizedlist>
+ <listitem>
+ download the sources form <ulink url="http://www.boostpro.com/vault/index.php">boost-vault</ulink>
+ (section <emphasis>Concurrent Programing</emphasis>) or <ulink url="https://svn.boost.org/svn/boost/sandbox/task/">boost-sandbox</ulink>
+ </listitem>
+ <listitem>
+ extract the archive into the boost-source directory
+ </listitem>
+ <listitem>
+ change directory to &lt;boost-source&gt;/libs/task/build
+ </listitem>
+ <listitem>
+ call <code><phrase role="identifier">bjam</phrase> <phrase role="identifier">toolset</phrase><phrase
+ role="special">=&lt;</phrase><phrase role="identifier">compiler</phrase><phrase
+ role="special">-</phrase><phrase role="identifier">name</phrase><phrase role="special">&gt;</phrase></code>
+ </listitem>
+ </itemizedlist>
+ </section>
+ <section id="boost_task.motivation">
+ <title><link linkend="boost_task.motivation"> Motivation</link></title>
+ <para>
+ To speed-up computer-bound work and/or increase the computation-throughput
+ is a common motivation for parallelizing a program. Especially for interactive
+ applications that have to process user input while performing some background
+ tasks responsivness iss very important. Parallelizing a program requires partitioning
+ the program into smaller chunks that can run in parallel. The code can scale
+ as the hardware gets better without changing the code.
+ </para>
+ <para>
+ The evolution from one-core to many-core architectures and the usage of threads
+ (of course processes fit too) support this paradigm.
+ </para>
+ <note>
+ <para>
+ <quote>You can have multithreading on a single core machine, but you can
+ only have parallelism on a multi core machine ... .</quote> -- Daniel Moth
+ <footnote>
+ <para>
+ more to read at Daniel's <ulink url="http://www.danielmoth.com/Blog/2008/11/threadingconcurrency-vs-parallelism.html">blog</ulink>
+ </para>
+ </footnote>
+ </para>
+ </note>
+ <para>
+ <emphasis role="bold">Boost.Task</emphasis> provides a framework to utilize
+ the available hardware and provide a way for efficient asynchronous processing
+ of time consuming operations. The framework provides some <emphasis>asynchronous-executors</emphasis>,
+ like <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">new_thread</phrase></code>,
+ in order to execute the task asynchronously in another execution context (<emphasis
+ role="bold">Boost.Task</emphasis> uses preemptible threads for this purpose).
+ </para>
+ <para>
+
+<programlisting><phrase role="keyword">void</phrase> <phrase role="identifier">print</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">msg</phrase><phrase role="special">)</phrase>
+<phrase role="special">{</phrase> <phrase role="identifier">printf</phrase><phrase role="special">(</phrase><phrase role="string">&quot;%s\n&quot;</phrase><phrase role="special">,</phrase> <phrase role="identifier">msg</phrase><phrase role="special">.</phrase><phrase role="identifier">c_str</phrase><phrase role="special">()</phrase> <phrase role="special">);</phrase> <phrase role="special">}</phrase>
+
+<phrase role="keyword">void</phrase> <phrase role="identifier">main</phrase><phrase role="special">()</phrase>
+<phrase role="special">{</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">async</phrase><phrase role="special">(</phrase> <phrase role="comment">// dispatchs task
+</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">new_thread</phrase><phrase role="special">(),</phrase> <phrase role="comment">// asynchronous executor
+</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">make_task</phrase><phrase role="special">(</phrase> <phrase role="comment">// task, to be executed asynchronously
+</phrase> <phrase role="identifier">print</phrase><phrase role="special">,</phrase>
+ <phrase role="string">&quot;Hello World!&quot;</phrase><phrase role="special">)</phrase> <phrase role="special">)</phrase> <phrase role="special">);</phrase>
+<phrase role="special">}</phrase>
+</programlisting>
+ </para>
+ <para>
+ In order to manage the task <code><phrase role="identifier">boost</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">async</phrase><phrase role="special">()</phrase></code> returns
+ a handle <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">handle</phrase></code>
+ (associated with the submitted task). It functions as a <emphasis>asynchronous-completion-token</emphasis>
+ - that means it transfers the result of the execution back to the caller thread.
+ </para>
+ <para>
+
+<programlisting><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="identifier">echo</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">msg</phrase><phrase role="special">)</phrase>
+<phrase role="special">{</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">msg</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase>
+
+<phrase role="keyword">void</phrase> <phrase role="identifier">main</phrase><phrase role="special">()</phrase>
+<phrase role="special">{</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">handle</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">h</phrase><phrase role="special">(</phrase> <phrase role="comment">// get handle associated with the task
+</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">async</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">new_thread</phrase><phrase role="special">(),</phrase> <phrase role="comment">// asynchronous executor
+</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">make_task</phrase><phrase role="special">(</phrase> <phrase role="comment">// task, to be executed asynchronously
+</phrase> <phrase role="identifier">echo</phrase><phrase role="special">,</phrase>
+ <phrase role="string">&quot;Hello World!&quot;</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">cout</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">h</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">// wait until task is finished and return the result
+</phrase><phrase role="special">}</phrase>
+</programlisting>
+ </para>
+ <para>
+ The task can also be interrupted via <code><phrase role="identifier">boost</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">handle</phrase></code> if it is a so-called <link linkend="boost_task.task"><emphasis>cooperative
+ task</emphasis></link>.
+ </para>
+ <para>
+
+<programlisting><phrase role="keyword">void</phrase> <phrase role="identifier">long_running</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="identifier">time_duration</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">rel_time</phrase><phrase role="special">)</phrase>
+<phrase role="special">{</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">this_thread</phrase><phrase role="special">::</phrase><phrase role="identifier">sleep</phrase><phrase role="special">(</phrase> <phrase role="identifier">rel_time</phrase><phrase role="special">);</phrase>
+
+<phrase role="keyword">void</phrase> <phrase role="identifier">main</phrase><phrase role="special">()</phrase>
+<phrase role="special">{</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">handle</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">h</phrase><phrase role="special">(</phrase> <phrase role="comment">// get handle associated with the task
+</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">async</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">new_thread</phrase><phrase role="special">(),</phrase> <phrase role="comment">// asynchronous executor
+</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">make_task</phrase><phrase role="special">(</phrase> <phrase role="comment">// long runing task, to be executed asynchronously
+</phrase> <phrase role="identifier">long_running</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="identifier">millisec</phrase><phrase role="special">(</phrase> <phrase role="number">500</phrase><phrase role="special">)</phrase> <phrase role="special">)</phrase> <phrase role="special">)</phrase> <phrase role="special">);</phrase>
+ <phrase role="identifier">h</phrase><phrase role="special">.</phrase><phrase role="identifier">interrupt</phrase><phrase role="special">();</phrase> <phrase role="comment">// interrupt execution of task
+</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">h</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">// wait until task is finished, will throw an exeception
+</phrase><phrase role="special">}</phrase>
+</programlisting>
+ </para>
+ <para>
+ Beside <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">new_thread</phrase></code>
+ (which creates a new task for each submitted task) <emphasis role="bold">Boost.Task</emphasis>
+ provides <link linkend="boost_task.pool"><emphasis>thread-pools</emphasis></link>
+ to prevent the overhead of thread creation and destruction for each task.
+ <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">default_pool</phrase></code>
+ submitts the tasks to the default <emphasis>thread-pool</emphasis> which contains
+ a fixed number of pre-spawned <emphasis>worker-threads</emphasis> (custom
+ <emphasis>thread-pools</emphasis> are supported too).
+ </para>
+ <para>
+
+<programlisting><phrase role="keyword">long</phrase> <phrase role="identifier">serial_fib</phrase><phrase role="special">(</phrase> <phrase role="keyword">long</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">2</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">serial_fib</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="identifier">serial_fib</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="keyword">long</phrase> <phrase role="identifier">parallel_fib</phrase><phrase role="special">(</phrase> <phrase role="keyword">long</phrase> <phrase role="identifier">n</phrase><phrase role="special">,</phrase> <phrase role="keyword">long</phrase> <phrase role="identifier">cutof</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">cutof</phrase><phrase role="special">)</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">serial_fib</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 sub-task calculating fibonacci(n-1)
+</phrase> <phrase role="identifier">h1</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">async</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_pool</phrase><phrase role="special">(),</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">make_task</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">parallel_fib</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="identifier">cutof</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase>
+ <phrase role="comment">// fork a sub-task calculating fibonacci(n-2)
+</phrase> <phrase role="identifier">h2</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">async</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_pool</phrase><phrase role="special">(),</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">make_task</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">parallel_fib</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="identifier">cutof</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase>
+ <phrase role="comment">// join the results of both sub-tasks
+</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">h1</phrase><phrase role="special">.</phrase><phrase role="identifier">get</phrase><phrase role="special">()</phrase> <phrase role="special">+</phrase> <phrase role="identifier">h2</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">void</phrase> <phrase role="identifier">main</phrase><phrase role="special">()</phrase>
+<phrase role="special">{</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">handle</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">long</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">h</phrase><phrase role="special">(</phrase> <phrase role="comment">// handle for fibonacci calculation
+</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">async</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">default_pool</phrase><phrase role="special">(),</phrase> <phrase role="comment">// access the default thread-pool
+</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">make_task</phrase><phrase role="special">(</phrase> <phrase role="comment">// calculate fibonacci number 10
+</phrase> <phrase role="identifier">parallel_fib</phrase><phrase role="special">,</phrase> <phrase role="comment">// for numbers &lt; 5 do inline recursive calculation
+</phrase> <phrase role="number">10</phrase><phrase role="special">,</phrase>
+ <phrase role="number">5</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">cout</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">h</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="special">}</phrase>
+</programlisting>
+ </para>
+ <para>
+ With function <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">this_task</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">runs_in_pool</phrase><phrase role="special">()</phrase></code>
+ a task can detect if it is executed inside a <emphasis>thread-pool</emphasis>.
+ <emphasis>sub-tasks</emphasis> arecreated by <code><phrase role="identifier">boost</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">as_sub_task</phrase></code>. Where the <emphasis>sub-task</emphasis>
+ is executed by a new thread if the parent task is not executed inside a <emphasis>thread-pool</emphasis>.
+ In the other case the <emphasis>sub-task</emphasis> is put into the local
+ <emphasis>worker-queue</emphasis> which enables <link linkend="boost_task.pool.work_stealing"><emphasis>work-stealing</emphasis></link>
+ and <link linkend="boost_task.pool.forkjoin">inline execution</link> of tasks.
+ </para>
+ <para>
+
+<programlisting><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">async</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">as_sub_task</phrase><phrase role="special">(),</phrase> <phrase role="comment">// sub-task executed in a new thread or inside
+</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">make_task</phrase><phrase role="special">(</phrase> <phrase role="comment">// the thread-pool depending upon the parent
+</phrase> <phrase role="identifier">parallel_fib</phrase><phrase role="special">,</phrase> <phrase role="comment">// task is executed inside a thread-pool or not
+</phrase> <phrase role="number">10</phrase><phrase role="special">,</phrase>
+ <phrase role="number">5</phrase><phrase role="special">)</phrase> <phrase role="special">)</phrase> <phrase role="special">);</phrase>
+</programlisting>
+ </para>
+ </section>
+ <section id="boost_task.task">
+ <title><link linkend="boost_task.task"> Task</link></title>
+ <para>
+ A task is a chunk of code that can be executed independently.
+ </para>
+ <para>
+ <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase></code>
+ represents a <emphasis>callable</emphasis> (provides <code><phrase role="keyword">operator</phrase><phrase
+ role="special">()()</phrase></code>) object containing the unit of code to
+ be execute by a <emphasis>asynchronous-executor</emphasis>. Function <code><phrase
+ role="identifier">get_future</phrase><phrase role="special">()</phrase></code>
+ returns a <emphasis>asynchronous-completion-token</emphasis> allowing to wait
+ for the completion of the computation of the task, for getting the result of
+ a computation or for transfering exceptions. Each <code><phrase role="identifier">boost</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase></code> has a unique identifier.
+ </para>
+ <anchor id="boost_task.task.creation"/>
+ <bridgehead renderas="sect3">
+ <link linkend="boost_task.task.creation">Creation</link>
+ </bridgehead>
+ <para>
+ <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">make_task</phrase><phrase
+ role="special">()</phrase></code> can be used to create <code><phrase role="identifier">boost</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase></code> by passing free-functions or member-functions
+ of objects and its arguments: <code><phrase role="identifier">boost</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">make_task</phrase><phrase role="special">()</phrase></code>
+ accepts up to ten arguments per default (can be overriden by defining BOOST_TASK_MAKE_TASK_MAX_ARITY
+ with the new value).
+ </para>
+ <itemizedlist>
+ <listitem>
+ create task from free-function with arguments:
+ </listitem>
+ </itemizedlist>
+ <para>
+
+<programlisting><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</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">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">make_task</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">parallel_fib</phrase><phrase role="special">,</phrase>
+ <phrase role="number">10</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase>
+</programlisting>
+ </para>
+ <itemizedlist>
+ <listitem>
+ create task from member-function with arguments:
+ </listitem>
+ </itemizedlist>
+ <para>
+
+<programlisting><phrase role="keyword">struct</phrase> <phrase role="identifier">X</phrase>
+<phrase role="special">{</phrase>
+ <phrase role="keyword">void</phrase> <phrase role="identifier">f</phrase><phrase role="special">(</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">i</phrase><phrase role="special">);</phrase>
+<phrase role="special">};</phrase>
+
+<phrase role="identifier">X</phrase> <phrase role="identifier">x</phrase><phrase role="special">;</phrase>
+<phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</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">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">make_task</phrase><phrase role="special">(</phrase>
+ <phrase role="special">&amp;</phrase> <phrase role="identifier">X</phrase><phrase role="special">::</phrase><phrase role="identifier">f</phrase><phrase role="special">,</phrase>
+ <phrase role="identifier">x</phrase><phrase role="special">,</phrase>
+ <phrase role="number">10</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase>
+</programlisting>
+ </para>
+ <para>
+ It is possible to create <code><phrase role="identifier">boost</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase></code> from a <emphasis>callable</emphasis>
+ too:
+ </para>
+ <para>
+
+<programlisting><phrase role="keyword">struct</phrase> <phrase role="identifier">Y</phrase>
+<phrase role="special">{</phrase>
+ <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="keyword">operator</phrase><phrase role="special">()();</phrase>
+<phrase role="special">};</phrase>
+
+<phrase role="identifier">Y</phrase> <phrase role="identifier">y</phrase><phrase role="special">;</phrase>
+<phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">t</phrase><phrase role="special">(</phrase> <phrase role="identifier">y</phrase><phrase role="special">);</phrase>
+</programlisting>
+ </para>
+ <anchor id="boost_task.task.cooperative_task_and_interruption"/>
+ <bridgehead renderas="sect3">
+ <link linkend="boost_task.task.cooperative_task_and_interruption">Cooperative
+ task and interruption</link>
+ </bridgehead>
+ <para>
+ Sometimes it is desired to stop a running task if it is no longer needed. In
+ this case the thread is not killed - it stops only at well-defined points (<emphasis>interruption-points</emphasis>)
+ its execution. In the context of task-interruption a task is known as cooperative
+ if it checks for an interruption request between two <emphasis>interruption-points</emphasis>
+ via <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">this_thread</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">interruption_requested</phrase><phrase role="special">()</phrase></code>
+ <footnote>
+ <para>
+ see <ulink url="http://www.ddj.com/architect/207100682">'Interrupt Politely'</ulink>,
+ Herb Sutter
+ </para>
+ </footnote>
+ .
+ </para>
+ <para>
+ <emphasis>interruption-points</emphasis> are:
+ </para>
+ <itemizedlist>
+ <listitem>
+ <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">thread</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">join</phrase><phrase role="special">()</phrase></code>
+ </listitem>
+ <listitem>
+ <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">thread</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">timed_join</phrase><phrase role="special">()</phrase></code>
+ </listitem>
+ <listitem>
+ <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">condition_variable</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">wait</phrase><phrase role="special">()</phrase></code>
+ </listitem>
+ <listitem>
+ <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">condition_variable</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">timed_wait</phrase><phrase role="special">()</phrase></code>
+ </listitem>
+ <listitem>
+ <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">condition_variable_any</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">wait</phrase><phrase role="special">()</phrase></code>
+ </listitem>
+ <listitem>
+ <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">condition_variable_any</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">timed_wait</phrase><phrase role="special">()</phrase></code>
+ </listitem>
+ <listitem>
+ <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">thread</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">sleep</phrase><phrase role="special">()</phrase></code>
+ </listitem>
+ <listitem>
+ <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">this_thread</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">sleep</phrase><phrase role="special">()</phrase></code>
+ </listitem>
+ <listitem>
+ <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">this_thread</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">interruption_point</phrase><phrase role="special">()</phrase></code>
+ </listitem>
+ </itemizedlist>
+ <para>
+ A <emphasis>interruption-point</emphasis> throws <code><phrase role="identifier">boost</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task_interrupted</phrase></code> if an interruption was requested.
+ </para>
+ <para>
+
+<programlisting><phrase role="keyword">long</phrase> <phrase role="identifier">cooperative</phrase><phrase role="special">(</phrase> <phrase role="keyword">long</phrase> <phrase role="identifier">n</phrase><phrase role="special">)</phrase>
+<phrase role="special">{</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">this_thread</phrase><phrase role="special">::</phrase><phrase role="identifier">interruption_point</phrase><phrase role="special">();</phrase> <phrase role="comment">// interruption point
+</phrase>
+ <phrase role="keyword">if</phrase> <phrase role="special">(</phrase> <phrase role="identifier">n</phrase> <phrase role="special">==</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="keyword">return</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase>
+ <phrase role="keyword">if</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="keyword">return</phrase> <phrase role="number">1</phrase><phrase role="special">;</phrase>
+ <phrase role="keyword">long</phrase> <phrase role="identifier">k1</phrase><phrase role="special">(</phrase> <phrase role="number">1</phrase><phrase role="special">),</phrase> <phrase role="identifier">k2</phrase><phrase role="special">(</phrase> <phrase role="number">0</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">2</phrase><phrase role="special">);</phrase> <phrase role="identifier">i</phrase> <phrase role="special">&lt;=</phrase> <phrase role="identifier">n</phrase><phrase role="special">;</phrase> <phrase role="special">++</phrase><phrase role="identifier">i</phrase><phrase role="special">)</phrase>
+ <phrase role="special">{</phrase>
+ <phrase role="keyword">if</phrase> <phrase role="special">(</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">this_thread</phrase><phrase role="special">::</phrase><phrase role="identifier">interruption_requested</phrase><phrase role="special">()</phrase> <phrase role="special">)</phrase> <phrase role="comment">// check if interruption was requested
+</phrase> <phrase role="keyword">return</phrase><phrase role="special">;</phrase>
+
+ <phrase role="keyword">long</phrase> <phrase role="identifier">tmp</phrase><phrase role="special">(</phrase> <phrase role="identifier">k1</phrase><phrase role="special">);</phrase>
+ <phrase role="identifier">k1</phrase> <phrase role="special">=</phrase> <phrase role="identifier">k1</phrase> <phrase role="special">+</phrase> <phrase role="identifier">k2</phrase><phrase role="special">;</phrase>
+ <phrase role="identifier">k2</phrase> <phrase role="special">=</phrase> <phrase role="identifier">tmp</phrase><phrase role="special">;</phrase>
+ <phrase role="special">}</phrase>
+
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">this_thread</phrase><phrase role="special">::</phrase><phrase role="identifier">interruption_point</phrase><phrase role="special">();</phrase> <phrase role="comment">// interruption point
+</phrase>
+ <phrase role="keyword">return</phrase> <phrase role="identifier">k1</phrase><phrase role="special">;</phrase>
+<phrase role="special">}</phrase>
+
+<phrase role="keyword">void</phrase> <phrase role="identifier">main</phrase><phrase role="special">()</phrase>
+<phrase role="special">{</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">handle</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">long</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">h</phrase><phrase role="special">(</phrase> <phrase role="comment">// get handle associated with the task
+</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">async</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">new_thread</phrase><phrase role="special">(),</phrase> <phrase role="comment">// asynchronous executor
+</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">make_task</phrase><phrase role="special">(</phrase> <phrase role="comment">// task, to be executed asynchronously
+</phrase> <phrase role="identifier">cooperative</phrase><phrase role="special">,</phrase>
+ <phrase role="number">10</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">cout</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">h</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">// throws boost::task::task_interrupted
+</phrase><phrase role="special">}</phrase>
+</programlisting>
+ </para>
+ <anchor id="boost_task.task.exceptions"/>
+ <bridgehead renderas="sect3">
+ <link linkend="boost_task.task.exceptions">Exceptions</link>
+ </bridgehead>
+ <para>
+ Exceptions thrown by <code><phrase role="identifier">boost</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase></code> are transported by the <emphasis>asynchronous-completion-token</emphasis>.
+ </para>
+ <para>
+
+<programlisting><phrase role="keyword">void</phrase> <phrase role="identifier">throwing</phrase><phrase role="special">()</phrase>
+<phrase role="special">{</phrase>
+ <phrase role="special">...</phrase>
+ <phrase role="keyword">throw</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">domain_error</phrase><phrase role="special">(</phrase><phrase role="string">&quot;domain error&quot;</phrase><phrase role="special">);</phrase>
+ <phrase role="special">...</phrase>
+<phrase role="special">}</phrase>
+
+<phrase role="keyword">void</phrase> <phrase role="identifier">main</phrase><phrase role="special">()</phrase>
+<phrase role="special">{</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">handle</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">void</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">h</phrase><phrase role="special">(</phrase> <phrase role="comment">// get handle associated with the task
+</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">async</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">new_thread</phrase><phrase role="special">(),</phrase> <phrase role="comment">// asynchronous executor
+</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">make_task</phrase><phrase role="special">(</phrase> <phrase role="comment">// task, to be executed asynchronously
+</phrase> <phrase role="identifier">throwing</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">cout</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">h</phrase><phrase role="special">.</phrase><phrase role="identifier">wait</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">// throws std::domain_error
+</phrase><phrase role="special">}</phrase>
+</programlisting>
+ </para>
+ <para>
+ Exceptions rethrown by type are:
+ </para>
+ <itemizedlist>
+ <listitem>
+ <code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">bad_alloc</phrase></code>
+ </listitem>
+ <listitem>
+ <code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">bad_cast</phrase></code>
+ </listitem>
+ <listitem>
+ <code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">bad_exception</phrase></code>
+ </listitem>
+ <listitem>
+ <code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">bad_typeid</phrase></code>
+ </listitem>
+ <listitem>
+ <code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">domain_error</phrase></code>
+ </listitem>
+ <listitem>
+ <code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">invalid_argument</phrase></code>
+ </listitem>
+ <listitem>
+ <code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">ios_base</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">failure</phrase></code>
+ </listitem>
+ <listitem>
+ <code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">length_error</phrase></code>
+ </listitem>
+ <listitem>
+ <code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">logic_error</phrase></code>
+ </listitem>
+ <listitem>
+ <code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">out_of_range</phrase></code>
+ </listitem>
+ <listitem>
+ <code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">overflow_error</phrase></code>
+ </listitem>
+ <listitem>
+ <code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">range_error</phrase></code>
+ </listitem>
+ <listitem>
+ <code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">runtime_error</phrase></code>
+ </listitem>
+ <listitem>
+ <code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">underflow_error</phrase></code>
+ </listitem>
+ <listitem>
+ <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">future_already_set</phrase></code>
+ </listitem>
+ <listitem>
+ <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">future_cancel</phrase></code>
+ </listitem>
+ <listitem>
+ <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">exception</phrase></code>
+ </listitem>
+ <listitem>
+ <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">invalid_thread_argument</phrase></code>
+ </listitem>
+ <listitem>
+ <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">lock_error</phrase></code>
+ </listitem>
+ <listitem>
+ <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task_interrupted</phrase></code>
+ </listitem>
+ <listitem>
+ <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">broken_task</phrase></code>
+ </listitem>
+ </itemizedlist>
+ <anchor id="boost_task.task.parent_task"/>
+ <bridgehead renderas="sect3">
+ <link linkend="boost_task.task.parent_task">Parent task</link>
+ </bridgehead>
+ <para>
+ Top-level tasks have no parent. A parent task can create child tasks when it
+ creates another task by using <code><phrase role="identifier">boost</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">as_sub_task</phrase></code> as <emphasis>asynchronous-executor</emphasis>.
+ These children are implicitly treated as <emphasis>sub-tasks</emphasis> of
+ the larger task. It is assumed that that <emphasis>sub-tasks</emphasis> can
+ be executed in any order because only overall operation speed matters (enabling
+ strategies for fast execution of unordered <emphasis>work-items</emphasis>
+ as <link linkend="boost_task.pool.work_stealing"><emphasis>work-stealing</emphasis></link>).
+ </para>
+ <para>
+
+<programlisting><phrase role="keyword">long</phrase> <phrase role="identifier">serial_fib</phrase><phrase role="special">(</phrase> <phrase role="keyword">long</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">2</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">serial_fib</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="identifier">serial_fib</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="keyword">long</phrase> <phrase role="identifier">parallel_fib</phrase><phrase role="special">(</phrase> <phrase role="keyword">long</phrase> <phrase role="identifier">n</phrase><phrase role="special">,</phrase> <phrase role="keyword">long</phrase> <phrase role="identifier">cutof</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">cutof</phrase><phrase role="special">)</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">serial_fib</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">// submit a sub-task to pool calculating fibonacci(n-1)
+</phrase> <phrase role="identifier">h1</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">async</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">as_sub_task</phrase><phrase role="special">(),</phrase> <phrase role="comment">// execute a sub-task
+</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">make_task</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">parallel_fib</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="identifier">cutof</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase>
+ <phrase role="comment">// submit a sub-task to pool calculating fibonacci(n-2)
+</phrase> <phrase role="identifier">h2</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">async</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">as_sub_task</phrase><phrase role="special">(),</phrase> <phrase role="comment">// execute a sub-task
+</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">make_task</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">parallel_fib</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="identifier">cutof</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase>
+ <phrase role="comment">// calculate fibonacci(n) from the results of both sub-tasks
+</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">h1</phrase><phrase role="special">.</phrase><phrase role="identifier">get</phrase><phrase role="special">()</phrase> <phrase role="special">+</phrase> <phrase role="identifier">h2</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">void</phrase> <phrase role="identifier">main</phrase><phrase role="special">()</phrase>
+<phrase role="special">{</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">handle</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">long</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">h</phrase><phrase role="special">(</phrase> <phrase role="comment">// handle for fibonacci calculation
+</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">async</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">default_pool</phrase><phrase role="special">(),</phrase> <phrase role="comment">// access the default thread-pool
+</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">make_task</phrase><phrase role="special">(</phrase> <phrase role="comment">// calculate fibonacci number 10
+</phrase> <phrase role="identifier">parallel_fib</phrase><phrase role="special">,</phrase> <phrase role="comment">// for numbers &lt; 5 do inline recursive calculation
+</phrase> <phrase role="number">10</phrase><phrase role="special">,</phrase>
+ <phrase role="number">5</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">cout</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">h</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="special">}</phrase>
+</programlisting>
+ </para>
+ </section>
+ <section id="boost_task.handle">
+ <title><link linkend="boost_task.handle"> Handle</link></title>
+ <para>
+ The <emphasis>asynchronous-completion-token</emphasis> dispatches tasks in
+ response to the completion of asynchronous operations. <emphasis>asynchronous-completion-token</emphasis>
+ uniquely identifies the task and state necessary to process the result of the
+ operation
+ <footnote>
+ <para>
+ see <ulink url="http://www.cs.wustl.edu/~schmidt/PDF/ACT.pdf">'Asynchronous
+ Completion Token'</ulink>, Douglas Schmidt
+ </para>
+ </footnote>
+ .
+ </para>
+ <para>
+ <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">handle</phrase></code>
+ represents an <emphasis>asynchronous-completion-token</emphasis>. It will be
+ returned by <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">async</phrase><phrase
+ role="special">()</phrase></code> and is associated with the submitted <code><phrase
+ role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">task</phrase></code>.
+ </para>
+ <anchor id="boost_task.handle.asynchronous_completion_token_interface"/>
+ <bridgehead renderas="sect3">
+ <link linkend="boost_task.handle.asynchronous_completion_token_interface">Asynchronous
+ completion token interface</link>
+ </bridgehead>
+ <para>
+ <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">handle</phrase></code>
+ implements an interface in order to check the state of computation and result
+ transfer
+ </para>
+ <itemizedlist>
+ <listitem>
+ <code><phrase role="identifier">get_id</phrase><phrase role="special">()</phrase></code>:
+ return id of the associated task-id
+ </listitem>
+ <listitem>
+ <code><phrase role="identifier">is_ready</phrase><phrase role="special">()</phrase></code>:
+ test if result is set
+ </listitem>
+ <listitem>
+ <code><phrase role="identifier">has_value</phrase><phrase role="special">()</phrase></code>:
+ test if value-result is set
+ </listitem>
+ <listitem>
+ <code><phrase role="identifier">has_exception</phrase><phrase role="special">()</phrase></code>:
+ test if exception-result is set
+ </listitem>
+ <listitem>
+ <code><phrase role="identifier">get</phrase><phrase role="special">()</phrase></code>:
+ return value-result
+ </listitem>
+ <listitem>
+ <code><phrase role="identifier">wait</phrase><phrase role="special">()</phrase></code>:
+ wait until result is set
+ </listitem>
+ <listitem>
+ <code><phrase role="identifier">wait_for</phrase><phrase role="special">()</phrase></code>:
+ wait until result is set or time-duration has elapsed
+ </listitem>
+ <listitem>
+ <code><phrase role="identifier">wait_until</phrase><phrase role="special">()</phrase></code>:
+ wait until result ist set or time-point has elapsed
+ </listitem>
+ </itemizedlist>
+ <para>
+
+<programlisting><phrase role="keyword">long</phrase> <phrase role="identifier">fibonacci</phrase><phrase role="special">(</phrase> <phrase role="keyword">long</phrase> <phrase role="identifier">n</phrase><phrase role="special">)</phrase>
+<phrase role="special">{</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">this_thread</phrase><phrase role="special">::</phrase><phrase role="identifier">interruption_point</phrase><phrase role="special">();</phrase> <phrase role="comment">// interruption point
+</phrase>
+ <phrase role="keyword">if</phrase> <phrase role="special">(</phrase> <phrase role="identifier">n</phrase> <phrase role="special">==</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="keyword">return</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase>
+ <phrase role="keyword">if</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="keyword">return</phrase> <phrase role="number">1</phrase><phrase role="special">;</phrase>
+ <phrase role="keyword">long</phrase> <phrase role="identifier">k1</phrase><phrase role="special">(</phrase> <phrase role="number">1</phrase><phrase role="special">),</phrase> <phrase role="identifier">k2</phrase><phrase role="special">(</phrase> <phrase role="number">0</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">2</phrase><phrase role="special">);</phrase> <phrase role="identifier">i</phrase> <phrase role="special">&lt;=</phrase> <phrase role="identifier">n</phrase><phrase role="special">;</phrase> <phrase role="special">++</phrase><phrase role="identifier">i</phrase><phrase role="special">)</phrase>
+ <phrase role="special">{</phrase>
+ <phrase role="keyword">if</phrase> <phrase role="special">(</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">this_thread</phrase><phrase role="special">::</phrase><phrase role="identifier">interruption_requested</phrase><phrase role="special">()</phrase> <phrase role="special">)</phrase> <phrase role="comment">// check if interruption was requested
+</phrase> <phrase role="keyword">return</phrase><phrase role="special">;</phrase>
+
+ <phrase role="keyword">long</phrase> <phrase role="identifier">tmp</phrase><phrase role="special">(</phrase> <phrase role="identifier">k1</phrase><phrase role="special">);</phrase>
+ <phrase role="identifier">k1</phrase> <phrase role="special">=</phrase> <phrase role="identifier">k1</phrase> <phrase role="special">+</phrase> <phrase role="identifier">k2</phrase><phrase role="special">;</phrase>
+ <phrase role="identifier">k2</phrase> <phrase role="special">=</phrase> <phrase role="identifier">tmp</phrase><phrase role="special">;</phrase>
+ <phrase role="special">}</phrase>
+
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">this_thread</phrase><phrase role="special">::</phrase><phrase role="identifier">interruption_point</phrase><phrase role="special">();</phrase> <phrase role="comment">// interruption point
+</phrase>
+ <phrase role="keyword">return</phrase> <phrase role="identifier">k1</phrase><phrase role="special">;</phrase>
+<phrase role="special">}</phrase>
+
+<phrase role="keyword">void</phrase> <phrase role="identifier">main</phrase><phrase role="special">()</phrase>
+<phrase role="special">{</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">handle</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">long</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">h</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">async</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">new_thread</phrase><phrase role="special">(),</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">make_task</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">fibonacci</phrase><phrase role="special">,</phrase>
+ <phrase role="number">10</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">cout</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;id == &quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">h</phrase><phrase role="special">.</phrase><phrase role="identifier">get_id</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;\n&quot;</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;is ready == &quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">boolalpha</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">h</phrase><phrase role="special">.</phrase><phrase role="identifier">is_ready</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;\n&quot;</phrase><phrase role="special">;</phrase>
+ <phrase role="identifier">h</phrase><phrase role="special">.</phrase><phrase role="identifier">wait</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;has value == &quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">boolalpha</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">h</phrase><phrase role="special">.</phrase><phrase role="identifier">has_value</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;\n&quot;</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;has exception == &quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">boolalpha</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">h</phrase><phrase role="special">.</phrase><phrase role="identifier">has_exception</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;\n&quot;</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(10) == &quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">h</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="special">}</phrase>
+</programlisting>
+ </para>
+ <anchor id="boost_task.handle.task_interruption"/>
+ <bridgehead renderas="sect3">
+ <link linkend="boost_task.handle.task_interruption">Task interruption</link>
+ </bridgehead>
+ <itemizedlist>
+ <listitem>
+ <code><phrase role="identifier">interrupt</phrase><phrase role="special">()</phrase></code>:
+ interrupt <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase></code> and return immediately
+ </listitem>
+ <listitem>
+ <code><phrase role="identifier">interrupt_and_wait</phrase><phrase role="special">()</phrase></code>:
+ interrupt and wait until <code><phrase role="identifier">boost</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">task</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">task</phrase></code>
+ was removed from <emphasis>worker-thread</emphasis>
+ </listitem>
+ <listitem>
+ <code><phrase role="identifier">interrupt_and_wait_for</phrase><phrase role="special">()</phrase></code>:
+ interrupt and wait until <code><phrase role="identifier">boost</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">task</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">task</phrase></code>
+ was removed from <emphasis>worker-thread</emphasis> or time duration has
+ elapsed
+ </listitem>
+ <listitem>
+ <code><phrase role="identifier">interrupt_and_wait_until</phrase><phrase
+ role="special">()</phrase></code>: interrupt and wait until <code><phrase
+ role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase></code> was removed from <emphasis>worker-thread</emphasis>
+ or time point has elapsed
+ </listitem>
+ <listitem>
+ <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">this_thread</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">interruption_requested</phrase><phrase role="special">()</phrase></code>:
+ return bool if interruption was requested
+ </listitem>
+ </itemizedlist>
+ <para>
+
+<programlisting><phrase role="keyword">long</phrase> <phrase role="identifier">cooperative</phrase><phrase role="special">(</phrase> <phrase role="keyword">long</phrase> <phrase role="identifier">n</phrase><phrase role="special">)</phrase>
+<phrase role="special">{</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">this_thread</phrase><phrase role="special">::</phrase><phrase role="identifier">interruption_point</phrase><phrase role="special">();</phrase> <phrase role="comment">// interruption point
+</phrase>
+ <phrase role="keyword">if</phrase> <phrase role="special">(</phrase> <phrase role="identifier">n</phrase> <phrase role="special">==</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="keyword">return</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase>
+ <phrase role="keyword">if</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="keyword">return</phrase> <phrase role="number">1</phrase><phrase role="special">;</phrase>
+ <phrase role="keyword">long</phrase> <phrase role="identifier">k1</phrase><phrase role="special">(</phrase> <phrase role="number">1</phrase><phrase role="special">),</phrase> <phrase role="identifier">k2</phrase><phrase role="special">(</phrase> <phrase role="number">0</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">2</phrase><phrase role="special">);</phrase> <phrase role="identifier">i</phrase> <phrase role="special">&lt;=</phrase> <phrase role="identifier">n</phrase><phrase role="special">;</phrase> <phrase role="special">++</phrase><phrase role="identifier">i</phrase><phrase role="special">)</phrase>
+ <phrase role="special">{</phrase>
+ <phrase role="keyword">if</phrase> <phrase role="special">(</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">this_thread</phrase><phrase role="special">::</phrase><phrase role="identifier">interruption_requested</phrase><phrase role="special">()</phrase> <phrase role="special">)</phrase> <phrase role="comment">// check if interruption was requested
+</phrase> <phrase role="keyword">return</phrase><phrase role="special">;</phrase>
+
+ <phrase role="keyword">long</phrase> <phrase role="identifier">tmp</phrase><phrase role="special">(</phrase> <phrase role="identifier">k1</phrase><phrase role="special">);</phrase>
+ <phrase role="identifier">k1</phrase> <phrase role="special">=</phrase> <phrase role="identifier">k1</phrase> <phrase role="special">+</phrase> <phrase role="identifier">k2</phrase><phrase role="special">;</phrase>
+ <phrase role="identifier">k2</phrase> <phrase role="special">=</phrase> <phrase role="identifier">tmp</phrase><phrase role="special">;</phrase>
+ <phrase role="special">}</phrase>
+
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">this_thread</phrase><phrase role="special">::</phrase><phrase role="identifier">interruption_point</phrase><phrase role="special">();</phrase> <phrase role="comment">// interruption point
+</phrase>
+ <phrase role="keyword">return</phrase> <phrase role="identifier">k1</phrase><phrase role="special">;</phrase>
+<phrase role="special">}</phrase>
+
+<phrase role="keyword">void</phrase> <phrase role="identifier">main</phrase><phrase role="special">()</phrase>
+<phrase role="special">{</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">handle</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">long</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">h</phrase><phrase role="special">(</phrase> <phrase role="comment">// get handle associated with the task
+</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">async</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">new_thread</phrase><phrase role="special">(),</phrase> <phrase role="comment">// asynchronous executor
+</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">make_task</phrase><phrase role="special">(</phrase> <phrase role="comment">// task, to be executed asynchronously
+</phrase> <phrase role="identifier">cooperative</phrase><phrase role="special">,</phrase>
+ <phrase role="number">10</phrase><phrase role="special">)</phrase> <phrase role="special">)</phrase> <phrase role="special">);</phrase>
+ <phrase role="identifier">h</phrase><phrase role="special">.</phrase><phrase role="identifier">interrupt_and_wait</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;id == &quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">h</phrase><phrase role="special">.</phrase><phrase role="identifier">get_id</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;\n&quot;</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;is ready == &quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">boolalpha</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">h</phrase><phrase role="special">.</phrase><phrase role="identifier">is_ready</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;\n&quot;</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;has value == &quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">boolalpha</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">h</phrase><phrase role="special">.</phrase><phrase role="identifier">has_value</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;\n&quot;</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;has exception == &quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">boolalpha</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">h</phrase><phrase role="special">.</phrase><phrase role="identifier">has_exception</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;\n&quot;</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">h</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">// throws boost::task::task_interrupted
+</phrase><phrase role="special">}</phrase>
+</programlisting>
+ </para>
+ </section>
+ <section id="boost_task.own_thread">
+ <title><link linkend="boost_task.own_thread"> Execute in own thread</link></title>
+ <para>
+ <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">own_thread</phrase></code>
+ executes the task in the current thread (synchronous execution - concerns of
+ <ulink url="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2802.html">N2802</ulink>
+ do not aply).
+ </para>
+ <para>
+
+<programlisting><phrase role="keyword">long</phrase> <phrase role="identifier">fibonacci</phrase><phrase role="special">(</phrase> <phrase role="keyword">long</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">==</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="keyword">return</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase>
+ <phrase role="keyword">if</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="keyword">return</phrase> <phrase role="number">1</phrase><phrase role="special">;</phrase>
+ <phrase role="keyword">long</phrase> <phrase role="identifier">k1</phrase><phrase role="special">(</phrase> <phrase role="number">1</phrase><phrase role="special">),</phrase> <phrase role="identifier">k2</phrase><phrase role="special">(</phrase> <phrase role="number">0</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">2</phrase><phrase role="special">);</phrase> <phrase role="identifier">i</phrase> <phrase role="special">&lt;=</phrase> <phrase role="identifier">n</phrase><phrase role="special">;</phrase> <phrase role="special">++</phrase><phrase role="identifier">i</phrase><phrase role="special">)</phrase>
+ <phrase role="special">{</phrase>
+ <phrase role="keyword">long</phrase> <phrase role="identifier">tmp</phrase><phrase role="special">(</phrase> <phrase role="identifier">k1</phrase><phrase role="special">);</phrase>
+ <phrase role="identifier">k1</phrase> <phrase role="special">=</phrase> <phrase role="identifier">k1</phrase> <phrase role="special">+</phrase> <phrase role="identifier">k2</phrase><phrase role="special">;</phrase>
+ <phrase role="identifier">k2</phrase> <phrase role="special">=</phrase> <phrase role="identifier">tmp</phrase><phrase role="special">;</phrase>
+ <phrase role="special">}</phrase>
+ <phrase role="keyword">return</phrase> <phrase role="identifier">k1</phrase><phrase role="special">;</phrase>
+<phrase role="special">}</phrase>
+
+<phrase role="keyword">void</phrase> <phrase role="identifier">main</phrase><phrase role="special">()</phrase>
+<phrase role="special">{</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">handle</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">long</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">h</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">async</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">own_thread</phrase><phrase role="special">(),</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">make_task</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">fibonacci</phrase><phrase role="special">,</phrase>
+ <phrase role="number">10</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">cout</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;fibonacci(10) == &quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">h</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="special">}</phrase>
+</programlisting>
+ </para>
+ </section>
+ <section id="boost_task.new_thread">
+ <title><link linkend="boost_task.new_thread"> Execute in new thread</link></title>
+ <para>
+ <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">new_thread</phrase></code>
+ creates a new <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">thread</phrase></code> and executes the task in this thread
+ (asynchronous). The created thread gets joined by handle (so <ulink url="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2802.html">N2802</ulink>
+ should be addressed).
+ </para>
+ <caution>
+ <para>
+ Always store the returned <emphasis>asynchronous-completion-token</emphasis>
+ in a variable because <code><phrase role="identifier">boost</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">task</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">handle</phrase></code>
+ joins the thread in its destructor (if the last reference gets out of scope).
+ </para>
+ </caution>
+ <para>
+
+<programlisting><phrase role="keyword">long</phrase> <phrase role="identifier">fibonacci</phrase><phrase role="special">(</phrase> <phrase role="keyword">long</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">==</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="keyword">return</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase>
+ <phrase role="keyword">if</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="keyword">return</phrase> <phrase role="number">1</phrase><phrase role="special">;</phrase>
+ <phrase role="keyword">long</phrase> <phrase role="identifier">k1</phrase><phrase role="special">(</phrase> <phrase role="number">1</phrase><phrase role="special">),</phrase> <phrase role="identifier">k2</phrase><phrase role="special">(</phrase> <phrase role="number">0</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">2</phrase><phrase role="special">);</phrase> <phrase role="identifier">i</phrase> <phrase role="special">&lt;=</phrase> <phrase role="identifier">n</phrase><phrase role="special">;</phrase> <phrase role="special">++</phrase><phrase role="identifier">i</phrase><phrase role="special">)</phrase>
+ <phrase role="special">{</phrase>
+ <phrase role="keyword">long</phrase> <phrase role="identifier">tmp</phrase><phrase role="special">(</phrase> <phrase role="identifier">k1</phrase><phrase role="special">);</phrase>
+ <phrase role="identifier">k1</phrase> <phrase role="special">=</phrase> <phrase role="identifier">k1</phrase> <phrase role="special">+</phrase> <phrase role="identifier">k2</phrase><phrase role="special">;</phrase>
+ <phrase role="identifier">k2</phrase> <phrase role="special">=</phrase> <phrase role="identifier">tmp</phrase><phrase role="special">;</phrase>
+ <phrase role="special">}</phrase>
+ <phrase role="keyword">return</phrase> <phrase role="identifier">k1</phrase><phrase role="special">;</phrase>
+<phrase role="special">}</phrase>
+
+<phrase role="keyword">void</phrase> <phrase role="identifier">main</phrase><phrase role="special">()</phrase>
+<phrase role="special">{</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">handle</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">long</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">h</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">async</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">new_thread</phrase><phrase role="special">(),</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">make_task</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">fibonacci</phrase><phrase role="special">,</phrase>
+ <phrase role="number">10</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">cout</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;fibonacci(10) == &quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">h</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="special">}</phrase>
+</programlisting>
+ </para>
+ <para>
+ In the example below both <code><phrase role="identifier">a_function</phrase><phrase
+ role="special">()</phrase></code> and <code><phrase role="identifier">another_function</phrase><phrase
+ role="special">()</phrase></code> are executed synchron (see <link linkend="boost_task.own_thread"><code><phrase
+ role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">own_thread</phrase></code></link>
+ for synchronous execution)!
+ </para>
+ <para>
+
+<programlisting><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">async</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">new_thread</phrase><phrase role="special">(),</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">make_task</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">a_function</phrase><phrase role="special">)</phrase> <phrase role="special">)</phrase> <phrase role="special">);</phrase>
+
+<phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">async</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">new_thread</phrase><phrase role="special">(),</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">make_task</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">another_function</phrase><phrase role="special">)</phrase> <phrase role="special">)</phrase> <phrase role="special">);</phrase>
+</programlisting>
+ </para>
+ </section>
+ <section id="boost_task.pool">
+ <title><link linkend="boost_task.pool"> Thread-pool</link></title>
+ <para>
+ Instead of creating a new thread and quickly throwing it away after the task
+ is done, the overhead related to thread creation and destruction can be avoided
+ by running the <emphasis>work-items</emphasis> on a <emphasis>thread-pool</emphasis>
+ (reusing an existing <emphasis>worker-thread</emphasis> instead).
+ </para>
+ <para>
+ A <emphasis>thread-pool</emphasis> maintains a queue (or queues) of <emphasis>work-items</emphasis>
+ to be done, and a pool of <emphasis>worker-threads</emphasis> which execute
+ <emphasis>work-items</emphasis> from the queue(s).
+ </para>
+ <para>
+ <emphasis role="bold">Boost.Task</emphasis> provides <code><phrase role="identifier">boost</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">async</phrase><phrase role="special">()</phrase></code> with
+ support of executing an <code><phrase role="identifier">boost</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase></code> in <code><phrase role="identifier">boost</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">default_pool</phrase></code> (using <code><phrase role="identifier">boost</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">default_pool</phrase><phrase role="special">()</phrase></code>):
+ </para>
+ <para>
+
+<programlisting><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="identifier">echo</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">msg</phrase><phrase role="special">)</phrase>
+<phrase role="special">{</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">msg</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase>
+
+<phrase role="keyword">void</phrase> <phrase role="identifier">main</phrase><phrase role="special">()</phrase>
+<phrase role="special">{</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">handle</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">h</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">async</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">default_pool</phrase><phrase role="special">(),</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">make_task</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">echo</phrase><phrase role="special">,</phrase>
+ <phrase role="string">&quot;Hello World!&quot;</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">cout</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">h</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="special">}</phrase>
+</programlisting>
+ </para>
+ <para>
+ and a custom <emphasis>thread-pool</emphasis> (passing pool instance as an
+ argument to <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">async</phrase><phrase
+ role="special">()</phrase></code>):
+ </para>
+ <para>
+
+<programlisting><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="identifier">echo</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">msg</phrase><phrase role="special">)</phrase>
+<phrase role="special">{</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">msg</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase>
+
+<phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">static_pool</phrase><phrase role="special">&lt;</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</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">task</phrase><phrase role="special">::</phrase><phrase role="identifier">fifo</phrase>
+ <phrase role="special">&gt;</phrase>
+<phrase role="special">&gt;</phrase> <phrase role="identifier">pool</phrase><phrase role="special">(</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">poolsize</phrase><phrase role="special">(</phrase> <phrase role="number">5</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase>
+
+<phrase role="keyword">void</phrase> <phrase role="identifier">main</phrase><phrase role="special">()</phrase>
+<phrase role="special">{</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">handle</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">h</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">async</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">pool</phrase><phrase role="special">,</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">make_task</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">echo</phrase><phrase role="special">,</phrase>
+ <phrase role="string">&quot;Hello World!&quot;</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">cout</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">h</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="special">}</phrase>
+</programlisting>
+ .
+ </para>
+ <important>
+ <para>
+ Tasks should not be too small (performance overhead dominates) and avoid
+ blocking tasks
+ <footnote>
+ <para>
+ see <ulink url="http://www.ddj.com/go-parallel/article/showArticle.jhtml?articleID=216500409">'Use
+ Thread Pools Correctly'</ulink>, Herb Sutter
+ </para>
+ </footnote>
+ .
+ </para>
+ </important>
+ <section id="boost_task.pool.static_pool">
+ <title><link linkend="boost_task.pool.static_pool"> Static thread-pool</link></title>
+ <para>
+ <emphasis role="bold">Boost.Task</emphasis> provides <code><phrase role="identifier">boost</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">task</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">static_pool</phrase></code>
+ - which contains an fixed set of pre-forked <emphasis>worker-threads</emphasis>
+ (the size of the pool doesn't change during its lifetime).
+ </para>
+ <para>
+
+<programlisting><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">_static_pool</phrase><phrase role="special">&lt;</phrase> <phrase role="comment">// pool type
+</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">unbounded_channel</phrase><phrase role="special">&lt;</phrase> <phrase role="comment">// queuing policy (unbounded_channel, bounded_channel)
+</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">fifo</phrase> <phrase role="comment">// scheduling policy (fifo, priority, smart)
+</phrase> <phrase role="special">&gt;</phrase>
+<phrase role="special">&gt;</phrase> <phrase role="identifier">pool</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">poolsize</phrase><phrase role="special">(</phrase> <phrase role="number">6</phrase><phrase role="special">),</phrase> <phrase role="comment">// pool with 6 pre-forked worker-threads
+</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">posix_time</phrase><phrase role="special">::</phrase><phrase role="identifier">posix_time</phrase><phrase role="special">::</phrase><phrase role="identifier">milliseconds</phrase><phrase role="special">(</phrase> <phrase role="number">50</phrase><phrase role="special">),</phrase> <phrase role="comment">// time to sleep if no work-item available
+</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">scanns</phrase><phrase role="special">(</phrase> <phrase role="number">10</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase> <phrase role="comment">// iterations over local-queues before sleep
+</phrase></programlisting>
+ </para>
+ <para>
+ The first argument of the constructor specifies how many <emphasis>worker-threads</emphasis>
+ the pool will contain. The second and third argument are used by the <link
+ linkend="boost_task.pool.work_stealing"><emphasis>work-stealing</emphasis></link>
+ algorithm.
+ </para>
+ <note>
+ <para>
+ If <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">bounded_channel</phrase></code> is used as queuing policy
+ the constructor has two additional arguments .
+ </para>
+ </note>
+ <para>
+ <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">static_pool</phrase></code> provides functionality to check
+ the status of the pool - <code><phrase role="identifier">close</phrase><phrase
+ role="special">()</phrase></code> returns true when the pool was shutdown
+ and <code><phrase role="identifier">active</phrase><phrase role="special">()</phrase></code>
+ as well as <code><phrase role="identifier">idle</phrase><phrase role="special">()</phrase></code>
+ returning how many <emphasis>worker-threads</emphasis> are active (executing
+ a task) or idle. The size of the pool can be accessed over <code><phrase
+ role="identifier">size</phrase><phrase role="special">()</phrase></code>.
+ </para>
+ <para>
+ For infomational pruposes <code><phrase role="identifier">empty</phrase><phrase
+ role="special">()</phrase></code> and <code><phrase role="identifier">pending</phrase><phrase
+ role="special">()()</phrase></code> can be used in order to know if the global
+ task-queue is empty or how many tasks are waiting for execution. With <code><phrase
+ role="identifier">clear</phrase><phrase role="special">()</phrase></code>
+ all tasks are removed from the global-queue.
+ </para>
+ <note>
+ <para>
+ <code><phrase role="identifier">pending</phrase><phrase role="special">()()</phrase></code>
+ does not count tasks in the local-queues of the <emphasis>worker-threads</emphasis>.
+ </para>
+ </note>
+ </section>
+ <section id="boost_task.pool.channel">
+ <title><link linkend="boost_task.pool.channel"> Channel</link></title>
+ <para>
+ The channel synchronizes the access between non-pool threads (application
+ threads) and <emphasis>worker-threads</emphasis> and implements a queuing
+ policy (limitation of queued tasks).
+ </para>
+ <anchor id="boost_task.pool.channel._code__phrase_role__identifier__boost__phrase__phrase_role__special______phrase__phrase_role__identifier__task__phrase__phrase_role__special______phrase__phrase_role__identifier__bounded_channel__phrase___code_"/>
+ <bridgehead renderas="sect4">
+ <link linkend="boost_task.pool.channel._code__phrase_role__identifier__boost__phrase__phrase_role__special______phrase__phrase_role__identifier__task__phrase__phrase_role__special______phrase__phrase_role__identifier__bounded_channel__phrase___code_"><code><phrase
+ role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">bounded_channel</phrase></code></link>
+ </bridgehead>
+ <para>
+ <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">bounded_channel</phrase></code> contains a single lock
+ in order to synchronize access to the queue. The number of pending tasks
+ is limited in order to prevent resource exhaustion. For this purpose a high-
+ and low-watermark has to be passed at construction. <code><phrase role="identifier">boost</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">task</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">high_watermark</phrase></code>
+ sets the maximum of pending tasks. If this limited is reached all threads
+ which submit a task will be set to sleep (blocked). If it is equal to <code><phrase
+ role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">low_watermark</phrase></code> everytime a sleeping producer
+ thread will be woken up and puts its task if one worker thread has taken
+ a task from the channel. <code><phrase role="identifier">boost</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">task</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">low_watermark</phrase></code>
+ sets the threshold when blocked threads get woken up. If it is less than
+ <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">high_watermark</phrase></code> all sleeping producer threads
+ will be woken up if the amount of pending tasks reaches <code><phrase role="identifier">boost</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">task</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">low_watermark</phrase></code>.
+ </para>
+ <anchor id="boost_task.pool.channel._code__phrase_role__identifier__boost__phrase__phrase_role__special______phrase__phrase_role__identifier__task__phrase__phrase_role__special______phrase__phrase_role__identifier__unbounded_channel__phrase___code_"/>
+ <bridgehead renderas="sect4">
+ <link linkend="boost_task.pool.channel._code__phrase_role__identifier__boost__phrase__phrase_role__special______phrase__phrase_role__identifier__task__phrase__phrase_role__special______phrase__phrase_role__identifier__unbounded_channel__phrase___code_"><code><phrase
+ role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">unbounded_channel</phrase></code></link>
+ </bridgehead>
+ <para>
+ <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">unbounded_channel</phrase></code> contains a single lock
+ in order to synchronize access to the queue. An unlimited number of tasks
+ can be queued into this channel. The insertion of an <code><phrase role="identifier">boost</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">task</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">task</phrase></code>
+ will never block. If the channel becomes empty <emphasis>worker-threads</emphasis>
+ will be set to sleep until new tasks are enqueued.
+ </para>
+ </section>
+ <section id="boost_task.pool.scheduling">
+ <title><link linkend="boost_task.pool.scheduling"> Scheduling</link></title>
+ <para>
+ The scheduling policy determines how tasks are scheduled inside the <emphasis>channel</emphasis>.
+ </para>
+ <anchor id="boost_task.pool.scheduling.fifo"/>
+ <bridgehead renderas="sect4">
+ <link linkend="boost_task.pool.scheduling.fifo">fifo</link>
+ </bridgehead>
+ <para>
+ First inserted pending <code><phrase role="identifier">boost</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">task</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">task</phrase></code>
+ gets taken first.
+ </para>
+ <anchor id="boost_task.pool.scheduling.priority"/>
+ <bridgehead renderas="sect4">
+ <link linkend="boost_task.pool.scheduling.priority">priority</link>
+ </bridgehead>
+ <para>
+ Each <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase></code> is submitted to the pool with a priority
+ attribute. The type and ordering of the priority is user-defined.
+ </para>
+ <para>
+
+<programlisting><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">static_pool</phrase><phrase role="special">&lt;</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">unbounded_channel</phrase><phrase role="special">&lt;</phrase> <phrase role="comment">// allow unlimited tasks to be queue in global-queue
+</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">priority</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">int</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&gt;</phrase> <phrase role="comment">// tasks with lower priority are scheduled first
+</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">pool</phrase><phrase role="special">(</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">poolsize</phrase><phrase role="special">(</phrase> <phrase role="number">5</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase>
+
+<phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">async</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">pool</phrase><phrase role="special">,</phrase> <phrase role="comment">// thread-pool
+</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">make_task</phrase><phrase role="special">(</phrase> <phrase role="identifier">some_fn</phrase><phrase role="special">),</phrase> <phrase role="comment">// task to be executed
+</phrase> <phrase role="number">5</phrase><phrase role="special">);</phrase> <phrase role="comment">// priority is 5
+</phrase>
+<phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">async</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">pool</phrase><phrase role="special">,</phrase> <phrase role="comment">// thread-pool
+</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">make_task</phrase><phrase role="special">(</phrase> <phrase role="identifier">another_fn</phrase><phrase role="special">),</phrase> <phrase role="comment">// task to be executed
+</phrase> <phrase role="number">3</phrase><phrase role="special">);</phrase> <phrase role="comment">// priority is 3
+</phrase></programlisting>
+ </para>
+ <para>
+ In this example the tasks get scheduled by the assigned integer (third argument
+ of <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">async</phrase><phrase role="special">()</phrase></code>).
+ The <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase></code> with the lowest priority gets scheduled
+ first (taken by a <emphasis>worker-thread</emphasis>). The ordering can be
+ changed by the second argument of <code><phrase role="identifier">boost</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">task</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">priority</phrase></code>
+ (the default is <code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">less</phrase><phrase role="special">&lt;</phrase> <phrase
+ role="identifier">Attr</phrase> <phrase role="special">&gt;</phrase></code>).
+ </para>
+ <para>
+
+<programlisting><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">static_pool</phrase><phrase role="special">&lt;</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</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">task</phrase><phrase role="special">::</phrase><phrase role="identifier">priority</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">int</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">greater</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">int</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&gt;</phrase> <phrase role="comment">// tasks with higher priority are scheduled first
+</phrase>
+<phrase role="special">&gt;</phrase> <phrase role="identifier">pool</phrase><phrase role="special">(</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">poolsize</phrase><phrase role="special">(</phrase> <phrase role="number">5</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase>
+</programlisting>
+ </para>
+ <anchor id="boost_task.pool.scheduling.smart"/>
+ <bridgehead renderas="sect4">
+ <link linkend="boost_task.pool.scheduling.smart">smart</link>
+ </bridgehead>
+ <para>
+ Each inserted <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase></code> is associated with an attribute. The
+ scheduler gets an put- and take-policy as template arguments. The corresponding
+ policy gets applied for each insertion and removal.
+ </para>
+ <para>
+ <emphasis role="bold">Boost.Task</emphasis> provides <code><phrase role="identifier">boost</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">task</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">replace_oldest</phrase></code>
+ as put- policy and <code><phrase role="identifier">boost</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">task</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">take_oldest</phrase></code>
+ as take-policy. Both policies allow the replacement of older (pending) tasks
+ in the scheduler by new ones.
+ </para>
+ <para>
+
+<programlisting><phrase role="keyword">long</phrase> <phrase role="identifier">fibonacci_fn</phrase><phrase role="special">(</phrase> <phrase role="keyword">long</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">==</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="keyword">return</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase>
+ <phrase role="keyword">if</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="keyword">return</phrase> <phrase role="number">1</phrase><phrase role="special">;</phrase>
+ <phrase role="keyword">long</phrase> <phrase role="identifier">k1</phrase><phrase role="special">(</phrase> <phrase role="number">1</phrase><phrase role="special">),</phrase> <phrase role="identifier">k2</phrase><phrase role="special">(</phrase> <phrase role="number">0</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">2</phrase><phrase role="special">);</phrase> <phrase role="identifier">i</phrase> <phrase role="special">&lt;=</phrase> <phrase role="identifier">n</phrase><phrase role="special">;</phrase> <phrase role="special">++</phrase><phrase role="identifier">i</phrase><phrase role="special">)</phrase>
+ <phrase role="special">{</phrase>
+ <phrase role="keyword">long</phrase> <phrase role="identifier">tmp</phrase><phrase role="special">(</phrase> <phrase role="identifier">k1</phrase><phrase role="special">);</phrase>
+ <phrase role="identifier">k1</phrase> <phrase role="special">=</phrase> <phrase role="identifier">k1</phrase> <phrase role="special">+</phrase> <phrase role="identifier">k2</phrase><phrase role="special">;</phrase>
+ <phrase role="identifier">k2</phrase> <phrase role="special">=</phrase> <phrase role="identifier">tmp</phrase><phrase role="special">;</phrase>
+ <phrase role="special">}</phrase>
+ <phrase role="keyword">return</phrase> <phrase role="identifier">k1</phrase><phrase role="special">;</phrase>
+<phrase role="special">}</phrase>
+
+<phrase role="keyword">typedef</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">static_pool</phrase><phrase role="special">&lt;</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</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">task</phrase><phrase role="special">::</phrase><phrase role="identifier">smart</phrase><phrase role="special">&lt;</phrase>
+ <phrase role="keyword">int</phrase><phrase role="special">,</phrase>
+ <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">less</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">int</phrase> <phrase role="special">&gt;,</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">replace_oldest</phrase><phrase role="special">,</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">take_oldest</phrase>
+ <phrase role="special">&gt;</phrase>
+ <phrase role="special">&gt;</phrase>
+<phrase role="special">&gt;</phrase> <phrase role="identifier">pool_type</phrase><phrase role="special">;</phrase>
+
+<phrase role="keyword">void</phrase> <phrase role="identifier">main</phrase><phrase role="special">()</phrase>
+<phrase role="special">{</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">task</phrase><phrase role="special">::</phrase><phrase role="identifier">poolsize</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">// replaced by later task with same attribute == 2
+</phrase> <phrase role="comment">// if still pending in pool
+</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">async</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">pool</phrase><phrase role="special">,</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">make_task</phrase><phrase role="special">(</phrase> <phrase role="identifier">fibonacci_fn</phrase><phrase role="special">,</phrase> <phrase role="number">10</phrase><phrase role="special">),</phrase>
+ <phrase role="number">2</phrase><phrase role="special">);</phrase> <phrase role="comment">// attribute is 2
+</phrase>
+ <phrase role="comment">// will replace previous pending task with attribute == 2
+</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">async</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">pool</phrase><phrase role="special">,</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">make_task</phrase><phrase role="special">(</phrase> <phrase role="identifier">fibonacci_fn</phrase><phrase role="special">,</phrase> <phrase role="number">5</phrase><phrase role="special">),</phrase>
+ <phrase role="number">2</phrase><phrase role="special">);</phrase> <phrase role="comment">// attribute is 2 too
+</phrase><phrase role="special">}</phrase>
+</programlisting>
+ </para>
+ </section>
+ <section id="boost_task.pool.pool_shutdown">
+ <title><link linkend="boost_task.pool.pool_shutdown"> Pool shutdown</link></title>
+ <para>
+ <emphasis role="bold">Boost.Task</emphasis> allows to shutdown a <emphasis>thread-pool</emphasis>
+ explicitly via functions <code><phrase role="identifier">shutdown</phrase><phrase
+ role="special">()</phrase></code> and <code><phrase role="identifier">shutdown_now</phrase><phrase
+ role="special">()</phrase></code>. The destructor of the pool calls <code><phrase
+ role="identifier">shutdown</phrase><phrase role="special">()</phrase></code>
+ if not already done so that all <emphasis>worker-threads</emphasis> are joined
+ and the topic of <ulink url="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2802.html">N2802</ulink>
+ should be addressed.
+ </para>
+ <anchor id="boost_task.pool.pool_shutdown.shutdown"/>
+ <bridgehead renderas="sect4">
+ <link linkend="boost_task.pool.pool_shutdown.shutdown">Shutdown</link>
+ </bridgehead>
+ <para>
+ If <code><phrase role="identifier">shutdown</phrase><phrase role="special">()</phrase></code>
+ is called - the the pool is set the closed state and all <emphasis>worker-threads</emphasis>
+ are joined until all pending tasks are processed. No futher tasks can be
+ submitted.
+ </para>
+ <note>
+ <para>
+ The deconstructor calls <code><phrase role="identifier">shutdown</phrase><phrase
+ role="special">()</phrase></code> if the pool was not shutdown yet.
+ </para>
+ </note>
+ <para>
+
+<programlisting><phrase role="keyword">long</phrase> <phrase role="identifier">fibonacci_fn</phrase><phrase role="special">(</phrase> <phrase role="keyword">long</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">==</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="keyword">return</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase>
+ <phrase role="keyword">if</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="keyword">return</phrase> <phrase role="number">1</phrase><phrase role="special">;</phrase>
+ <phrase role="keyword">long</phrase> <phrase role="identifier">k1</phrase><phrase role="special">(</phrase> <phrase role="number">1</phrase><phrase role="special">),</phrase> <phrase role="identifier">k2</phrase><phrase role="special">(</phrase> <phrase role="number">0</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">2</phrase><phrase role="special">);</phrase> <phrase role="identifier">i</phrase> <phrase role="special">&lt;=</phrase> <phrase role="identifier">n</phrase><phrase role="special">;</phrase> <phrase role="special">++</phrase><phrase role="identifier">i</phrase><phrase role="special">)</phrase>
+ <phrase role="special">{</phrase>
+ <phrase role="keyword">long</phrase> <phrase role="identifier">tmp</phrase><phrase role="special">(</phrase> <phrase role="identifier">k1</phrase><phrase role="special">);</phrase>
+ <phrase role="identifier">k1</phrase> <phrase role="special">=</phrase> <phrase role="identifier">k1</phrase> <phrase role="special">+</phrase> <phrase role="identifier">k2</phrase><phrase role="special">;</phrase>
+ <phrase role="identifier">k2</phrase> <phrase role="special">=</phrase> <phrase role="identifier">tmp</phrase><phrase role="special">;</phrase>
+ <phrase role="special">}</phrase>
+ <phrase role="keyword">return</phrase> <phrase role="identifier">k1</phrase><phrase role="special">;</phrase>
+<phrase role="special">}</phrase>
+
+<phrase role="keyword">typedef</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">static_pool</phrase><phrase role="special">&lt;</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</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">task</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">void</phrase> <phrase role="identifier">main</phrase><phrase role="special">()</phrase>
+<phrase role="special">{</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">task</phrase><phrase role="special">::</phrase><phrase role="identifier">poolsize</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">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">handle</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">long</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">h1</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">async</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">pool</phrase><phrase role="special">,</phrase> <phrase role="comment">// asynchronous executor
+</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">make_task</phrase><phrase role="special">(</phrase> <phrase role="identifier">fibonacci_fn</phrase><phrase role="special">,</phrase> <phrase role="number">10</phrase><phrase role="special">)</phrase> <phrase role="special">)</phrase> <phrase role="special">);</phrase>
+
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">handle</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">long</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">h2</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">async</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">pool</phrase><phrase role="special">,</phrase> <phrase role="comment">// asynchronous executor
+</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">make_task</phrase><phrase role="special">(</phrase> <phrase role="identifier">fibonacci_fn</phrase><phrase role="special">,</phrase> <phrase role="number">5</phrase><phrase role="special">)</phrase> <phrase role="special">)</phrase> <phrase role="special">);</phrase>
+
+ <phrase role="identifier">pool</phrase><phrase role="special">.</phrase><phrase role="identifier">shutdown</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(10) == &quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">h1</phrase><phrase role="special">.</phrase><phrase role="identifier">get</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;\n&quot;</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(5) == &quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">h2</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="special">}</phrase>
+</programlisting>
+ </para>
+ <anchor id="boost_task.pool.pool_shutdown.shutdown_immediatly"/>
+ <bridgehead renderas="sect4">
+ <link linkend="boost_task.pool.pool_shutdown.shutdown_immediatly">Shutdown
+ immediatly</link>
+ </bridgehead>
+ <para>
+ The function <code><phrase role="identifier">shutdown_now</phrase><phrase
+ role="special">()</phrase></code> closes the pool, interrupts and then joins
+ all <emphasis>worker-threads</emphasis>. Pending tasks are unprocessed.
+ </para>
+ <para>
+
+<programlisting><phrase role="keyword">long</phrase> <phrase role="identifier">fibonacci_fn</phrase><phrase role="special">(</phrase> <phrase role="keyword">long</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">==</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="keyword">return</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase>
+ <phrase role="keyword">if</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="keyword">return</phrase> <phrase role="number">1</phrase><phrase role="special">;</phrase>
+ <phrase role="keyword">long</phrase> <phrase role="identifier">k1</phrase><phrase role="special">(</phrase> <phrase role="number">1</phrase><phrase role="special">),</phrase> <phrase role="identifier">k2</phrase><phrase role="special">(</phrase> <phrase role="number">0</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">2</phrase><phrase role="special">);</phrase> <phrase role="identifier">i</phrase> <phrase role="special">&lt;=</phrase> <phrase role="identifier">n</phrase><phrase role="special">;</phrase> <phrase role="special">++</phrase><phrase role="identifier">i</phrase><phrase role="special">)</phrase>
+ <phrase role="special">{</phrase>
+ <phrase role="keyword">long</phrase> <phrase role="identifier">tmp</phrase><phrase role="special">(</phrase> <phrase role="identifier">k1</phrase><phrase role="special">);</phrase>
+ <phrase role="identifier">k1</phrase> <phrase role="special">=</phrase> <phrase role="identifier">k1</phrase> <phrase role="special">+</phrase> <phrase role="identifier">k2</phrase><phrase role="special">;</phrase>
+ <phrase role="identifier">k2</phrase> <phrase role="special">=</phrase> <phrase role="identifier">tmp</phrase><phrase role="special">;</phrase>
+ <phrase role="special">}</phrase>
+ <phrase role="keyword">return</phrase> <phrase role="identifier">k1</phrase><phrase role="special">;</phrase>
+<phrase role="special">}</phrase>
+
+<phrase role="keyword">typedef</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">static_pool</phrase><phrase role="special">&lt;</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</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">task</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">void</phrase> <phrase role="identifier">main</phrase><phrase role="special">()</phrase>
+<phrase role="special">{</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">task</phrase><phrase role="special">::</phrase><phrase role="identifier">poolsize</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">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">handle</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">long</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">h1</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">async</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">pool</phrase><phrase role="special">,</phrase> <phrase role="comment">// asynchronous executor
+</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">make_task</phrase><phrase role="special">(</phrase> <phrase role="identifier">fibonacci_fn</phrase><phrase role="special">,</phrase> <phrase role="number">10</phrase><phrase role="special">)</phrase> <phrase role="special">)</phrase> <phrase role="special">);</phrase>
+
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">handle</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">long</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">h2</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">async</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">pool</phrase><phrase role="special">,</phrase> <phrase role="comment">// asynchronous executor
+</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">make_task</phrase><phrase role="special">(</phrase> <phrase role="identifier">fibonacci_fn</phrase><phrase role="special">,</phrase> <phrase role="number">5</phrase><phrase role="special">)</phrase> <phrase role="special">)</phrase> <phrase role="special">);</phrase>
+
+ <phrase role="identifier">pool</phrase><phrase role="special">.</phrase><phrase role="identifier">shutdown_now</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(10) == &quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">h1</phrase><phrase role="special">.</phrase><phrase role="identifier">get</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;\n&quot;</phrase><phrase role="special">;</phrase> <phrase role="comment">// may throw broken_task or task_interrupted
+</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(5) == &quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">h2</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">// may throw broken_task or task_interrupted
+</phrase><phrase role="special">}</phrase>
+</programlisting>
+ </para>
+ </section>
+ <section id="boost_task.pool.default_pool">
+ <title><link linkend="boost_task.pool.default_pool"> Default pool</link></title>
+ <para>
+ The library provides a default-pool accessible via <code><phrase role="identifier">boost</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">task</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">default_pool</phrase><phrase
+ role="special">()</phrase></code>. The function returns a reference to <code><phrase
+ role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">static_pool</phrase><phrase role="special">&lt;</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</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">task</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">fifo</phrase> <phrase role="special">&gt;</phrase> <phrase
+ role="special">&gt;</phrase></code>. The static instance of <code><phrase
+ role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">default_pool</phrase></code> contains as many <emphasis>worker-threads</emphasis>
+ as <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">thread</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">hardware_concurrency</phrase><phrase role="special">()</phrase></code>
+ returns, queues unlimited amount of tasks and schedules the tasks in FIFO-order.
+ </para>
+ <para>
+
+<programlisting><phrase role="keyword">long</phrase> <phrase role="identifier">fibonacci_fn</phrase><phrase role="special">(</phrase> <phrase role="keyword">long</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">==</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="keyword">return</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase>
+ <phrase role="keyword">if</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="keyword">return</phrase> <phrase role="number">1</phrase><phrase role="special">;</phrase>
+ <phrase role="keyword">long</phrase> <phrase role="identifier">k1</phrase><phrase role="special">(</phrase> <phrase role="number">1</phrase><phrase role="special">),</phrase> <phrase role="identifier">k2</phrase><phrase role="special">(</phrase> <phrase role="number">0</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">2</phrase><phrase role="special">);</phrase> <phrase role="identifier">i</phrase> <phrase role="special">&lt;=</phrase> <phrase role="identifier">n</phrase><phrase role="special">;</phrase> <phrase role="special">++</phrase><phrase role="identifier">i</phrase><phrase role="special">)</phrase>
+ <phrase role="special">{</phrase>
+ <phrase role="keyword">long</phrase> <phrase role="identifier">tmp</phrase><phrase role="special">(</phrase> <phrase role="identifier">k1</phrase><phrase role="special">);</phrase>
+ <phrase role="identifier">k1</phrase> <phrase role="special">=</phrase> <phrase role="identifier">k1</phrase> <phrase role="special">+</phrase> <phrase role="identifier">k2</phrase><phrase role="special">;</phrase>
+ <phrase role="identifier">k2</phrase> <phrase role="special">=</phrase> <phrase role="identifier">tmp</phrase><phrase role="special">;</phrase>
+ <phrase role="special">}</phrase>
+ <phrase role="keyword">return</phrase> <phrase role="identifier">k1</phrase><phrase role="special">;</phrase>
+<phrase role="special">}</phrase>
+
+<phrase role="keyword">void</phrase> <phrase role="identifier">main</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="string">&quot;worker-threads running in default-pool == &quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">default_pool</phrase><phrase role="special">().</phrase><phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;\n&quot;</phrase><phrase role="special">;</phrase>
+
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">handle</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">long</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">h1</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">async</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">default_pool</phrase><phrase role="special">(),</phrase> <phrase role="comment">// asynchronous executor == default-pool
+</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">make_task</phrase><phrase role="special">(</phrase> <phrase role="identifier">fibonacci_fn</phrase><phrase role="special">,</phrase> <phrase role="number">10</phrase><phrase role="special">)</phrase> <phrase role="special">)</phrase> <phrase role="special">);</phrase>
+
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">handle</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">long</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">h2</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">async</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">default_pool</phrase><phrase role="special">(),</phrase> <phrase role="comment">// asynchronous executor == default-pool
+</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">make_task</phrase><phrase role="special">(</phrase> <phrase role="identifier">fibonacci_fn</phrase><phrase role="special">,</phrase> <phrase role="number">5</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">cout</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;fibonacci(10) == &quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">h1</phrase><phrase role="special">.</phrase><phrase role="identifier">get</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;\n&quot;</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(5) == &quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">h2</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="special">}</phrase>
+</programlisting>
+ </para>
+ </section>
+ <section id="boost_task.pool.processor_binding">
+ <title><link linkend="boost_task.pool.processor_binding"> Processor binding</link></title>
+ <para>
+ For some applications it is convenient to bind the <emphasis>worker-threads</emphasis>
+ to processors/cores of the system. For this purpose <code><phrase role="identifier">boost</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">task</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">poolsize</phrase></code>
+ must not be given to the constructor so that a <emphasis>worker-thread</emphasis>
+ is created an bound the the core.
+ </para>
+ <para>
+
+<programlisting><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">static_pool</phrase><phrase role="special">&lt;</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</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</phrase><phrase role="special">;</phrase> <phrase role="comment">// constructs thread-pool with worker-threads as hardware_concurrency() returns
+</phrase></programlisting>
+ </para>
+ <para>
+ The constructor takes additional arguments for the link_work_stealing[work-stealing
+ algorithm] and link_channel[high-] and link_channel[low-watermark] too.
+ </para>
+ <note>
+ <para>
+ <emphasis role="bold">Boost.Task</emphasis> does provide this feature only
+ for Windows, Linux, AIX, HP-UX and Solaris.
+ </para>
+ </note>
+ </section>
+ <section id="boost_task.pool.work_stealing">
+ <title><link linkend="boost_task.pool.work_stealing"> Work-Stealing</link></title>
+ <para>
+ Traditional <emphasis>thread-pools</emphasis> do not scale because they use
+ a single global-queue protected by a global-lock. The frequency at which
+ <emphasis>worker-threads</emphasis> aquire the global-lock becomes a limiting
+ factor for the throughput if:
+ </para>
+ <itemizedlist>
+ <listitem>
+ the tasks become smaller
+ </listitem>
+ <listitem>
+ more processors are added
+ </listitem>
+ </itemizedlist>
+ <para>
+ A <emphasis>work-stealing</emphasis> algorithm can be used to solve this
+ problem. It uses a special kind of queue which has two ends, and allows lock-free
+ pushes and pops from the <emphasis>private end</emphasis> (accessed by the
+ <emphasis>worker-thread</emphasis> owning the queue), but requires synchronization
+ from the <emphasis>public end</emphasis> (accessed by the other <emphasis>worker-threads</emphasis>).
+ Synchronization is necessary when the queue is sufficiently small that private
+ and public operations could conflict.
+ </para>
+ <para>
+ The pool contains one global-queue (<code><phrase role="identifier">boost</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">task</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">bounded_channel</phrase></code>
+ or <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">unbounded_channel</phrase></code>) protected by a global-lock
+ and each <emphasis>worker-thread</emphasis> has its own private local worker-queue.
+ If work is enqueued by a <emphasis>worker-thread</emphasis> the <code><phrase
+ role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase></code> is stored in the worker queue. If
+ the work is enqueued by a application thread it goes into the global queue.
+ When <emphasis>worker-threads</emphasis> are looking for work, they have
+ following search order:
+ </para>
+ <itemizedlist>
+ <listitem>
+ look into the private worker-queue - tasks can be dequeued without locks
+ </listitem>
+ <listitem>
+ look in the global-queue - locks are used for synchronization
+ </listitem>
+ <listitem>
+ check other worker-queues ('stealing' tasks from private worker queues
+ of other <emphasis>worker-threads</emphasis>) - requires locks
+ </listitem>
+ </itemizedlist>
+ <para>
+ For a lot of recursively queued tasks (so called <emphasis>sub-tasks</emphasis>),
+ the use of a worker-queue per thread substantially reduces the synchronization
+ necessary to complete the work. There are also fewer cache effects due to
+ sharing of the global-queue information.
+ </para>
+ <para>
+ Operations on the private worker queue are executed in LIFO order and operations
+ on worker queues of other <emphasis>worker-threads</emphasis> in FIFO order
+ (steals).
+ </para>
+ <itemizedlist>
+ <listitem>
+ There are chances that memory is still hot in the cache, if the tasks are
+ pushed in LIFO order into the private worker queue.
+ </listitem>
+ <listitem>
+ If a <emphasis>worker-thread</emphasis> steals work in FIFO order, increases
+ the chances that a larger 'chunk' of work will be stolen (the need for
+ other steals will be possibly reduced). Because the <emphasis>sub-tasks</emphasis>
+ are stored in LIFO order, the oldest items are closer to the <emphasis>public
+ end</emphasis> of the queue (forming a tree). Stealing such an older <code><phrase
+ role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase></code> also steals a (probably) larger
+ subtree of tasks unfolded if the stolen work item get executed. Since a
+ <emphasis>sub-task</emphasis> is just part of a larger <code><phrase role="identifier">boost</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">task</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">task</phrase></code>,
+ we don’t need to worry about execution order.
+ </listitem>
+ </itemizedlist>
+ </section>
+ <para>
+ / Copyright Oliver Kowalke 2009. Distributed under the Boost Software License,
+ Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
+ ]
+ </para>
+ <section id="boost_task.pool.forkjoin">
+ <title><link linkend="boost_task.pool.forkjoin"> Fork/Join</link></title>
+ <para>
+ Fork/Join algorithms are recursive divide-and-conquer algorithms which repeatedly
+ splitt into sub-tasks until they become small enough to solve using simple,
+ short sequential methods, so that they run in parallel on multiple cores.
+ </para>
+ <para>
+ The fork operation creates new <emphasis>sub-tasks</emphasis> which can run
+ in parallel. The current <code><phrase role="identifier">boost</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">task</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">task</phrase></code>
+ is not proceeded in the join operation until the forked <emphasis>sub-tasks</emphasis>
+ have completed. In the meantime the <emphasis>worker-thread</emphasis> executes
+ other tasks from its local worker-queue.
+ </para>
+ <para>
+
+<programlisting><phrase role="keyword">long</phrase> <phrase role="identifier">serial_fib</phrase><phrase role="special">(</phrase> <phrase role="keyword">long</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">2</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">serial_fib</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="identifier">serial_fib</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="keyword">long</phrase> <phrase role="identifier">parallel_fib</phrase><phrase role="special">(</phrase> <phrase role="keyword">long</phrase> <phrase role="identifier">n</phrase><phrase role="special">,</phrase> <phrase role="keyword">long</phrase> <phrase role="identifier">cutof</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">cutof</phrase><phrase role="special">)</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">serial_fib</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 sub-task calculating fibonacci(n-1)
+</phrase> <phrase role="identifier">h1</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">async</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">as_sub_task</phrase><phrase role="special">(),</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">make_task</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">parallel_fib</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="identifier">cutof</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase>
+ <phrase role="comment">// fork a sub-task calculating fibonacci(n-2)
+</phrase> <phrase role="identifier">h2</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">async</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">as_sub_task</phrase><phrase role="special">(),</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">make_task</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">parallel_fib</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="identifier">cutof</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase>
+ <phrase role="comment">// join the results of both sub-tasks
+</phrase> <phrase role="comment">// if one of the both sub-tasks is not ready
+</phrase> <phrase role="comment">// the worker-thread does not block, it executes other
+</phrase> <phrase role="comment">// task from its local-queue
+</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">h1</phrase><phrase role="special">.</phrase><phrase role="identifier">get</phrase><phrase role="special">()</phrase> <phrase role="special">+</phrase> <phrase role="identifier">h2</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">void</phrase> <phrase role="identifier">main</phrase><phrase role="special">()</phrase>
+<phrase role="special">{</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">handle</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">long</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">h</phrase><phrase role="special">(</phrase> <phrase role="comment">// handle for fibonacci calculation
+</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">async</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">default_pool</phrase><phrase role="special">(),</phrase> <phrase role="comment">// access the default thread-pool
+</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">make_task</phrase><phrase role="special">(</phrase> <phrase role="comment">// calculate fibonacci number 10
+</phrase> <phrase role="identifier">parallel_fib</phrase><phrase role="special">,</phrase> <phrase role="comment">// for numbers &lt; 5 do inline recursive calculation
+</phrase> <phrase role="number">10</phrase><phrase role="special">,</phrase>
+ <phrase role="number">5</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">cout</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">h</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="special">}</phrase>
+</programlisting>
+ </para>
+ </section>
+ </section>
+ <section id="boost_task.as_sub_task">
+ <title><link linkend="boost_task.as_sub_task"> Execute as sub-task</link></title>
+ <para>
+ <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">as_sub_task</phrase></code>
+ is a convenient way to execute a <emphasis>sub-task</emphasis>. If the parent
+ task is executed inside a <emphasis>thread-pool</emphasis> the <emphasis>sub-task</emphasis>
+ is put into the local-queue of the <emphasis>worker-thread</emphasis> in the
+ other case the <emphasis>sub-task</emphasis> will be executed in a new thread.
+ </para>
+ <para>
+
+<programlisting><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">handle</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">long</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">h</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">async</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">as_sub_task</phrase><phrase role="special">(),</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">make_task</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">fibonacci</phrase><phrase role="special">,</phrase>
+ <phrase role="number">10</phrase><phrase role="special">)</phrase> <phrase role="special">)</phrase> <phrase role="special">);</phrase>
+</programlisting>
+ </para>
+ <para>
+ is equivalent to:
+ </para>
+ <para>
+
+<programlisting><phrase role="keyword">if</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">runs_in_pool</phrase><phrase role="special">()</phrase> <phrase role="special">)</phrase>
+<phrase role="special">{</phrase>
+ <phrase role="comment">// put the sub-task into worker-threads local-queue
+</phrase><phrase role="special">}</phrase>
+<phrase role="keyword">else</phrase>
+<phrase role="special">{</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">async</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">new_thread</phrase><phrase role="special">(),</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">make_task</phrase><phrase role="special">(...)</phrase> <phrase role="special">);</phrase>
+<phrase role="special">}</phrase>
+</programlisting>
+ </para>
+ </section>
+ <section id="boost_task.utilities">
+ <title><link linkend="boost_task.utilities"> Utilities</link></title>
+ <para>
+ <emphasis role="bold">Boost.Task</emphasis> provides some free-functions which
+ can be used inside a <code><phrase role="identifier">boost</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase></code> to access some informations (like if
+ the <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase></code>
+ runs in a <emphasis>thread-pool</emphasis>).
+ </para>
+ <anchor id="boost_task.utilities.reschedule_until"/>
+ <bridgehead renderas="sect3">
+ <link linkend="boost_task.utilities.reschedule_until">reschedule_until</link>
+ </bridgehead>
+ <para>
+ 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">Pred</phrase> <phrase role="keyword">const</phrase><phrase
+ role="special">&amp;)</phrase></code> allows to synchronize the task with other
+ asynchronous events without blocking the <emphasis>worker-threads</emphasis>
+ (bool Pred::operator()() must not block). The current task will be rescheduled
+ until the passed predicate becomes true.
+ </para>
+ <anchor id="boost_task.utilities.get_pool"/>
+ <bridgehead renderas="sect3">
+ <link linkend="boost_task.utilities.get_pool">get_pool</link>
+ </bridgehead>
+ <para>
+ The pool in which the current code (<code><phrase role="identifier">boost</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase></code>) is executed 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_pool</phrase><phrase
+ role="special">()</phrase></code>. If hte code is not executed by a <emphasis>worker-thread</emphasis>
+ an assertion is raised.
+ </para>
+ <anchor id="boost_task.utilities.runs_in_pool"/>
+ <bridgehead renderas="sect3">
+ <link linkend="boost_task.utilities.runs_in_pool">runs_in_pool</link>
+ </bridgehead>
+ <para>
+ In order to check if the current code is executed in a <emphasis>thread-pool</emphasis>
+ <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">this_task</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">runs_in_pool</phrase><phrase role="special">()</phrase></code>
+ should be used.
+ </para>
+ <anchor id="boost_task.utilities.worker_id"/>
+ <bridgehead renderas="sect3">
+ <link linkend="boost_task.utilities.worker_id">worker_id</link>
+ </bridgehead>
+ <para>
+ <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">this_task</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">worker_id</phrase><phrase role="special">()</phrase></code>
+ returns the <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">thread</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">id</phrase></code> of the <emphasis>worker-thread</emphasis>
+ executing the current <code><phrase role="identifier">boost</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase></code>.
+ </para>
+ <anchor id="boost_task.utilities.delay"/>
+ <bridgehead renderas="sect3">
+ <link linkend="boost_task.utilities.delay">delay</link>
+ </bridgehead>
+ <para>
+ The execution of a <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase></code>
+ can be delayed for a time-duration or until a specific time-point with <code><phrase
+ role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">this_task</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">delay</phrase><phrase role="special">()</phrase></code>.
+ </para>
+ <anchor id="boost_task.utilities.yield"/>
+ <bridgehead renderas="sect3">
+ <link linkend="boost_task.utilities.yield">yield</link>
+ </bridgehead>
+ <para>
+ If a <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase></code>
+ detects that it would bould block it can yield itself with <code><phrase role="identifier">boost</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">this_task</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">yield</phrase><phrase role="special">()</phrase></code>
+ so that the <emphasis>worker-thread</emphasis> can execute another <code><phrase
+ role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">task</phrase></code> in
+ the meantime.
+ </para>
+ <anchor id="boost_task.utilities.interrupt"/>
+ <bridgehead renderas="sect3">
+ <link linkend="boost_task.utilities.interrupt">interrupt</link>
+ </bridgehead>
+ <para>
+ A <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase></code>
+ can interrupt itself via <code><phrase role="identifier">boost</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">this_task</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">interrupt</phrase><phrase
+ role="special">()</phrase></code>.
+ </para>
+ </section>
+ <section id="boost_task.meta_functions">
+ <title><link linkend="boost_task.meta_functions"> Meta functions</link></title>
+ <para>
+ If the <emphasis>thread-pool</emphasis> supports attributes (like priorities)
+ <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">has_attribute</phrase></code>
+ evaluates to <code><phrase role="keyword">true</phrase></code> at compile-time
+ (derived from boost::mpl::bool_). The type of the attribute is determined by
+ <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">attribute_type</phrase></code>.
+ </para>
+ <para>
+
+<programlisting><phrase role="identifier">typdef</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">static_pool</phrase><phrase role="special">&lt;</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</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">task</phrase><phrase role="special">::</phrase><phrase role="identifier">priority</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">int</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&gt;</phrase> <phrase role="comment">// pool with priority scheduling; integer as priority type
+</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">pool_type</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">std</phrase><phrase role="special">::</phrase><phrase role="identifier">boolalpha</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">has_attribute</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">pool_type</phrase> <phrase role="special">&gt;::</phrase><phrase role="identifier">value</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;\n&quot;</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="keyword">typeid</phrase><phrase role="special">(</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">task</phrase><phrase role="special">::</phrase><phrase role="identifier">attribute_type</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">pool_type</phrase> <phrase role="special">&gt;::</phrase><phrase role="identifier">type</phrase><phrase role="special">).</phrase><phrase role="identifier">name</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>
+</programlisting>
+ </para>
+ </section>
+ <section id="boost_task.reference">
+ <title><link linkend="boost_task.reference"> Reference</link></title>
+ <section id="boost_task.reference.task">
+ <title><link linkend="boost_task.reference.task"> Class template <code><phrase
+ role="identifier">task</phrase></code></link></title>
+ <para>
+
+<programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">task</phrase><phrase role="special">/</phrase><phrase role="identifier">task</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">R</phrase> <phrase role="special">&gt;</phrase>
+<phrase role="keyword">class</phrase> <phrase role="identifier">task</phrase>
+<phrase role="special">{</phrase>
+<phrase role="keyword">public</phrase><phrase role="special">:</phrase>
+ <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Fn</phrase> <phrase role="special">&gt;</phrase>
+ <phrase role="identifier">task</phrase><phrase role="special">(</phrase> <phrase role="identifier">Fn</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">fn</phrase><phrase role="special">);</phrase>
+
+ <phrase role="keyword">const</phrase> <phrase role="identifier">id</phrase> <phrase role="identifier">get_id</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase>
+
+ <phrase role="identifier">shared_future</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">R</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">get_future</phrase><phrase role="special">();</phrase>
+
+ <phrase role="keyword">void</phrase> <phrase role="identifier">swap</phrase><phrase role="special">(</phrase> <phrase role="identifier">task</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">R</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">other</phrase><phrase role="special">)</phrase> <phrase role="comment">// throw();
+</phrase>
+ <phrase role="keyword">void</phrase> <phrase role="keyword">operator</phrase><phrase role="special">()()</phrase> <phrase role="comment">// throw();
+</phrase><phrase role="special">}</phrase>
+</programlisting>
+ </para>
+ <section id="boost_task.reference.task.constructor">
+ <title><link linkend="boost_task.reference.task.constructor"> Constructor</link></title>
+
+<programlisting><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Fn</phrase> <phrase role="special">&gt;</phrase>
+<phrase role="identifier">task</phrase><phrase role="special">(</phrase> <phrase role="identifier">Fn</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">fn</phrase><phrase role="special">)</phrase>
+</programlisting>
+ <variablelist>
+ <title></title> <varlistentry><term>Effects:</term>
+ <listitem>
+ <para>
+ constructs a <code><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="identifier">R</phrase>
+ <phrase role="special">&gt;</phrase></code> from a function object
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Throws:</term>
+ <listitem>
+ <para>
+ Nothing
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ <section id="boost_task.reference.task.get_id">
+ <title><link linkend="boost_task.reference.task.get_id"> Member function
+ <code><phrase role="identifier">get_id</phrase><phrase role="special">()</phrase></code></link></title>
+
+<programlisting><phrase role="keyword">const</phrase> <phrase role="identifier">id</phrase> <phrase role="identifier">get_id</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase>
+</programlisting>
+ <variablelist>
+ <title></title> <varlistentry><term>Effects:</term>
+ <listitem>
+ <para>
+ returns task identifier
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Throws:</term>
+ <listitem>
+ <para>
+ Nothing
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ <section id="boost_task.reference.task.get_future">
+ <title><link linkend="boost_task.reference.task.get_future"> Member function
+ <code><phrase role="identifier">get_future</phrase><phrase role="special">()</phrase></code></link></title>
+
+<programlisting><phrase role="identifier">shared_future</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">R</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">get_future</phrase><phrase role="special">()</phrase>
+</programlisting>
+ <variablelist>
+ <title></title> <varlistentry><term>Effects:</term>
+ <listitem>
+ <para>
+ returns a future assiciated with the task
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Throws:</term>
+ <listitem>
+ <para>
+ ???
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ <section id="boost_task.reference.task.swap">
+ <title><link linkend="boost_task.reference.task.swap"> Member function <code><phrase
+ role="identifier">swap</phrase><phrase role="special">()</phrase></code></link></title>
+
+<programlisting><phrase role="keyword">void</phrase> <phrase role="identifier">swap</phrase><phrase role="special">(</phrase> <phrase role="identifier">task</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">R</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">other</phrase><phrase role="special">)</phrase>
+</programlisting>
+ <variablelist>
+ <title></title> <varlistentry><term>Effects:</term>
+ <listitem>
+ <para>
+ swaps the task
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Throws:</term>
+ <listitem>
+ <para>
+ Nothing
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ <section id="boost_task.reference.task.operator">
+ <title><link linkend="boost_task.reference.task.operator"> Member function
+ <code><phrase role="keyword">operator</phrase><phrase role="special">()()</phrase></code></link></title>
+
+<programlisting><phrase role="keyword">void</phrase> <phrase role="keyword">operator</phrase><phrase role="special">()()</phrase>
+</programlisting>
+ <variablelist>
+ <title></title> <varlistentry><term>Effects:</term>
+ <listitem>
+ <para>
+ executes tasks internal function object
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Throws:</term>
+ <listitem>
+ <para>
+ Nothing
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ </section>
+ <section id="boost_task.reference.handle">
+ <title><link linkend="boost_task.reference.handle"> Class template <code><phrase
+ role="identifier">handle</phrase></code></link></title>
+ <para>
+
+<programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">task</phrase><phrase role="special">/</phrase><phrase role="identifier">handle</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">R</phrase> <phrase role="special">&gt;</phrase>
+<phrase role="keyword">class</phrase> <phrase role="identifier">handle</phrase>
+<phrase role="special">{</phrase>
+ <phrase role="identifier">handle</phrase><phrase role="special">();</phrase>
+
+ <phrase role="keyword">const</phrase> <phrase role="identifier">id</phrase> <phrase role="identifier">get_id</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase>
+
+ <phrase role="keyword">void</phrase> <phrase role="identifier">interrupt</phrase><phrase role="special">();</phrase>
+
+ <phrase role="keyword">void</phrase> <phrase role="identifier">interrupt_and_wait</phrase><phrase role="special">();</phrase>
+
+ <phrase role="keyword">void</phrase> <phrase role="identifier">interrupt_and_wait_until</phrase><phrase role="special">(</phrase> <phrase role="identifier">system_time</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">abs_time</phrase><phrase role="special">);</phrase>
+
+ <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Duration</phrase> <phrase role="special">&gt;</phrase>
+ <phrase role="keyword">void</phrase> <phrase role="identifier">interrupt_and_wait_for</phrase><phrase role="special">(</phrase> <phrase role="identifier">Duration</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">rel_time</phrase><phrase role="special">);</phrase>
+
+ <phrase role="keyword">bool</phrase> <phrase role="identifier">interruption_requested</phrase><phrase role="special">();</phrase>
+
+ <phrase role="identifier">R</phrase> <phrase role="identifier">get</phrase><phrase role="special">();</phrase>
+
+ <phrase role="keyword">bool</phrase> <phrase role="identifier">is_ready</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase>
+
+ <phrase role="keyword">bool</phrase> <phrase role="identifier">has_value</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase>
+
+ <phrase role="keyword">bool</phrase> <phrase role="identifier">has_exception</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase>
+
+ <phrase role="keyword">void</phrase> <phrase role="identifier">wait</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase>
+
+ <phrase role="keyword">void</phrase> <phrase role="identifier">swap</phrase><phrase role="special">(</phrase> <phrase role="identifier">handle</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">R</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">other</phrase><phrase role="special">);</phrase>
+<phrase role="special">};</phrase>
+</programlisting>
+ </para>
+ <section id="boost_task.reference.handle.constructor">
+ <title><link linkend="boost_task.reference.handle.constructor"> Constructor</link></title>
+
+<programlisting><phrase role="identifier">handle</phrase><phrase role="special">()</phrase>
+</programlisting>
+ <variablelist>
+ <title></title> <varlistentry><term>Effects:</term>
+ <listitem>
+ <para>
+ constructs an empty (invalid) handle
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Throws:</term>
+ <listitem>
+ <para>
+ Nothing
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ <section id="boost_task.reference.handle.get_id">
+ <title><link linkend="boost_task.reference.handle.get_id"> Member function
+ <code><phrase role="identifier">get_id</phrase><phrase role="special">()</phrase></code></link></title>
+
+<programlisting><phrase role="keyword">const</phrase> <phrase role="identifier">id</phrase> <phrase role="identifier">get_id</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase>
+</programlisting>
+ <variablelist>
+ <title></title> <varlistentry><term>Effects:</term>
+ <listitem>
+ <para>
+ returns identifier of the associated task
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Throws:</term>
+ <listitem>
+ <para>
+ Nothing
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ <section id="boost_task.reference.handle.interruption_requested">
+ <title><link linkend="boost_task.reference.handle.interruption_requested">
+ Member function <code><phrase role="identifier">interruption_requested</phrase><phrase
+ role="special">()</phrase></code></link></title>
+<programlisting><phrase role="keyword">bool</phrase> <phrase role="identifier">interruption_requested</phrase><phrase role="special">()</phrase>
+</programlisting>
+ <variablelist>
+ <title></title> <varlistentry><term>Effects:</term>
+ <listitem>
+ <para>
+ checks if interruption is already requested
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Throws:</term>
+ <listitem>
+ <para>
+ Nothing
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ <section id="boost_task.reference.handle.interrupt">
+ <title><link linkend="boost_task.reference.handle.interrupt"> Member function
+ <code><phrase role="identifier">interrupt</phrase><phrase role="special">()</phrase></code></link></title>
+
+<programlisting><phrase role="keyword">void</phrase> <phrase role="identifier">interrupt</phrase><phrase role="special">()</phrase>
+</programlisting>
+ <variablelist>
+ <title></title> <varlistentry><term>Effects:</term>
+ <listitem>
+ <para>
+ requests task interruption; doesn not block (immediatly returns)
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Throws:</term>
+ <listitem>
+ <para>
+ ???
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ <section id="boost_task.reference.handle.interrupt_and_wait">
+ <title><link linkend="boost_task.reference.handle.interrupt_and_wait"> Member
+ function <code><phrase role="identifier">interrupt_and_wait</phrase><phrase
+ role="special">()</phrase></code></link></title>
+<programlisting><phrase role="keyword">void</phrase> <phrase role="identifier">interrupt_and_wait</phrase><phrase role="special">()</phrase>
+</programlisting>
+ <variablelist>
+ <title></title> <varlistentry><term>Effects:</term>
+ <listitem>
+ <para>
+ requests task interruption and blocks until worker-thread stops task
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Throws:</term>
+ <listitem>
+ <para>
+ ???
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ <section id="boost_task.reference.handle.interrupt_and_wait_until">
+ <title><link linkend="boost_task.reference.handle.interrupt_and_wait_until">
+ Member function <code><phrase role="identifier">interrupt_and_wait_until</phrase><phrase
+ role="special">()</phrase></code></link></title>
+<programlisting><phrase role="keyword">void</phrase> <phrase role="identifier">interrupt_and_wait_until</phrase><phrase role="special">(</phrase> <phrase role="identifier">system_time</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">abs_time</phrase><phrase role="special">)</phrase>
+</programlisting>
+ <variablelist>
+ <title></title> <varlistentry><term>Effects:</term>
+ <listitem>
+ <para>
+ requests task interruption and blocks until worker-thread stops task
+ or time-point elapsed
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Throws:</term>
+ <listitem>
+ <para>
+ ???
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ <section id="boost_task.reference.handle.interrupt_and_wait_for">
+ <title><link linkend="boost_task.reference.handle.interrupt_and_wait_for">
+ Member function <code><phrase role="identifier">interrupt_and_wait_for</phrase><phrase
+ role="special">()</phrase></code></link></title>
+<programlisting><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Duration</phrase> <phrase role="special">&gt;</phrase>
+<phrase role="keyword">void</phrase> <phrase role="identifier">interrupt_and_wait_for</phrase><phrase role="special">(</phrase> <phrase role="identifier">Duration</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">rel_time</phrase><phrase role="special">)</phrase>
+</programlisting>
+ <variablelist>
+ <title></title> <varlistentry><term>Effects:</term>
+ <listitem>
+ <para>
+ requests task interruption and blocks until worker-thread stops task
+ or time-duration elapsed
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Throws:</term>
+ <listitem>
+ <para>
+ ???
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ <section id="boost_task.reference.handle.get">
+ <title><link linkend="boost_task.reference.handle.get"> Member function
+ <code><phrase role="identifier">get</phrase><phrase role="special">()</phrase></code></link></title>
+
+<programlisting><phrase role="identifier">R</phrase> <phrase role="identifier">get</phrase><phrase role="special">()</phrase>
+</programlisting>
+ <variablelist>
+ <title></title> <varlistentry><term>Effects:</term>
+ <listitem>
+ <para>
+ requests the result
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Throws:</term>
+ <listitem>
+ <para>
+ task_interrupted, task_uninialized
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ <section id="boost_task.reference.handle.wait">
+ <title><link linkend="boost_task.reference.handle.wait"> Member function
+ <code><phrase role="identifier">wait</phrase><phrase role="special">()</phrase></code></link></title>
+
+<programlisting><phrase role="keyword">void</phrase> <phrase role="identifier">wait</phrase><phrase role="special">()</phrase>
+</programlisting>
+ <variablelist>
+ <title></title> <varlistentry><term>Effects:</term>
+ <listitem>
+ <para>
+ blocks caller until task is done
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Throws:</term>
+ <listitem>
+ <para>
+ task_interrupted, task_uninialized
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ <section id="boost_task.reference.handle.is_ready">
+ <title><link linkend="boost_task.reference.handle.is_ready"> Member function
+ <code><phrase role="identifier">is_ready</phrase><phrase role="special">()</phrase></code></link></title>
+
+<programlisting><phrase role="keyword">bool</phrase> <phrase role="identifier">is_ready</phrase><phrase role="special">()</phrase>
+</programlisting>
+ <variablelist>
+ <title></title> <varlistentry><term>Effects:</term>
+ <listitem>
+ <para>
+ checks if task is done
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Throws:</term>
+ <listitem>
+ <para>
+ Nothing
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ <section id="boost_task.reference.handle.has_value">
+ <title><link linkend="boost_task.reference.handle.has_value"> Member function
+ <code><phrase role="identifier">has_value</phrase><phrase role="special">()</phrase></code></link></title>
+
+<programlisting><phrase role="keyword">bool</phrase> <phrase role="identifier">has_value</phrase><phrase role="special">()</phrase>
+</programlisting>
+ <variablelist>
+ <title></title> <varlistentry><term>Effects:</term>
+ <listitem>
+ <para>
+ checks if task is done and a result value is set
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Throws:</term>
+ <listitem>
+ <para>
+ Nothing
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ <section id="boost_task.reference.handle.has_exception">
+ <title><link linkend="boost_task.reference.handle.has_exception"> Member
+ function <code><phrase role="identifier">has_exception</phrase><phrase role="special">()</phrase></code></link></title>
+
+<programlisting><phrase role="keyword">bool</phrase> <phrase role="identifier">has_exception</phrase><phrase role="special">()</phrase>
+</programlisting>
+ <variablelist>
+ <title></title> <varlistentry><term>Effects:</term>
+ <listitem>
+ <para>
+ checks if task is done and an exception is set
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Throws:</term>
+ <listitem>
+ <para>
+ Nothing
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ <section id="boost_task.reference.handle.swap">
+ <title><link linkend="boost_task.reference.handle.swap"> Member function
+ <code><phrase role="identifier">swap</phrase><phrase role="special">()</phrase></code></link></title>
+
+<programlisting><phrase role="keyword">void</phrase> <phrase role="identifier">swap</phrase><phrase role="special">(</phrase> <phrase role="identifier">handle</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">R</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">other</phrase><phrase role="special">)</phrase>
+</programlisting>
+ <variablelist>
+ <title></title> <varlistentry><term>Effects:</term>
+ <listitem>
+ <para>
+ swapps handle
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Throws:</term>
+ <listitem>
+ <para>
+ Nothing
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ </section>
+ <section id="boost_task.reference.async">
+ <title><link linkend="boost_task.reference.async"> Function <code><phrase role="identifier">async</phrase><phrase
+ role="special">()</phrase></code></link></title>
+ <section id="boost_task.reference.async.async_default">
+ <title><link linkend="boost_task.reference.async.async_default"> Templated
+ non-member function <code><phrase role="identifier">async</phrase><phrase
+ role="special">(</phrase> <phrase role="identifier">AE</phrase><phrase role="special">,</phrase>
+ <phrase role="identifier">task</phrase><phrase role="special">&lt;</phrase>
+ <phrase role="identifier">R</phrase> <phrase role="special">&gt;)</phrase></code></link></title>
+ <para>
+
+<programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">task</phrase><phrase role="special">/</phrase><phrase role="identifier">async</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">AE</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">R</phrase> <phrase role="special">&gt;</phrase>
+<phrase role="identifier">handle</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">R</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">async</phrase><phrase role="special">(</phrase> <phrase role="identifier">AE</phrase> <phrase role="identifier">ae</phrase><phrase role="special">,</phrase> <phrase role="identifier">task</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">R</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">t</phrase><phrase role="special">);</phrase>
+</programlisting>
+ </para>
+ <variablelist>
+ <title></title> <varlistentry><term>Effects:</term>
+ <listitem>
+ <para>
+ executes task in an asyncrounous executer and returns a handle associated
+ with the task
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Throws:</term>
+ <listitem>
+ <para>
+ Nothing
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ <section id="boost_task.reference.async.async_pool">
+ <title><link linkend="boost_task.reference.async.async_pool"> Templated non-member
+ function <code><phrase role="identifier">async</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">pool</phrase><phrase role="special">&lt;</phrase>
+ <phrase role="identifier">Channel</phrase> <phrase role="special">&gt;</phrase>
+ <phrase role="special">&amp;,</phrase> <phrase role="identifier">task</phrase><phrase
+ role="special">&lt;</phrase> <phrase role="identifier">R</phrase> <phrase
+ role="special">&gt;)</phrase></code></link></title>
+ <para>
+
+<programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">task</phrase><phrase role="special">/</phrase><phrase role="identifier">async</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">R</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Channel</phrase> <phrase role="special">&gt;</phrase>
+<phrase role="identifier">handle</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">R</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">async</phrase><phrase role="special">(</phrase> <phrase role="identifier">pool</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Channel</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">ae</phrase><phrase role="special">,</phrase> <phrase role="identifier">task</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">R</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">t</phrase><phrase role="special">);</phrase>
+</programlisting>
+ </para>
+ <variablelist>
+ <title></title> <varlistentry><term>Effects:</term>
+ <listitem>
+ <para>
+ executes task in a thread-pool and returns a handle associated with
+ the task
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Throws:</term>
+ <listitem>
+ <para>
+ Nothing
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ <section id="boost_task.reference.async.async_pool_attr">
+ <title><link linkend="boost_task.reference.async.async_pool_attr"> Templated
+ non-member function <code><phrase role="identifier">async</phrase><phrase
+ role="special">(</phrase> <phrase role="identifier">pool</phrase><phrase
+ role="special">&lt;</phrase> <phrase role="identifier">Channel</phrase>
+ <phrase role="special">&gt;</phrase> <phrase role="special">&amp;,</phrase>
+ <phrase role="identifier">task</phrase><phrase role="special">&lt;</phrase>
+ <phrase role="identifier">R</phrase> <phrase role="special">&gt;,</phrase>
+ <phrase role="identifier">Attr</phrase><phrase role="special">)</phrase></code></link></title>
+ <para>
+
+<programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">task</phrase><phrase role="special">/</phrase><phrase role="identifier">async</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">R</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Channel</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Attr</phrase> <phrase role="special">&gt;</phrase>
+<phrase role="identifier">handle</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">R</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">async</phrase><phrase role="special">(</phrase> <phrase role="identifier">pool</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Channel</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">ae</phrase><phrase role="special">,</phrase> <phrase role="identifier">task</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">R</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">t</phrase><phrase role="special">,</phrase> <phrase role="identifier">Attr</phrase> <phrase role="identifier">attr</phrase><phrase role="special">);</phrase>
+</programlisting>
+ </para>
+ <variablelist>
+ <title></title> <varlistentry><term>Effects:</term>
+ <listitem>
+ <para>
+ executes atrributed task in a thread-pool and returns a handle associated
+ with the task
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Throws:</term>
+ <listitem>
+ <para>
+ Nothing
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ </section>
+ <section id="boost_task.reference.own_thread">
+ <title><link linkend="boost_task.reference.own_thread"> Class <code><phrase
+ role="identifier">own_thread</phrase></code></link></title>
+ <para>
+
+<programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">task</phrase><phrase role="special">/</phrase><phrase role="identifier">async</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase>
+
+<phrase role="keyword">struct</phrase> <phrase role="identifier">own_thread</phrase>
+<phrase role="special">{</phrase>
+ <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">R</phrase> <phrase role="special">&gt;</phrase>
+ <phrase role="identifier">handle</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">R</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">operator</phrase><phrase role="special">()(</phrase> <phrase role="identifier">task</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">R</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">t</phrase><phrase role="special">);</phrase>
+<phrase role="special">};</phrase>
+</programlisting>
+ </para>
+ <section id="boost_task.reference.own_thread.operator">
+ <title><link linkend="boost_task.reference.own_thread.operator"> Member function
+ <code><phrase role="keyword">operator</phrase><phrase role="special">()(</phrase>
+ <phrase role="identifier">task</phrase><phrase role="special">&lt;</phrase>
+ <phrase role="identifier">R</phrase> <phrase role="special">&gt;</phrase>
+ <phrase role="identifier">t</phrase><phrase role="special">)</phrase></code></link></title>
+
+<programlisting><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">R</phrase> <phrase role="special">&gt;</phrase>
+<phrase role="identifier">handle</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">R</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">operator</phrase><phrase role="special">()(</phrase> <phrase role="identifier">task</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">R</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">t</phrase><phrase role="special">)</phrase>
+</programlisting>
+ <variablelist>
+ <title></title> <varlistentry><term>Effects:</term>
+ <listitem>
+ <para>
+ executes task in the current thread an returns an handle associated
+ with the task
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Throws:</term>
+ <listitem>
+ <para>
+ Nothing
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ </section>
+ <section id="boost_task.reference.new_thread">
+ <title><link linkend="boost_task.reference.new_thread"> Class <code><phrase
+ role="identifier">new_thread</phrase></code></link></title>
+ <para>
+
+<programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">task</phrase><phrase role="special">/</phrase><phrase role="identifier">async</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase>
+
+<phrase role="keyword">struct</phrase> <phrase role="identifier">new_thread</phrase>
+<phrase role="special">{</phrase>
+ <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">R</phrase> <phrase role="special">&gt;</phrase>
+ <phrase role="identifier">handle</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">R</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">operator</phrase><phrase role="special">()(</phrase> <phrase role="identifier">task</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">R</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">t</phrase><phrase role="special">);</phrase>
+<phrase role="special">};</phrase>
+</programlisting>
+ </para>
+ <section id="boost_task.reference.new_thread.operator">
+ <title><link linkend="boost_task.reference.new_thread.operator"> Member function
+ <code><phrase role="keyword">operator</phrase><phrase role="special">()(</phrase>
+ <phrase role="identifier">task</phrase><phrase role="special">&lt;</phrase>
+ <phrase role="identifier">R</phrase> <phrase role="special">&gt;</phrase>
+ <phrase role="identifier">t</phrase><phrase role="special">)</phrase></code></link></title>
+
+<programlisting><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">R</phrase> <phrase role="special">&gt;</phrase>
+<phrase role="identifier">handle</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">R</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">operator</phrase><phrase role="special">()(</phrase> <phrase role="identifier">task</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">R</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">t</phrase><phrase role="special">)</phrase>
+</programlisting>
+ <variablelist>
+ <title></title> <varlistentry><term>Effects:</term>
+ <listitem>
+ <para>
+ executes task in a new thread an returns an handle associated with
+ the task
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Throws:</term>
+ <listitem>
+ <para>
+ Nothing
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ </section>
+ <section id="boost_task.reference.static_pool">
+ <title><link linkend="boost_task.reference.static_pool"> Class template <code><phrase
+ role="identifier">static_pool</phrase></code></link></title>
+ <para>
+
+<programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">task</phrase><phrase role="special">/</phrase><phrase role="identifier">static_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">Channel</phrase> <phrase role="special">&gt;</phrase>
+<phrase role="keyword">class</phrase> <phrase role="identifier">static_pool</phrase> <phrase role="special">:</phrase> <phrase role="keyword">private</phrase> <phrase role="identifier">noncopyable</phrase>
+<phrase role="special">{</phrase>
+<phrase role="keyword">public</phrase><phrase role="special">:</phrase>
+ <phrase role="keyword">explicit</phrase> <phrase role="identifier">pool</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">poolsize</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">psize</phrase><phrase role="special">,</phrase>
+ <phrase role="identifier">posix_time</phrase><phrase role="special">::</phrase><phrase role="identifier">time_duration</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">asleep</phrase> <phrase role="special">=</phrase> <phrase role="identifier">posix_time</phrase><phrase role="special">::</phrase><phrase role="identifier">microseconds</phrase><phrase role="special">(</phrase> <phrase role="number">10</phrase><phrase role="special">),</phrase>
+ <phrase role="identifier">scanns</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">scns</phrase> <phrase role="special">=</phrase> <phrase role="identifier">scanns</phrase><phrase role="special">(</phrase> <phrase role="number">20</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase>
+
+ <phrase role="keyword">explicit</phrase> <phrase role="identifier">pool</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">poolsize</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">psize</phrase><phrase role="special">,</phrase>
+ <phrase role="identifier">high_watermark</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">hwm</phrase><phrase role="special">,</phrase>
+ <phrase role="identifier">low_watermark</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">lwm</phrase><phrase role="special">,</phrase>
+ <phrase role="identifier">posix_time</phrase><phrase role="special">::</phrase><phrase role="identifier">time_duration</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">asleep</phrase> <phrase role="special">=</phrase> <phrase role="identifier">posix_time</phrase><phrase role="special">::</phrase><phrase role="identifier">milliseconds</phrase><phrase role="special">(</phrase> <phrase role="number">100</phrase><phrase role="special">),</phrase>
+ <phrase role="identifier">scanns</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">scns</phrase> <phrase role="special">=</phrase> <phrase role="identifier">scanns</phrase><phrase role="special">(</phrase> <phrase role="number">20</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase>
+
+
+ <phrase role="keyword">explicit</phrase> <phrase role="identifier">pool</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">posix_time</phrase><phrase role="special">::</phrase><phrase role="identifier">time_duration</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">asleep</phrase> <phrase role="special">=</phrase> <phrase role="identifier">posix_time</phrase><phrase role="special">::</phrase><phrase role="identifier">microseconds</phrase><phrase role="special">(</phrase> <phrase role="number">10</phrase><phrase role="special">),</phrase>
+ <phrase role="identifier">scanns</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">scns</phrase> <phrase role="special">=</phrase> <phrase role="identifier">scanns</phrase><phrase role="special">(</phrase> <phrase role="number">20</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase>
+
+ <phrase role="keyword">explicit</phrase> <phrase role="identifier">pool</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">high_watermark</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">hwm</phrase><phrase role="special">,</phrase>
+ <phrase role="identifier">low_watermark</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">lwm</phrase><phrase role="special">,</phrase>
+ <phrase role="identifier">posix_time</phrase><phrase role="special">::</phrase><phrase role="identifier">time_duration</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">asleep</phrase> <phrase role="special">=</phrase> <phrase role="identifier">posix_time</phrase><phrase role="special">::</phrase><phrase role="identifier">milliseconds</phrase><phrase role="special">(</phrase> <phrase role="number">100</phrase><phrase role="special">),</phrase>
+ <phrase role="identifier">scanns</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">scns</phrase> <phrase role="special">=</phrase> <phrase role="identifier">scanns</phrase><phrase role="special">(</phrase> <phrase role="number">20</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase>
+
+ <phrase role="special">~</phrase><phrase role="identifier">static_pool</phrase><phrase role="special">();</phrase>
+
+ <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">size</phrase><phrase role="special">();</phrase>
+ <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">active</phrase><phrase role="special">();</phrase>
+ <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">idle</phrase><phrase role="special">();</phrase>
+
+ <phrase role="keyword">void</phrase> <phrase role="identifier">shutdown</phrase><phrase role="special">();</phrase>
+ <phrase role="keyword">void</phrase> <phrase role="identifier">shutdown_now</phrase><phrase role="special">();</phrase>
+
+ <phrase role="keyword">bool</phrase> <phrase role="identifier">closed</phrase><phrase role="special">();</phrase>
+ <phrase role="keyword">void</phrase> <phrase role="identifier">clear</phrase><phrase role="special">();</phrase>
+ <phrase role="keyword">bool</phrase> <phrase role="identifier">empty</phrase><phrase role="special">();</phrase>
+ <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">pending</phrase><phrase role="special">();</phrase>
+
+ <phrase role="keyword">const</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">upper_bound</phrase><phrase role="special">();</phrase>
+ <phrase role="keyword">void</phrase> <phrase role="identifier">upper_bound</phrase><phrase role="special">(</phrase> <phrase role="identifier">high_watermark</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">hwm</phrase><phrase role="special">);</phrase>
+ <phrase role="keyword">const</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">lower_bound</phrase><phrase role="special">();</phrase>
+ <phrase role="keyword">void</phrase> <phrase role="identifier">lower_bound</phrase><phrase role="special">(</phrase> <phrase role="identifier">low_watermark</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">lwm</phrase><phrase role="special">);</phrase>
+
+ <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">R</phrase> <phrase role="special">&gt;</phrase>
+ <phrase role="identifier">handle</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">R</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">submit</phrase><phrase role="special">(</phrase> <phrase role="identifier">task</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">R</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">t</phrase><phrase role="special">);</phrase>
+
+ <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">R</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Attr</phrase> <phrase role="special">&gt;</phrase>
+ <phrase role="identifier">handle</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">R</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">submit</phrase><phrase role="special">(</phrase> <phrase role="identifier">task</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">R</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">t</phrase><phrase role="special">,</phrase> <phrase role="identifier">Attr</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">attr</phrase><phrase role="special">);</phrase>
+<phrase role="special">};</phrase>
+</programlisting>
+ </para>
+ <section id="boost_task.reference.static_pool.constructor_unbounded_channel_hw">
+ <title><link linkend="boost_task.reference.static_pool.constructor_unbounded_channel_hw">
+ Constructor (unbounded channel)</link></title>
+<programlisting><phrase role="keyword">explicit</phrase> <phrase role="identifier">static_pool</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">posix_time</phrase><phrase role="special">::</phrase><phrase role="identifier">time_duration</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">asleep</phrase> <phrase role="special">=</phrase> <phrase role="identifier">posix_time</phrase><phrase role="special">::</phrase><phrase role="identifier">microseconds</phrase><phrase role="special">(</phrase> <phrase role="number">10</phrase><phrase role="special">),</phrase>
+ <phrase role="identifier">scanns</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">scns</phrase> <phrase role="special">=</phrase> <phrase role="identifier">scanns</phrase><phrase role="special">(</phrase> <phrase role="number">20</phrase><phrase role="special">)</phrase> <phrase role="special">)</phrase>
+</programlisting>
+ <variablelist>
+ <title></title> <varlistentry><term>Preconditions:</term>
+ <listitem>
+ <para>
+ operating system provides functionality for processor pining
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Effects:</term>
+ <listitem>
+ <para>
+ constructs a pool - for each processor a worker-thread is created and
+ bound to one processor - global-queue can queue an unlimited number
+ of tasks
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Throws:</term>
+ <listitem>
+ <para>
+ <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">invalid_scanns</phrase></code>, <code><phrase role="identifier">boost</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">task</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">invalid_timeduration</phrase></code>
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Notes:</term>
+ <listitem>
+ <para>
+ constructor has to be called if a unbounded-channel is used
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ <section id="boost_task.reference.static_pool.constructor_unbounded_channel">
+ <title><link linkend="boost_task.reference.static_pool.constructor_unbounded_channel">
+ Constructor (unbounded channel)</link></title>
+<programlisting><phrase role="keyword">explicit</phrase> <phrase role="identifier">static_pool</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">poolsize</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">psize</phrase><phrase role="special">,</phrase>
+ <phrase role="identifier">posix_time</phrase><phrase role="special">::</phrase><phrase role="identifier">time_duration</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">asleep</phrase> <phrase role="special">=</phrase> <phrase role="identifier">posix_time</phrase><phrase role="special">::</phrase><phrase role="identifier">microseconds</phrase><phrase role="special">(</phrase> <phrase role="number">10</phrase><phrase role="special">),</phrase>
+ <phrase role="identifier">scanns</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">scns</phrase> <phrase role="special">=</phrase> <phrase role="identifier">scanns</phrase><phrase role="special">(</phrase> <phrase role="number">20</phrase><phrase role="special">)</phrase> <phrase role="special">)</phrase>
+</programlisting>
+ <variablelist>
+ <title></title> <varlistentry><term>Effects:</term>
+ <listitem>
+ <para>
+ constructs a pool containing psize worker-threads - global-queue can
+ queue an unlimited number of tasks
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Throws:</term>
+ <listitem>
+ <para>
+ <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">invalid_scanns</phrase></code>, <code><phrase role="identifier">boost</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">task</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">invalid_timeduration</phrase></code>
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Notes:</term>
+ <listitem>
+ <para>
+ constructor has to be called if a unbounded-channel is used
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ <section id="boost_task.reference.static_pool.constructor_bounded_channel_hw">
+ <title><link linkend="boost_task.reference.static_pool.constructor_bounded_channel_hw">
+ Constructor (bounded channel)</link></title>
+<programlisting><phrase role="keyword">explicit</phrase> <phrase role="identifier">static_pool</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">high_watermark</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">hwm</phrase><phrase role="special">,</phrase>
+ <phrase role="identifier">low_watermark</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">lwm</phrase><phrase role="special">,</phrase>
+ <phrase role="identifier">posix_time</phrase><phrase role="special">::</phrase><phrase role="identifier">time_duration</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">asleep</phrase> <phrase role="special">=</phrase> <phrase role="identifier">posix_time</phrase><phrase role="special">::</phrase><phrase role="identifier">milliseconds</phrase><phrase role="special">(</phrase> <phrase role="number">100</phrase><phrase role="special">),</phrase>
+ <phrase role="identifier">scanns</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">scns</phrase> <phrase role="special">=</phrase> <phrase role="identifier">scanns</phrase><phrase role="special">(</phrase> <phrase role="number">20</phrase><phrase role="special">)</phrase> <phrase role="special">)</phrase>
+</programlisting>
+ <variablelist>
+ <title></title> <varlistentry><term>Preconditions:</term>
+ <listitem>
+ <para>
+ operating system provides functionality for processor pining
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Effects:</term>
+ <listitem>
+ <para>
+ constructs a pool - for each processor a worker-thread is created and
+ bound to one processor - global-queue can only queue a limited number
+ of tasks
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Throws:</term>
+ <listitem>
+ <para>
+ <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">invalid_scanns</phrase></code>, <code><phrase role="identifier">boost</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">task</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">invalid_timeduration</phrase></code>,
+ <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">invalid_watermark</phrase></code>
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Notes:</term>
+ <listitem>
+ <para>
+ Constructor has to be called if a bounded-channel is used.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ <section id="boost_task.reference.static_pool.constructor_bounded_channel">
+ <title><link linkend="boost_task.reference.static_pool.constructor_bounded_channel">
+ Constructor (bounded channel)</link></title>
+<programlisting><phrase role="keyword">explicit</phrase> <phrase role="identifier">static_pool</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">poolsize</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">psize</phrase><phrase role="special">,</phrase>
+ <phrase role="identifier">high_watermark</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">hwm</phrase><phrase role="special">,</phrase>
+ <phrase role="identifier">low_watermark</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">lwm</phrase><phrase role="special">,</phrase>
+ <phrase role="identifier">posix_time</phrase><phrase role="special">::</phrase><phrase role="identifier">time_duration</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">asleep</phrase> <phrase role="special">=</phrase> <phrase role="identifier">posix_time</phrase><phrase role="special">::</phrase><phrase role="identifier">milliseconds</phrase><phrase role="special">(</phrase> <phrase role="number">100</phrase><phrase role="special">),</phrase>
+ <phrase role="identifier">scanns</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">scns</phrase> <phrase role="special">=</phrase> <phrase role="identifier">scanns</phrase><phrase role="special">(</phrase> <phrase role="number">20</phrase><phrase role="special">)</phrase> <phrase role="special">)</phrase>
+</programlisting>
+ <variablelist>
+ <title></title> <varlistentry><term>Effects:</term>
+ <listitem>
+ <para>
+ constructs a pool containing psize worker-threads - global-queue can
+ only queue a limited number of tasks
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Throws:</term>
+ <listitem>
+ <para>
+ <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">invalid_scanns</phrase></code>, <code><phrase role="identifier">boost</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">task</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">invalid_timeduration</phrase></code>,
+ <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">invalid_watermark</phrase></code>
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Notes:</term>
+ <listitem>
+ <para>
+ constructor has to be called if a bounded-channel is used
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ <section id="boost_task.reference.static_pool.destructor">
+ <title><link linkend="boost_task.reference.static_pool.destructor"> Destructor</link></title>
+
+<programlisting><phrase role="special">~</phrase><phrase role="identifier">static_pool</phrase><phrase role="special">()</phrase>
+</programlisting>
+ <variablelist>
+ <title></title> <varlistentry><term>Effects:</term>
+ <listitem>
+ <para>
+ calls <code><phrase role="special">:</phrase><phrase role="identifier">shutdown</phrase><phrase
+ role="special">()</phrase></code> if not already called
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Throws:</term>
+ <listitem>
+ <para>
+ Nothing
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ <section id="boost_task.reference.static_pool.size">
+ <title><link linkend="boost_task.reference.static_pool.size"> Member function
+ <code><phrase role="identifier">size</phrase><phrase role="special">()</phrase></code></link></title>
+
+<programlisting><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">size</phrase><phrase role="special">()</phrase>
+</programlisting>
+ <variablelist>
+ <title></title> <varlistentry><term>Effects:</term>
+ <listitem>
+ <para>
+ returns how many worker-threads are running in the pool
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Throws:</term>
+ <listitem>
+ <para>
+ Nothing
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ <section id="boost_task.reference.static_pool.active">
+ <title><link linkend="boost_task.reference.static_pool.active"> Member function
+ <code><phrase role="identifier">active</phrase><phrase role="special">()</phrase></code></link></title>
+
+<programlisting><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">active</phrase><phrase role="special">()</phrase>
+</programlisting>
+ <variablelist>
+ <title></title> <varlistentry><term>Effects:</term>
+ <listitem>
+ <para>
+ returns how many worker-threads are active (executing an task)
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Throws:</term>
+ <listitem>
+ <para>
+ Nothing
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ <section id="boost_task.reference.static_pool.idle">
+ <title><link linkend="boost_task.reference.static_pool.idle"> Member function
+ <code><phrase role="identifier">idle</phrase><phrase role="special">()</phrase></code></link></title>
+
+<programlisting><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">idle</phrase><phrase role="special">()</phrase>
+</programlisting>
+ <variablelist>
+ <title></title> <varlistentry><term>Effects:</term>
+ <listitem>
+ <para>
+ returns how many worker-threads are idle (not executing an task).
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Throws:</term>
+ <listitem>
+ <para>
+ Nothing
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Notes:</term>
+ <listitem>
+ <para>
+ The value is the difference of <code><phrase role="identifier">size</phrase><phrase
+ role="special">()</phrase></code> and <code><phrase role="identifier">active</phrase><phrase
+ role="special">()</phrase></code>
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ <section id="boost_task.reference.static_pool.shutdown">
+ <title><link linkend="boost_task.reference.static_pool.shutdown"> Member
+ function <code><phrase role="identifier">shutdown</phrase><phrase role="special">()</phrase></code></link></title>
+
+<programlisting><phrase role="keyword">void</phrase> <phrase role="identifier">shutdown</phrase><phrase role="special">()</phrase>
+</programlisting>
+ <variablelist>
+ <title></title> <varlistentry><term>Effects:</term>
+ <listitem>
+ <para>
+ deactivates the channel and joins all worker-threads - the pool is
+ closed
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Throws:</term>
+ <listitem>
+ <para>
+ Nothing
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Notes:</term>
+ <listitem>
+ <para>
+ all pending tasks are processed
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ <section id="boost_task.reference.static_pool.shutdown_now">
+ <title><link linkend="boost_task.reference.static_pool.shutdown_now"> Member
+ function <code><phrase role="identifier">shutdown_now</phrase><phrase role="special">()</phrase></code></link></title>
+
+<programlisting><phrase role="keyword">void</phrase> <phrase role="identifier">shutdown_now</phrase><phrase role="special">()</phrase>
+</programlisting>
+ <variablelist>
+ <title></title> <varlistentry><term>Effects:</term>
+ <listitem>
+ <para>
+ deactivates the channel, send interruption request to all worker-threads
+ and joins them - the pool is closed
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Throws:</term>
+ <listitem>
+ <para>
+ Nothing
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Notes:</term>
+ <listitem>
+ <para>
+ pending tasks are not processed but returned
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ <section id="boost_task.reference.static_pool.losed">
+ <title><link linkend="boost_task.reference.static_pool.losed"> Member function
+ <code><phrase role="identifier">closed</phrase><phrase role="special">()</phrase></code></link></title>
+
+<programlisting><phrase role="keyword">bool</phrase> <phrase role="identifier">closed</phrase><phrase role="special">()</phrase>
+</programlisting>
+ <variablelist>
+ <title></title> <varlistentry><term>Effects:</term>
+ <listitem>
+ <para>
+ queries if the pool is closed (pool is shutdown)
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Throws:</term>
+ <listitem>
+ <para>
+ Nothing
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ <section id="boost_task.reference.static_pool.clear">
+ <title><link linkend="boost_task.reference.static_pool.clear"> Member function
+ <code><phrase role="identifier">clear</phrase><phrase role="special">()</phrase></code></link></title>
+
+<programlisting><phrase role="keyword">void</phrase> <phrase role="identifier">clear</phrase><phrase role="special">()</phrase>
+</programlisting>
+ <variablelist>
+ <title></title> <varlistentry><term>Effects:</term>
+ <listitem>
+ <para>
+ removes all pending tasks from the channel
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Throws:</term>
+ <listitem>
+ <para>
+ Nothing
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ <section id="boost_task.reference.static_pool.empty">
+ <title><link linkend="boost_task.reference.static_pool.empty"> Member function
+ <code><phrase role="identifier">empty</phrase><phrase role="special">()</phrase></code></link></title>
+
+<programlisting><phrase role="keyword">bool</phrase> <phrase role="identifier">empty</phrase><phrase role="special">()</phrase>
+</programlisting>
+ <variablelist>
+ <title></title> <varlistentry><term>Effects:</term>
+ <listitem>
+ <para>
+ queries if the channel is empty
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Throws:</term>
+ <listitem>
+ <para>
+ Nothing
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ <section id="boost_task.reference.static_pool.pending">
+ <title><link linkend="boost_task.reference.static_pool.pending"> Member function
+ <code><phrase role="identifier">pending</phrase><phrase role="special">()</phrase></code></link></title>
+
+<programlisting><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">pending</phrase><phrase role="special">()</phrase>
+</programlisting>
+ <variablelist>
+ <title></title> <varlistentry><term>Effects:</term>
+ <listitem>
+ <para>
+ queries how many tasks are pending (still unprocessed) in the global-queue
+ (channel)
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Throws:</term>
+ <listitem>
+ <para>
+ Nothing
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ <section id="boost_task.reference.static_pool.get_upper_bound">
+ <title><link linkend="boost_task.reference.static_pool.get_upper_bound">
+ Member function <code><phrase role="identifier">upper_bound</phrase><phrase
+ role="special">()</phrase></code></link></title>
+<programlisting><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">upper_bound</phrase><phrase role="special">()</phrase>
+</programlisting>
+ <variablelist>
+ <title></title> <varlistentry><term>Preconditions:</term>
+ <listitem>
+ <para>
+ channel is of type bounded-channel
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Effects:</term>
+ <listitem>
+ <para>
+ returns the upper bound of the bounded-channel
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Throws:</term>
+ <listitem>
+ <para>
+ Nothing
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Notes:</term>
+ <listitem>
+ <para>
+ can only be used if a bounded-channel is used
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ <section id="boost_task.reference.static_pool.set_upper_bound">
+ <title><link linkend="boost_task.reference.static_pool.set_upper_bound">
+ Member function <code><phrase role="identifier">upper_bound</phrase><phrase
+ role="special">(</phrase> <phrase role="identifier">high_watermark</phrase>
+ <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase>
+ <phrase role="identifier">hwm</phrase><phrase role="special">)</phrase></code></link></title>
+
+<programlisting><phrase role="keyword">void</phrase> <phrase role="identifier">upper_bound</phrase><phrase role="special">(</phrase> <phrase role="identifier">high_watermark</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">hwm</phrase><phrase role="special">)</phrase>
+</programlisting>
+ <variablelist>
+ <title></title> <varlistentry><term>Preconditions:</term>
+ <listitem>
+ <para>
+ channel is of type bounded-channel
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Effects:</term>
+ <listitem>
+ <para>
+ sets the upper bound of the bounded-channel
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Postconditions:</term>
+ <listitem>
+ <para>
+ <code><phrase role="keyword">this</phrase><phrase role="special">-&gt;</phrase><phrase
+ role="identifier">upper_bound</phrase><phrase role="special">()</phrase>
+ <phrase role="special">==</phrase> <phrase role="identifier">hwm</phrase></code>
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Throws:</term>
+ <listitem>
+ <para>
+ <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">invalid_watermark</phrase></code>
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Notes:</term>
+ <listitem>
+ <para>
+ can only be used if a bounded-channel is used
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ <section id="boost_task.reference.static_pool.get_lower_bound">
+ <title><link linkend="boost_task.reference.static_pool.get_lower_bound">
+ Member function <code><phrase role="identifier">lower_bound</phrase><phrase
+ role="special">()</phrase></code></link></title>
+<programlisting><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">lower_bound</phrase><phrase role="special">();</phrase>
+</programlisting>
+ <variablelist>
+ <title></title> <varlistentry><term>Preconditions:</term>
+ <listitem>
+ <para>
+ channel is of type bounded-channel
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Effects:</term>
+ <listitem>
+ <para>
+ returns the lower bound of the bounded-channel
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Throws:</term>
+ <listitem>
+ <para>
+ Nothing
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Notes:</term>
+ <listitem>
+ <para>
+ can only be used if a bounded-channel is used
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ <section id="boost_task.reference.static_pool.set_lower_bound">
+ <title><link linkend="boost_task.reference.static_pool.set_lower_bound">
+ Member function <code><phrase role="identifier">lower_bound</phrase><phrase
+ role="special">(</phrase> <phrase role="identifier">low_watermark</phrase>
+ <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase>
+ <phrase role="identifier">lwm</phrase><phrase role="special">)</phrase></code></link></title>
+
+<programlisting><phrase role="keyword">void</phrase> <phrase role="identifier">lower_bound</phrase><phrase role="special">(</phrase> <phrase role="identifier">low_watermark</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">lwm</phrase><phrase role="special">)</phrase>
+</programlisting>
+ <variablelist>
+ <title></title> <varlistentry><term>Preconditions:</term>
+ <listitem>
+ <para>
+ channel is of type bounded-channel
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Effects:</term>
+ <listitem>
+ <para>
+ sets the lower bound of the bounded-channel
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Postconditions:</term>
+ <listitem>
+ <para>
+ <code><phrase role="keyword">this</phrase><phrase role="special">-&gt;</phrase><phrase
+ role="identifier">lower_bound</phrase><phrase role="special">()</phrase>
+ <phrase role="special">==</phrase> <phrase role="identifier">lwm</phrase></code>
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Throws:</term>
+ <listitem>
+ <para>
+ <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">invalid_watermark</phrase></code>
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Notes:</term>
+ <listitem>
+ <para>
+ can only be used if a bounded-channel is used
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ <section id="boost_task.reference.static_pool.submit">
+ <title><link linkend="boost_task.reference.static_pool.submit"> Member function
+ <code><phrase role="identifier">submit</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">Act</phrase> <phrase role="keyword">const</phrase><phrase
+ role="special">&amp;</phrase> <phrase role="identifier">act</phrase><phrase
+ role="special">)</phrase></code></link></title>
+<programlisting><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">R</phrase> <phrase role="special">&gt;</phrase>
+<phrase role="identifier">handle</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">R</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">submit</phrase><phrase role="special">(</phrase> <phrase role="identifier">task</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> <phrase role="identifier">t</phrase><phrase role="special">)</phrase>
+</programlisting>
+ <variablelist>
+ <title></title> <varlistentry><term>Preconditions:</term>
+ <listitem>
+ <para>
+ has_attribute&lt; pool &gt;::value == false &amp;&amp; ! closed()
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Effects:</term>
+ <listitem>
+ <para>
+ submits an task to the pool and returns an associated handle
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Throws:</term>
+ <listitem>
+ <para>
+ <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task_rejected</phrase></code>
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ <section id="boost_task.reference.static_pool.submit_attr">
+ <title><link linkend="boost_task.reference.static_pool.submit_attr"> Member
+ function <code><phrase role="identifier">submit</phrase><phrase role="special">(</phrase>
+ <phrase role="identifier">Act</phrase> <phrase role="keyword">const</phrase><phrase
+ role="special">&amp;</phrase> <phrase role="identifier">act</phrase><phrase
+ role="special">,</phrase> <phrase role="identifier">Attr</phrase> <phrase
+ role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase
+ role="identifier">attr</phrase><phrase role="special">)</phrase></code></link></title>
+
+<programlisting><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">R</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Attr</phrase> <phrase role="special">&gt;</phrase>
+<phrase role="identifier">handle</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">R</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">submit</phrase><phrase role="special">(</phrase> <phrase role="identifier">task</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> <phrase role="identifier">t</phrase><phrase role="special">,</phrase> <phrase role="identifier">Attr</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">attr</phrase><phrase role="special">)</phrase>
+</programlisting>
+ <variablelist>
+ <title></title> <varlistentry><term>Preconditions:</term>
+ <listitem>
+ <para>
+ has_attribute&lt; pool &gt;::value == true &amp;&amp; ! closed()
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Effects:</term>
+ <listitem>
+ <para>
+ submits an task to the pool and returns an associated handle - task
+ is scheduled by the attribute
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Throws:</term>
+ <listitem>
+ <para>
+ <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task_rejected</phrase></code>
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ </section>
+ <section id="boost_task.reference.utility">
+ <title><link linkend="boost_task.reference.utility"> Utilities</link></title>
+ <section id="boost_task.reference.utility.reschedule_until">
+ <title><link linkend="boost_task.reference.utility.reschedule_until"> Non-member
+ function <code><phrase role="identifier">reschedule_until</phrase><phrase
+ role="special">()</phrase></code></link></title>
+ <para>
+
+<programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">task</phrase><phrase role="special">/</phrase><phrase role="identifier">utility</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">Pred</phrase> <phrase role="special">&gt;</phrase>
+<phrase role="keyword">void</phrase> <phrase role="identifier">reschedule_until</phrase><phrase role="special">(</phrase> <phrase role="identifier">Pred</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;)</phrase>
+</programlisting>
+ </para>
+ <variablelist>
+ <title></title> <varlistentry><term>Effects:</term>
+ <listitem>
+ <para>
+ reschedules current task until passed callable predicate 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_task.reference.utility.get_pool">
+ <title><link linkend="boost_task.reference.utility.get_pool"> Non-member
+ function <code><phrase role="identifier">get_pool</phrase><phrase role="special">()</phrase></code></link></title>
+ <para>
+
+<programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">task</phrase><phrase role="special">/</phrase><phrase role="identifier">utility</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">&gt;</phrase>
+<phrase role="identifier">Pool</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">get_pool</phrase><phrase role="special">()</phrase>
+</programlisting>
+ </para>
+ <variablelist>
+ <title></title> <varlistentry><term>Effects:</term>
+ <listitem>
+ <para>
+ returns reference to the thread-pool where the current worker thread
+ is executed
+ </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_task.reference.utility.runs_in_pool">
+ <title><link linkend="boost_task.reference.utility.runs_in_pool"> Non-member
+ function <code><phrase role="identifier">runs_in_pool</phrase><phrase role="special">()</phrase></code></link></title>
+ <para>
+
+<programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">task</phrase><phrase role="special">/</phrase><phrase role="identifier">utility</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase>
+
+<phrase role="keyword">bool</phrase> <phrase role="identifier">runs_in_pool</phrase><phrase role="special">()</phrase>
+</programlisting>
+ </para>
+ <variablelist>
+ <title></title> <varlistentry><term>Effects:</term>
+ <listitem>
+ <para>
+ returns true if the current task is executed in a thread-pool
+ </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_task.reference.utility.worker_id">
+ <title><link linkend="boost_task.reference.utility.worker_id"> Non-member
+ function <code><phrase role="identifier">worker_id</phrase><phrase role="special">()</phrase></code></link></title>
+ <para>
+
+<programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">task</phrase><phrase role="special">/</phrase><phrase role="identifier">utility</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase>
+
+<phrase role="identifier">id</phrase> <phrase role="identifier">worker_id</phrase><phrase role="special">()</phrase>
+</programlisting>
+ </para>
+ <variablelist>
+ <title></title> <varlistentry><term>Effects:</term>
+ <listitem>
+ <para>
+ returns returns the thread-id of the worker-thread
+ </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_task.reference.utility.delay">
+ <title><link linkend="boost_task.reference.utility.delay"> Non-member function
+ <code><phrase role="identifier">delay</phrase><phrase role="special">()</phrase></code></link></title>
+ <para>
+
+<programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">task</phrase><phrase role="special">/</phrase><phrase role="identifier">utility</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase>
+
+<phrase role="keyword">void</phrase> <phrase role="identifier">delay</phrase><phrase role="special">(</phrase> <phrase role="identifier">system_time</phrase> <phrase role="identifier">abs_time</phrase><phrase role="special">)</phrase>
+
+<phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Duration</phrase> <phrase role="special">&gt;</phrase>
+<phrase role="keyword">void</phrase> <phrase role="identifier">delay</phrase><phrase role="special">(</phrase> <phrase role="identifier">Duration</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">rel_time</phrase><phrase role="special">)</phrase>
+</programlisting>
+ </para>
+ <variablelist>
+ <title></title> <varlistentry><term>Effects:</term>
+ <listitem>
+ <para>
+ delays the execution of the current task so that the worker-thread
+ can process another task in the meantime
+ </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_task.reference.utility.yield">
+ <title><link linkend="boost_task.reference.utility.yield"> Non-member function
+ <code><phrase role="identifier">yield</phrase><phrase role="special">()</phrase></code></link></title>
+ <para>
+
+<programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">task</phrase><phrase role="special">/</phrase><phrase role="identifier">utility</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase>
+
+<phrase role="keyword">void</phrase> <phrase role="identifier">yield</phrase><phrase role="special">()</phrase>
+</programlisting>
+ </para>
+ <variablelist>
+ <title></title> <varlistentry><term>Effects:</term>
+ <listitem>
+ <para>
+ yields the current task so that the worker-threadcan process another
+ task in the meantime
+ </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_task.reference.utility.interrupt">
+ <title><link linkend="boost_task.reference.utility.interrupt"> Non-member
+ function <code><phrase role="identifier">interrupt</phrase><phrase role="special">()</phrase></code></link></title>
+ <para>
+
+<programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">task</phrase><phrase role="special">/</phrase><phrase role="identifier">utility</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase>
+
+<phrase role="keyword">void</phrase> <phrase role="identifier">interrupt</phrase><phrase role="special">()</phrase>
+</programlisting>
+ </para>
+ <variablelist>
+ <title></title> <varlistentry><term>Effects:</term>
+ <listitem>
+ <para>
+ task can request interruption for itself
+ </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>
+ <section id="boost_task.reference.has_attribute">
+ <title><link linkend="boost_task.reference.has_attribute"> Meta function <code><phrase
+ role="identifier">has_attribute</phrase></code></link></title>
+ <para>
+
+<programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">task</phrase><phrase role="special">/</phrase><phrase role="identifier">meta</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">&gt;</phrase>
+<phrase role="keyword">struct</phrase> <phrase role="identifier">has_attribute</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <phrase role="identifier">mpl</phrase><phrase role="special">::</phrase><phrase role="identifier">bool_</phrase><phrase role="special">&lt;</phrase>
+ <phrase role="identifier">is_same</phrase><phrase role="special">&lt;</phrase>
+ <phrase role="identifier">detail</phrase><phrase role="special">::</phrase><phrase role="identifier">has_priority</phrase><phrase role="special">,</phrase>
+ <phrase role="keyword">typename</phrase> <phrase role="identifier">Pool</phrase><phrase role="special">::</phrase><phrase role="identifier">scheduler_type</phrase><phrase role="special">::</phrase><phrase role="identifier">priority_tag_type</phrase>
+ <phrase role="special">&gt;::</phrase><phrase role="identifier">value</phrase>
+<phrase role="special">&gt;</phrase>
+<phrase role="special">{};</phrase>
+</programlisting>
+ </para>
+ </section>
+ <section id="boost_task.reference.attribute_type">
+ <title><link linkend="boost_task.reference.attribute_type"> Meta function
+ <code><phrase role="identifier">attribute_type</phrase></code></link></title>
+ <para>
+
+<programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">task</phrase><phrase role="special">/</phrase><phrase role="identifier">meta</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">&gt;</phrase>
+<phrase role="keyword">struct</phrase> <phrase role="identifier">attribute_type</phrase>
+<phrase role="special">{</phrase>
+ <phrase role="keyword">typedef</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Pool</phrase><phrase role="special">::</phrase><phrase role="identifier">scheduler_type</phrase><phrase role="special">::</phrase><phrase role="identifier">attribute_type</phrase> <phrase role="identifier">type</phrase><phrase role="special">;</phrase>
+<phrase role="special">};</phrase>
+</programlisting>
+ </para>
+ </section>
+ <section id="boost_task.reference.invalid_poolsize">
+ <title><link linkend="boost_task.reference.invalid_poolsize"> Class <code><phrase
+ role="identifier">invalid_poolsize</phrase></code></link></title>
+ <para>
+
+<programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">task</phrase><phrase role="special">/</phrase><phrase role="identifier">exceptions</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase>
+
+<phrase role="keyword">class</phrase> <phrase role="identifier">invalid_poolsize</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">invalid_argument</phrase>
+<phrase role="special">{</phrase>
+<phrase role="keyword">public</phrase><phrase role="special">:</phrase>
+ <phrase role="identifier">invalid_poolsize</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">msg</phrase><phrase role="special">);</phrase>
+<phrase role="special">};</phrase>
+</programlisting>
+ </para>
+ <section id="boost_task.reference.invalid_poolsize.constructor">
+ <title><link linkend="boost_task.reference.invalid_poolsize.constructor">
+ Constructor</link></title>
+<programlisting><phrase role="identifier">invalid_poolsize</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">msg</phrase><phrase role="special">);</phrase>
+</programlisting>
+ <variablelist>
+ <title></title> <varlistentry><term>Effects:</term>
+ <listitem>
+ <para>
+ Constructs a <code><phrase role="identifier">boost</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">task</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">invalid_poolsize</phrase></code>
+ instance.
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Throws:</term>
+ <listitem>
+ <para>
+ Nothing
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ </section>
+ <section id="boost_task.reference.invalid_scanns">
+ <title><link linkend="boost_task.reference.invalid_scanns"> Class <code><phrase
+ role="identifier">invalid_scanns</phrase></code></link></title>
+ <para>
+
+<programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">task</phrase><phrase role="special">/</phrase><phrase role="identifier">exceptions</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase>
+
+<phrase role="keyword">class</phrase> <phrase role="identifier">invalid_scanns</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">invalid_argument</phrase>
+<phrase role="special">{</phrase>
+<phrase role="keyword">public</phrase><phrase role="special">:</phrase>
+ <phrase role="identifier">invalid_scanns</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">msg</phrase><phrase role="special">);</phrase>
+<phrase role="special">};</phrase>
+</programlisting>
+ </para>
+ <section id="boost_task.reference.invalid_scanns.constructor">
+ <title><link linkend="boost_task.reference.invalid_scanns.constructor"> Constructor</link></title>
+
+<programlisting><phrase role="identifier">invalid_scanns</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">msg</phrase><phrase role="special">)</phrase>
+</programlisting>
+ <variablelist>
+ <title></title> <varlistentry><term>Effects:</term>
+ <listitem>
+ <para>
+ Constructs a <code><phrase role="identifier">boost</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">task</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">invalid_scanns</phrase></code>
+ instance.
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Throws:</term>
+ <listitem>
+ <para>
+ Nothing
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ </section>
+ <section id="boost_task.reference.invalid_timeduration">
+ <title><link linkend="boost_task.reference.invalid_timeduration"> Class <code><phrase
+ role="identifier">invalid_timeduration</phrase></code></link></title>
+ <para>
+
+<programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">task</phrase><phrase role="special">/</phrase><phrase role="identifier">exceptions</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase>
+
+<phrase role="keyword">class</phrase> <phrase role="identifier">invalid_timeduration</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">invalid_argument</phrase>
+<phrase role="special">{</phrase>
+<phrase role="keyword">public</phrase><phrase role="special">:</phrase>
+ <phrase role="identifier">invalid_timeduration</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">msg</phrase><phrase role="special">);</phrase>
+<phrase role="special">};</phrase>
+</programlisting>
+ </para>
+ <section id="boost_task.reference.invalid_timeduration.constructor">
+ <title><link linkend="boost_task.reference.invalid_timeduration.constructor">
+ Constructor</link></title>
+<programlisting><phrase role="identifier">invalid_timeduration</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">msg</phrase><phrase role="special">)</phrase>
+</programlisting>
+ <variablelist>
+ <title></title> <varlistentry><term>Effects:</term>
+ <listitem>
+ <para>
+ Constructs a <code><phrase role="identifier">boost</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">task</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">invalid_timeduration</phrase></code>
+ instance.
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Throws:</term>
+ <listitem>
+ <para>
+ Nothing
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ </section>
+ <section id="boost_task.reference.invalid_watermark">
+ <title><link linkend="boost_task.reference.invalid_watermark"> Class <code><phrase
+ role="identifier">invalid_watermark</phrase></code></link></title>
+ <para>
+
+<programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">task</phrase><phrase role="special">/</phrase><phrase role="identifier">exceptions</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase>
+
+<phrase role="keyword">class</phrase> <phrase role="identifier">invalid_watermark</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">invalid_argument</phrase>
+<phrase role="special">{</phrase>
+<phrase role="keyword">public</phrase><phrase role="special">:</phrase>
+ <phrase role="identifier">invalid_watermark</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">msg</phrase><phrase role="special">);</phrase>
+<phrase role="special">};</phrase>
+</programlisting>
+ </para>
+ <section id="boost_task.reference.invalid_watermark.constructor">
+ <title><link linkend="boost_task.reference.invalid_watermark.constructor">
+ Constructor</link></title>
+<programlisting><phrase role="identifier">invalid_watermark</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">msg</phrase><phrase role="special">)</phrase>
+</programlisting>
+ <variablelist>
+ <title></title> <varlistentry><term>Effects:</term>
+ <listitem>
+ <para>
+ Constructs a <code><phrase role="identifier">boost</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">task</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">invalid_watermark</phrase></code>
+ instance.
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Throws:</term>
+ <listitem>
+ <para>
+ Nothing
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ </section>
+ <section id="boost_task.reference.task_rejected">
+ <title><link linkend="boost_task.reference.task_rejected"> Class <code><phrase
+ role="identifier">task_rejected</phrase></code></link></title>
+ <para>
+
+<programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">task</phrase><phrase role="special">/</phrase><phrase role="identifier">exceptions</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase>
+
+<phrase role="keyword">class</phrase> <phrase role="identifier">task_rejected</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">runtime_error</phrase>
+<phrase role="special">{</phrase>
+<phrase role="keyword">public</phrase><phrase role="special">:</phrase>
+ <phrase role="identifier">task_rejected</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">msg</phrase><phrase role="special">);</phrase>
+<phrase role="special">};</phrase>
+</programlisting>
+ </para>
+ <section id="boost_task.reference.task_rejected.constructor">
+ <title><link linkend="boost_task.reference.task_rejected.constructor"> Constructor</link></title>
+
+<programlisting><phrase role="identifier">task_rejected</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">msg</phrase><phrase role="special">)</phrase>
+</programlisting>
+ <variablelist>
+ <title></title> <varlistentry><term>Effects:</term>
+ <listitem>
+ <para>
+ Constructs a <code><phrase role="identifier">boost</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">task</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">task_rejected</phrase></code>
+ instance.
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Throws:</term>
+ <listitem>
+ <para>
+ Nothing
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ </section>
+ <section id="boost_task.reference.poolsize">
+ <title><link linkend="boost_task.reference.poolsize"> Class <code><phrase role="identifier">poolsize</phrase></code></link></title>
+ <para>
+
+<programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">task</phrase><phrase role="special">/</phrase><phrase role="identifier">poolsize</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase>
+
+<phrase role="keyword">class</phrase> <phrase role="identifier">poolsize</phrase>
+<phrase role="special">{</phrase>
+<phrase role="keyword">public</phrase><phrase role="special">:</phrase>
+ <phrase role="keyword">explicit</phrase> <phrase role="identifier">poolsize</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">value</phrase><phrase role="special">);</phrase>
+
+ <phrase role="keyword">operator</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="special">()</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase>
+<phrase role="special">};</phrase>
+</programlisting>
+ </para>
+ <section id="boost_task.reference.poolsize.constructor">
+ <title><link linkend="boost_task.reference.poolsize.constructor"> Constructor</link></title>
+
+<programlisting><phrase role="keyword">explicit</phrase> <phrase role="identifier">poolsize</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">value</phrase><phrase role="special">)</phrase>
+</programlisting>
+ <variablelist>
+ <title></title> <varlistentry><term>Preconditions:</term>
+ <listitem>
+ <para>
+ value &gt; 0
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Effects:</term>
+ <listitem>
+ <para>
+ constructs a <code><phrase role="identifier">boost</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">task</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">poolsize</phrase></code>
+ instance
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Postconditions:</term>
+ <listitem>
+ <para>
+ operator std::size_t () &gt; 0
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Throws:</term>
+ <listitem>
+ <para>
+ <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">invalid_poolsize</phrase></code>
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ <section id="boost_task.reference.poolsize.operator">
+ <title><link linkend="boost_task.reference.poolsize.operator"> Member function
+ <code><phrase role="keyword">operator</phrase> <phrase role="identifier">std</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">size_t</phrase><phrase
+ role="special">()</phrase></code></link></title>
+<programlisting><phrase role="keyword">operator</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="special">()</phrase> <phrase role="keyword">const</phrase>
+</programlisting>
+ <variablelist>
+ <title></title> <varlistentry><term>Effects:</term>
+ <listitem>
+ <para>
+ returns the value
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Throws:</term>
+ <listitem>
+ <para>
+ Nothing
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ </section>
+ <section id="boost_task.reference.high_watermark">
+ <title><link linkend="boost_task.reference.high_watermark"> Class <code><phrase
+ role="identifier">high_watermark</phrase></code></link></title>
+ <para>
+
+<programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">task</phrase><phrase role="special">/</phrase><phrase role="identifier">watermark</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase>
+
+<phrase role="keyword">class</phrase> <phrase role="identifier">high_watermark</phrase>
+<phrase role="special">{</phrase>
+<phrase role="keyword">public</phrase><phrase role="special">:</phrase>
+ <phrase role="keyword">explicit</phrase> <phrase role="identifier">high_watermark</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">value</phrase><phrase role="special">);</phrase>
+
+ <phrase role="keyword">operator</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="special">()</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase>
+<phrase role="special">};</phrase>
+</programlisting>
+ </para>
+ <section id="boost_task.reference.high_watermark.constructor">
+ <title><link linkend="boost_task.reference.high_watermark.constructor"> Constructor</link></title>
+
+<programlisting><phrase role="keyword">explicit</phrase> <phrase role="identifier">high_watermark</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">value</phrase><phrase role="special">)</phrase>
+</programlisting>
+ <variablelist>
+ <title></title> <varlistentry><term>Effects:</term>
+ <listitem>
+ <para>
+ constructs a <code><phrase role="identifier">boost</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">tp</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">high_watermark</phrase></code>
+ instance
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Throws:</term>
+ <listitem>
+ <para>
+ <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">invalid_watermark</phrase></code>
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ <section id="boost_task.reference.high_watermark.operator">
+ <title><link linkend="boost_task.reference.high_watermark.operator"> Member
+ function <code><phrase role="keyword">operator</phrase> <phrase role="identifier">std</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">size_t</phrase><phrase
+ role="special">()</phrase></code></link></title>
+<programlisting><phrase role="keyword">operator</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="special">()</phrase> <phrase role="keyword">const</phrase>
+</programlisting>
+ <variablelist>
+ <title></title> <varlistentry><term>Effects:</term>
+ <listitem>
+ <para>
+ returns high watermark
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Throws:</term>
+ <listitem>
+ <para>
+ Nothing
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ </section>
+ <section id="boost_task.reference.low_watermark">
+ <title><link linkend="boost_task.reference.low_watermark"> Class <code><phrase
+ role="identifier">low_watermark</phrase></code></link></title>
+ <para>
+
+<programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">task</phrase><phrase role="special">/</phrase><phrase role="identifier">watermark</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase>
+
+<phrase role="keyword">class</phrase> <phrase role="identifier">low_watermark</phrase>
+<phrase role="special">{</phrase>
+<phrase role="keyword">public</phrase><phrase role="special">:</phrase>
+ <phrase role="keyword">explicit</phrase> <phrase role="identifier">low_watermark</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">value</phrase><phrase role="special">);</phrase>
+
+ <phrase role="keyword">operator</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="special">()</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase>
+<phrase role="special">};</phrase>
+</programlisting>
+ </para>
+ <section id="boost_task.reference.low_watermark.constructor">
+ <title><link linkend="boost_task.reference.low_watermark.constructor"> Constructor</link></title>
+
+<programlisting><phrase role="keyword">explicit</phrase> <phrase role="identifier">low_watermark</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">value</phrase><phrase role="special">)</phrase>
+</programlisting>
+ <variablelist>
+ <title></title> <varlistentry><term>Effects:</term>
+ <listitem>
+ <para>
+ constructs a <code><phrase role="identifier">boost</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">task</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">low_watermark</phrase></code>
+ instance
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Throws:</term>
+ <listitem>
+ <para>
+ <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">invalid_watermark</phrase></code>
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ <section id="boost_task.reference.low_watermark.operator">
+ <title><link linkend="boost_task.reference.low_watermark.operator"> Member
+ function <code><phrase role="keyword">operator</phrase> <phrase role="identifier">std</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">size_t</phrase><phrase
+ role="special">()</phrase></code></link></title>
+<programlisting><phrase role="keyword">operator</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="special">()</phrase> <phrase role="keyword">const</phrase>
+</programlisting>
+ <variablelist>
+ <title></title> <varlistentry><term>Effects:</term>
+ <listitem>
+ <para>
+ returns low watermark
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Throws:</term>
+ <listitem>
+ <para>
+ Nothing
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ </section>
+ <section id="boost_task.reference.scanns">
+ <title><link linkend="boost_task.reference.scanns"> Class <code><phrase role="identifier">scanns</phrase></code></link></title>
+ <para>
+
+<programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">task</phrase><phrase role="special">/</phrase><phrase role="identifier">scanns</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase>
+
+<phrase role="keyword">class</phrase> <phrase role="identifier">scanns</phrase>
+<phrase role="special">{</phrase>
+<phrase role="keyword">public</phrase><phrase role="special">:</phrase>
+ <phrase role="keyword">explicit</phrase> <phrase role="identifier">scanns</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">value</phrase><phrase role="special">);</phrase>
+
+ <phrase role="keyword">operator</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="special">()</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase>
+<phrase role="special">};</phrase>
+</programlisting>
+ </para>
+ <section id="boost_task.reference.scanns.constructor">
+ <title><link linkend="boost_task.reference.scanns.constructor"> Constructor</link></title>
+
+<programlisting><phrase role="keyword">explicit</phrase> <phrase role="identifier">scanns</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">value</phrase><phrase role="special">)</phrase>
+</programlisting>
+ <variablelist>
+ <title></title> <varlistentry><term>Preconditions:</term>
+ <listitem>
+ <para>
+ value &gt; 0
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Effects:</term>
+ <listitem>
+ <para>
+ constructs a <code><phrase role="identifier">boost</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">task</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">scanns</phrase></code>
+ instance
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Postconditions:</term>
+ <listitem>
+ <para>
+ operator std::size_t () &gt; 0
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Throws:</term>
+ <listitem>
+ <para>
+ <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">invalid_poolsize</phrase></code>
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ <section id="boost_task.reference.scanns.operator">
+ <title><link linkend="boost_task.reference.scanns.operator"> Member function
+ <code><phrase role="keyword">operator</phrase> <phrase role="identifier">std</phrase><phrase
+ role="special">::</phrase><phrase role="identifier">size_t</phrase><phrase
+ role="special">()</phrase></code></link></title>
+<programlisting><phrase role="keyword">operator</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="special">()</phrase> <phrase role="keyword">const</phrase>
+</programlisting>
+ <variablelist>
+ <title></title> <varlistentry><term>Effects:</term>
+ <listitem>
+ <para>
+ returns the value
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry><term>Throws:</term>
+ <listitem>
+ <para>
+ Nothing
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ </section>
+ </section>
+ <section id="boost_task.appendices">
+ <title><link linkend="boost_task.appendices">Appendices</link></title>
+ <section id="boost_task.appendices.todo">
+ <title><link linkend="boost_task.appendices.todo"> Appendix A: Future development</link></title>
+ <anchor id="boost_task.appendices.todo.dynamic_thread_pool"/>
+ <bridgehead renderas="sect4">
+ <link linkend="boost_task.appendices.todo.dynamic_thread_pool">Dynamic thread-pool</link>
+ </bridgehead>
+ <itemizedlist>
+ <listitem>
+ <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">dynamic_pool</phrase></code> adds or removes <emphasis>worker-threads</emphasis>
+ from the <emphasis>thread-pool</emphasis> depending on the work-load (undersubscription/
+ oversubscription).
+ </listitem>
+ </itemizedlist>
+ <anchor id="boost_task.appendices.todo.communication_and_synchronisation_abstractions"/>
+ <bridgehead renderas="sect4">
+ <link linkend="boost_task.appendices.todo.communication_and_synchronisation_abstractions">Communication
+ and synchronisation abstractions</link>
+ </bridgehead>
+ <itemizedlist>
+ <listitem>
+ <emphasis role="bold">Event variable</emphasis>: A event variable is a
+ bivalued variable (up/down) on which a task can wait for an event to be
+ set or reset. The calling task will be suspended until the state of the
+ event variable is that required by the caller.
+ </listitem>
+ <listitem>
+ <emphasis role="bold">Buffer</emphasis>: A bounded/unbounded buffer is
+ shared between several tasks. The data must be placed in, and retrieved
+ from, the buffer under mutual exclusion. Condition synchronisation is required
+ because a calling task attempting to place data into the buffer. When the
+ buffer is full, the task must be suspended until there is space int the
+ buffer. Also a retrieving task must be suspended when the buffer is empty.
+ The data, once read, is destroyed.
+ </listitem>
+ <listitem>
+ <emphasis role="bold">Multicast</emphasis>: The data is sent to a specific
+ group of tasks and all tasks in the group should receive the data. Only
+ when all tasks have received one item of data then another item is allowed
+ to be transmitted.
+ </listitem>
+ <listitem>
+ <emphasis role="bold">Rendezvous</emphasis>: A rendezvous uses direct naming
+ and synchronous communication between tasks. One task that executes its
+ command first will be delayed until the other tasks is ready to rendezvous.
+ </listitem>
+ <listitem>
+ <emphasis role="bold">Protected resource</emphasis>: A protected resource
+ is a passive entity that controls access to the internal states (to the
+ controled real resources).
+ </listitem>
+ <listitem>
+ <emphasis role="bold">Task groups</emphasis>: A task group defines a graph
+ of interdependent tasks that can mostly be run in parallel. The tasks in
+ the group have dependencies or communicate with each other.
+ </listitem>
+ </itemizedlist>
+ <anchor id="boost_task.appendices.todo.interdepended_task"/>
+ <bridgehead renderas="sect4">
+ <link linkend="boost_task.appendices.todo.interdepended_task">Interdepended
+ task</link>
+ </bridgehead>
+ <itemizedlist>
+ <listitem>
+ With special support of concurrence and synchronisation abstractions interdepended
+ tasks work in <emphasis>thread-pools</emphasis> (using context switching/fibers).
+ </listitem>
+ </itemizedlist>
+ <anchor id="boost_task.appendices.todo.support_of_explicit_processor_bindig"/>
+ <bridgehead renderas="sect4">
+ <link linkend="boost_task.appendices.todo.support_of_explicit_processor_bindig">Support
+ of explicit processor bindig</link>
+ </bridgehead>
+ <itemizedlist>
+ <listitem>
+ <emphasis>asynchronous-executors</emphasis> related to a <emphasis>thread-pool</emphasis>
+ (like <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">task</phrase><phrase role="special">::</phrase><phrase
+ role="identifier">default_pool</phrase></code>) could support explicit
+ processor binding.
+ </listitem>
+ </itemizedlist>
+ <anchor id="boost_task.appendices.todo.optimizations"/>
+ <bridgehead renderas="sect4">
+ <link linkend="boost_task.appendices.todo.optimizations">Optimizations</link>
+ </bridgehead>
+ <itemizedlist>
+ <listitem>
+ two-lock-queue as global queue in <emphasis>thread-pool</emphasis>
+ </listitem>
+ <listitem>
+ maybe lock-free-queue as global queue too (how to provide the scheduling
+ policies fifo, priority, smart?)
+ </listitem>
+ </itemizedlist>
+ <anchor id="boost_task.appendices.todo.actor_framework"/>
+ <bridgehead renderas="sect4">
+ <link linkend="boost_task.appendices.todo.actor_framework">Actor framework</link>
+ </bridgehead>
+ <itemizedlist>
+ <listitem>
+ framework support of communication and synchronisation between tasks
+ </listitem>
+ <listitem>
+ so called actors provide the required mechanisms
+ </listitem>
+ <listitem>
+ for a detailed explanation read Micorsoft proposal of <ulink url="http://msdn.microsoft.com/en-us/devlabs/dd795202.aspx">Axum</ulink>
+ </listitem>
+ </itemizedlist>
+ </section>
+ <section id="boost_task.appendices.acknowledgements">
+ <title><link linkend="boost_task.appendices.acknowledgements"> Appendix B:
+ Acknowledgments</link></title>
+ <para>
+ I'd like to thank Vicente J. Botet Escriba for his comments on the implementation
+ and Anthony Williams and Braddock Gaskill for their future libraries.
+ </para>
+ </section>
+ </section>
+</library>

Modified: sandbox/task/libs/task/doc/channel.qbk
==============================================================================
--- sandbox/task/libs/task/doc/channel.qbk (original)
+++ sandbox/task/libs/task/doc/channel.qbk 2009-06-01 08:13:01 EDT (Mon, 01 Jun 2009)
@@ -8,12 +8,13 @@
 
 [section:channel Channel]
 
-The channel synchronizes the access between non-pool threads (application threads) and __worker_threads__ and implements a queuing policy (limitation of queued _tasks__).
+The channel synchronizes the access between non-pool threads (application threads) and __worker_threads__ and implements
+a queuing policy (limitation of queued tasks).
 
 
 [heading __bounded_channel__]
 
-__bounded_channel__ contains a single lock in order to synchronize access to the queue. The number of pending __tasks__ is limited in order to prevent resource exhaustion.
+__bounded_channel__ contains a single lock in order to synchronize access to the queue. The number of pending tasks is limited in order to prevent resource exhaustion.
 For this purpose a high- and low-watermark has to be passed at construction.
 __hwm__ sets the maximum of pending tasks. If this limited is reached all threads which submit a task will be set to sleep (blocked). If it is equal to __lwm__ everytime a
 sleeping producer thread will be woken up and puts its task if one worker thread has taken a task from the channel.
@@ -23,8 +24,8 @@
 
 [heading __unbounded_channel__]
 
-__unbounded_channel__ contains a single lock in order to synchronize access to the queue. An unlimited number of __tasks__ can be queued into this channel.
-The insertion of an __task__ will never block. If the channel becomes empty __worker_threads__ will be set to sleep until new __tasks__ are enqueued.
+__unbounded_channel__ contains a single lock in order to synchronize access to the queue. An unlimited number of tasks can be queued into this channel.
+The insertion of an __task__ will never block. If the channel becomes empty __worker_threads__ will be set to sleep until new tasks are enqueued.
 
 
 [endsect]

Modified: sandbox/task/libs/task/doc/default_pool.qbk
==============================================================================
--- sandbox/task/libs/task/doc/default_pool.qbk (original)
+++ sandbox/task/libs/task/doc/default_pool.qbk 2009-06-01 08:13:01 EDT (Mon, 01 Jun 2009)
@@ -8,8 +8,9 @@
 
 [section:default_pool Default pool]
 
-The library provides a default-pool accessible via __fn_default_pool__. The function returns a reference to __full_default_pool__. The static instance of __default_pool__ contains as many __worker_threads__ as
-__hardware_concurrency__ returns, queues unlimited amount of __tasks__ and schedules the __tasks__ in FIFO-order.
+The library provides a default-pool accessible via __fn_default_pool__. The function returns a reference to
+__full_default_pool__. The static instance of __default_pool__ contains as many __worker_threads__ as
+__hardware_concurrency__ returns, queues unlimited amount of tasks and schedules the tasks in FIFO-order.
 
 
 ``

Deleted: sandbox/task/libs/task/doc/description.qbk
==============================================================================
--- sandbox/task/libs/task/doc/description.qbk 2009-06-01 08:13:01 EDT (Mon, 01 Jun 2009)
+++ (empty file)
@@ -1,18 +0,0 @@
-[/
- Copyright Oliver Kowalke 2009.
- Distributed under the Boost Software License, Version 1.0.
- (See accompanying file LICENSE_1_0.txt or copy at
- http://www.boost.org/LICENSE_1_0.txt
-]
-
-
-[section:description Description]
-
-[include task.qbk]
-[include async_completion_token.qbk]
-[include async_executor.qbk]
-[include utilities.qbk]
-[include meta_functions.qbk]
-
-
-[endsect]

Added: sandbox/task/libs/task/doc/fork_join.qbk
==============================================================================
--- (empty file)
+++ sandbox/task/libs/task/doc/fork_join.qbk 2009-06-01 08:13:01 EDT (Mon, 01 Jun 2009)
@@ -0,0 +1,65 @@
+/
+ Copyright Oliver Kowalke 2009.
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt
+]
+
+
+[section:forkjoin Fork/Join]
+
+Fork/Join algorithms are recursive divide-and-conquer algorithms which repeatedly splitt into sub-tasks until they become small
+enough to solve using simple, short sequential methods, so that they run in parallel on multiple cores.
+
+The fork operation creates new __sub_tasks__ which can run in parallel. The current __task__ is not proceeded in the join operation
+until the forked __sub_tasks__ have completed. In the meantime the __worker_thread__ executes other tasks from its local worker-queue.
+
+``
+ long serial_fib( long n)
+ {
+ if( n < 2) return n;
+ else return serial_fib( n - 1) + serial_fib( n - 2);
+ }
+
+ long parallel_fib( long n, long cutof)
+ {
+ if ( n < cutof) return serial_fib( n);
+ else
+ {
+ // fork a sub-task calculating fibonacci(n-1)
+ h1 = boost::task::async(
+ boost::task::as_sub_task(),
+ boost::task::make_task(
+ parallel_fib,
+ n - 1,
+ cutof) );
+ // fork a sub-task calculating fibonacci(n-2)
+ h2 = boost::task::async(
+ boost::task::as_sub_task(),
+ boost::task::make_task(
+ parallel_fib,
+ n - 2,
+ cutof) );
+ // join the results of both sub-tasks
+ // if one of the both sub-tasks is not ready
+ // the worker-thread does not block, it executes other
+ // task from its local-queue
+ return h1.get() + h2.get();
+ }
+ }
+
+ void main()
+ {
+ boost::task::handle< long > h( // handle for fibonacci calculation
+ boost::task::async(
+ boost::task::default_pool(), // access the default thread-pool
+ boost::task::make_task( // calculate fibonacci number 10
+ parallel_fib, // for numbers < 5 do inline recursive calculation
+ 10,
+ 5) ) );
+ std::cout << h.get() << std::endl;
+ }
+``
+
+
+[endsect]

Deleted: sandbox/task/libs/task/doc/forkjoin.qbk
==============================================================================
--- sandbox/task/libs/task/doc/forkjoin.qbk 2009-06-01 08:13:01 EDT (Mon, 01 Jun 2009)
+++ (empty file)
@@ -1,65 +0,0 @@
-/
- Copyright Oliver Kowalke 2009.
- Distributed under the Boost Software License, Version 1.0.
- (See accompanying file LICENSE_1_0.txt or copy at
- http://www.boost.org/LICENSE_1_0.txt
-]
-
-
-[section:forkjoin Fork/Join]
-
-Fork/Join algorithms are recursive divide-and-conquer algorithms which repeatedly splitt __sub_taskss__ until they become small enough to solve using simple, short sequential methods,
-so that they run in parallel on multiple cores.
-
-The fork operation creates new __sub_tasks__ which can run in parallel. The current __task__ is not proceeded in the join operation until the forked __sub_tasks__ have completed.
-In the meantime the __worker_thread__ executes other __tasks__ from its local worker-queue.
-
-``
- long serial_fib( long n)
- {
- if( n < 2) return n;
- else return serial_fib( n - 1) + serial_fib( n - 2);
- }
-
- long parallel_fib( long n, long cutof)
- {
- if ( n < cutof) return serial_fib( n);
- else
- {
- // fork a sub-task calculating fibonacci(n-1)
- h1 = boost::task::async(
- boost::task::as_sub_task(),
- boost::task::make_task(
- parallel_fib,
- n - 1,
- cutof) );
- // fork a sub-task calculating fibonacci(n-2)
- h2 = boost::task::async(
- boost::task::as_sub_task(),
- boost::task::make_task(
- parallel_fib,
- n - 2,
- cutof) );
- // join the results of both sub-tasks
- // if one of the both sub-tasks is not ready
- // the worker-thread does not block, it executes other
- // task from its local-queue
- return h1.get() + h2.get();
- }
- }
-
- void main()
- {
- boost::task::handle< long > h( // handle for fibonacci calculation
- boost::task::async(
- boost::task::default_pool(), // access the default thread-pool
- boost::task::make_task( // calculate fibonacci number 10
- parallel_fib, // for numbers < 5 do inline recursive calculation
- 10,
- 5) ) );
- std::cout << h.get() << std::endl;
- }
-``
-
-
-[endsect]

Modified: sandbox/task/libs/task/doc/handle.qbk
==============================================================================
--- sandbox/task/libs/task/doc/handle.qbk (original)
+++ sandbox/task/libs/task/doc/handle.qbk 2009-06-01 08:13:01 EDT (Mon, 01 Jun 2009)
@@ -8,10 +8,14 @@
 
 [section:handle Handle]
 
+The __act__ dispatches tasks in response to the completion of asynchronous operations. __act__ uniquely identifies
+the task and state necessary to process the result of the operation [footnote see [@http://www.cs.wustl.edu/~schmidt/PDF/ACT.pdf
+'Asynchronous Completion Token'], Douglas Schmidt].
+
 __handle__ represents an __act__. It will be returned by __fn_async__ and is associated with the submitted __task__.
 
 
-[heading:act_interface Asynchronous completion token interface]
+[heading Asynchronous completion token interface]
 
 __handle__ implements an interface in order to check the state of computation and result transfer
 
@@ -71,7 +75,7 @@
         }
 ``
 
-[heading:task_interruption Task interruption]
+[heading Task interruption]
 
 * __fn_interrupt__: interrupt __task__ and return immediately
 

Added: sandbox/task/libs/task/doc/html/boost_task/appendices.html
==============================================================================
--- (empty file)
+++ sandbox/task/libs/task/doc/html/boost_task/appendices.html 2009-06-01 08:13:01 EDT (Mon, 01 Jun 2009)
@@ -0,0 +1,161 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>Appendices</title>
+<link rel="stylesheet" href="../boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.75.0">
+<link rel="home" href="../index.html" title="Chapter 1. Boost.Task">
+<link rel="up" href="../index.html" title="Chapter 1. Boost.Task">
+<link rel="prev" href="reference.html" title="Reference">
+</head>
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<table cellpadding="2" width="100%"><tr>
+<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td>
+<td align="center">Home</td>
+<td align="center">Libraries</td>
+<td align="center">People</td>
+<td align="center">FAQ</td>
+<td align="center">More</td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="reference.html"><img src="../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/html/images/home.png" alt="Home"></a>
+</div>
+<div class="section" title="Appendices">
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="boost_task.appendices"></a><a class="link" href="appendices.html" title="Appendices">Appendices</a>
+</h2></div></div></div>
+<div class="toc"><dl>
+<dt><span class="section"> Appendix A: Future development</span></dt>
+<dt><span class="section"><a href="appendices.html#boost_task.appendices.acknowledgements"> Appendix B:
+ Acknowledgments</a></span></dt>
+</dl></div>
+<div class="section" title="Appendix A: Future development">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_task.appendices.todo"></a><a class="link" href="appendices.html#boost_task.appendices.todo" title="Appendix A: Future development"> Appendix A: Future development</a>
+</h3></div></div></div>
+<a name="boost_task.appendices.todo.dynamic_thread_pool"></a><h5>
+<a name="id598832"></a>
+ <a class="link" href="appendices.html#boost_task.appendices.todo.dynamic_thread_pool">Dynamic thread-pool</a>
+ </h5>
+<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem">
+<code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">dynamic_pool</span></code> adds or removes <span class="emphasis"><em>worker-threads</em></span>
+ from the <span class="emphasis"><em>thread-pool</em></span> depending on the work-load (undersubscription/
+ oversubscription).
+ </li></ul></div>
+<a name="boost_task.appendices.todo.communication_and_synchronisation_abstractions"></a><h5>
+<a name="id598896"></a>
+ <a class="link" href="appendices.html#boost_task.appendices.todo.communication_and_synchronisation_abstractions">Communication
+ and synchronisation abstractions</a>
+ </h5>
+<div class="itemizedlist"><ul class="itemizedlist" type="disc">
+<li class="listitem">
+<span class="bold"><strong>Event variable</strong></span>: A event variable is a
+ bivalued variable (up/down) on which a task can wait for an event to be
+ set or reset. The calling task will be suspended until the state of the
+ event variable is that required by the caller.
+ </li>
+<li class="listitem">
+<span class="bold"><strong>Buffer</strong></span>: A bounded/unbounded buffer is
+ shared between several tasks. The data must be placed in, and retrieved
+ from, the buffer under mutual exclusion. Condition synchronisation is required
+ because a calling task attempting to place data into the buffer. When the
+ buffer is full, the task must be suspended until there is space int the
+ buffer. Also a retrieving task must be suspended when the buffer is empty.
+ The data, once read, is destroyed.
+ </li>
+<li class="listitem">
+<span class="bold"><strong>Multicast</strong></span>: The data is sent to a specific
+ group of tasks and all tasks in the group should receive the data. Only
+ when all tasks have received one item of data then another item is allowed
+ to be transmitted.
+ </li>
+<li class="listitem">
+<span class="bold"><strong>Rendezvous</strong></span>: A rendezvous uses direct naming
+ and synchronous communication between tasks. One task that executes its
+ command first will be delayed until the other tasks is ready to rendezvous.
+ </li>
+<li class="listitem">
+<span class="bold"><strong>Protected resource</strong></span>: A protected resource
+ is a passive entity that controls access to the internal states (to the
+ controled real resources).
+ </li>
+<li class="listitem">
+<span class="bold"><strong>Task groups</strong></span>: A task group defines a graph
+ of interdependent tasks that can mostly be run in parallel. The tasks in
+ the group have dependencies or communicate with each other.
+ </li>
+</ul></div>
+<a name="boost_task.appendices.todo.interdepended_task"></a><h5>
+<a name="id598986"></a>
+ <a class="link" href="appendices.html#boost_task.appendices.todo.interdepended_task">Interdepended
+ task</a>
+ </h5>
+<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem">
+ With special support of concurrence and synchronisation abstractions interdepended
+ tasks work in <span class="emphasis"><em>thread-pools</em></span> (using context switching/fibers).
+ </li></ul></div>
+<a name="boost_task.appendices.todo.support_of_explicit_processor_bindig"></a><h5>
+<a name="id599017"></a>
+ <a class="link" href="appendices.html#boost_task.appendices.todo.support_of_explicit_processor_bindig">Support
+ of explicit processor bindig</a>
+ </h5>
+<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem">
+<span class="emphasis"><em>asynchronous-executors</em></span> related to a <span class="emphasis"><em>thread-pool</em></span>
+ (like <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">default_pool</span></code>) could support explicit
+ processor binding.
+ </li></ul></div>
+<a name="boost_task.appendices.todo.optimizations"></a><h5>
+<a name="id599080"></a>
+ <a class="link" href="appendices.html#boost_task.appendices.todo.optimizations">Optimizations</a>
+ </h5>
+<div class="itemizedlist"><ul class="itemizedlist" type="disc">
+<li class="listitem">
+ two-lock-queue as global queue in <span class="emphasis"><em>thread-pool</em></span>
+</li>
+<li class="listitem">
+ maybe lock-free-queue as global queue too (how to provide the scheduling
+ policies fifo, priority, smart?)
+ </li>
+</ul></div>
+<a name="boost_task.appendices.todo.actor_framework"></a><h5>
+<a name="id599114"></a>
+ <a class="link" href="appendices.html#boost_task.appendices.todo.actor_framework">Actor framework</a>
+ </h5>
+<div class="itemizedlist"><ul class="itemizedlist" type="disc">
+<li class="listitem">
+ framework support of communication and synchronisation between tasks
+ </li>
+<li class="listitem">
+ so called actors provide the required mechanisms
+ </li>
+<li class="listitem">
+ for a detailed explanation read Micorsoft proposal of Axum
+</li>
+</ul></div>
+</div>
+<div class="section" title="Appendix B: Acknowledgments">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_task.appendices.acknowledgements"></a><a class="link" href="appendices.html#boost_task.appendices.acknowledgements" title="Appendix B: Acknowledgments"> Appendix B:
+ Acknowledgments</a>
+</h3></div></div></div>
+<p>
+ I'd like to thank Vicente J. Botet Escriba for his comments on the implementation
+ and Anthony Williams and Braddock Gaskill for their future libraries.
+ </p>
+</div>
+</div>
+<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
+<td align="left"></td>
+<td align="right"><div class="copyright-footer">Copyright © 2009 Oliver Kowalke<p>
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ </p>
+</div></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="reference.html"><img src="../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/html/images/home.png" alt="Home"></a>
+</div>
+</body>
+</html>

Added: sandbox/task/libs/task/doc/html/boost_task/as_sub_task.html
==============================================================================
--- (empty file)
+++ sandbox/task/libs/task/doc/html/boost_task/as_sub_task.html 2009-06-01 08:13:01 EDT (Mon, 01 Jun 2009)
@@ -0,0 +1,81 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>Execute as sub-task</title>
+<link rel="stylesheet" href="../boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.75.0">
+<link rel="home" href="../index.html" title="Chapter 1. Boost.Task">
+<link rel="up" href="../index.html" title="Chapter 1. Boost.Task">
+<link rel="prev" href="pool.html" title="Thread-pool">
+<link rel="next" href="utilities.html" title="Utilities">
+</head>
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<table cellpadding="2" width="100%"><tr>
+<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td>
+<td align="center">Home</td>
+<td align="center">Libraries</td>
+<td align="center">People</td>
+<td align="center">FAQ</td>
+<td align="center">More</td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="pool.html"><img src="../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="utilities.html"><img src="../../../doc/html/images/next.png" alt="Next"></a>
+</div>
+<div class="section" title="Execute as sub-task">
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="boost_task.as_sub_task"></a><a class="link" href="as_sub_task.html" title="Execute as sub-task"> Execute as sub-task</a>
+</h2></div></div></div>
+<p>
+ <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">as_sub_task</span></code>
+ is a convenient way to execute a <span class="emphasis"><em>sub-task</em></span>. If the parent
+ task is executed inside a <span class="emphasis"><em>thread-pool</em></span> the <span class="emphasis"><em>sub-task</em></span>
+ is put into the local-queue of the <span class="emphasis"><em>worker-thread</em></span> in the
+ other case the <span class="emphasis"><em>sub-task</em></span> will be executed in a new thread.
+ </p>
+<p>
+
+</p>
+<pre class="programlisting"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">handle</span><span class="special">&lt;</span> <span class="keyword">long</span> <span class="special">&gt;</span> <span class="identifier">h</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">async</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">as_sub_task</span><span class="special">(),</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">make_task</span><span class="special">(</span>
+ <span class="identifier">fibonacci</span><span class="special">,</span>
+ <span class="number">10</span><span class="special">)</span> <span class="special">)</span> <span class="special">);</span>
+</pre>
+<p>
+ </p>
+<p>
+ is equivalent to:
+ </p>
+<p>
+
+</p>
+<pre class="programlisting"><span class="keyword">if</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">runs_in_pool</span><span class="special">()</span> <span class="special">)</span>
+<span class="special">{</span>
+ <span class="comment">// put the sub-task into worker-threads local-queue
+</span><span class="special">}</span>
+<span class="keyword">else</span>
+<span class="special">{</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">async</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">new_thread</span><span class="special">(),</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">make_task</span><span class="special">(...)</span> <span class="special">);</span>
+<span class="special">}</span>
+</pre>
+<p>
+ </p>
+</div>
+<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
+<td align="left"></td>
+<td align="right"><div class="copyright-footer">Copyright © 2009 Oliver Kowalke<p>
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ </p>
+</div></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="pool.html"><img src="../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="utilities.html"><img src="../../../doc/html/images/next.png" alt="Next"></a>
+</div>
+</body>
+</html>

Added: sandbox/task/libs/task/doc/html/boost_task/async_completion_token.html
==============================================================================
--- (empty file)
+++ sandbox/task/libs/task/doc/html/boost_task/async_completion_token.html 2009-06-01 08:13:01 EDT (Mon, 01 Jun 2009)
@@ -0,0 +1,226 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>Asynchronous completion token</title>
+<link rel="stylesheet" href="../boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.75.0">
+<link rel="home" href="../index.html" title="Chapter 1. Boost.Task">
+<link rel="up" href="../index.html" title="Chapter 1. Boost.Task">
+<link rel="prev" href="callable.html" title="Callable">
+<link rel="next" href="async_executor.html" title="Asynchronous executor">
+</head>
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<table cellpadding="2" width="100%"><tr>
+<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td>
+<td align="center">Home</td>
+<td align="center">Libraries</td>
+<td align="center">People</td>
+<td align="center">FAQ</td>
+<td align="center">More</td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="callable.html"><img src="../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="async_executor.html"><img src="../../../doc/html/images/next.png" alt="Next"></a>
+</div>
+<div class="section" title="Asynchronous completion token">
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="boost_task.async_completion_token"></a><a class="link" href="async_completion_token.html" title="Asynchronous completion token"> Asynchronous completion
+ token</a>
+</h2></div></div></div>
+<div class="toc"><dl><dt><span class="section"> Handle</span></dt></dl></div>
+<p>
+ The <span class="emphasis"><em>asynchronous-completion-token</em></span> dispatches processing
+ actions (<span class="underline">_tasks</span>_) in response to the
+ completion of asynchronous operations. <span class="emphasis"><em>asynchronous-completion-token</em></span>
+ uniquely identifies the task and state necessary to process the result of the
+ operation
+ <sup>[<a name="id638673" href="#ftn.id638673" class="footnote">3</a>]</sup>
+ .
+ </p>
+<div class="section" title="Handle">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_task.async_completion_token.handle"></a><a class="link" href="async_completion_token.html#boost_task.async_completion_token.handle" title="Handle"> Handle</a>
+</h3></div></div></div>
+<p>
+ <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">handle</span></code> represents an <span class="emphasis"><em>asynchronous-completion-token</em></span>.
+ It will be returned by <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">async</span><span class="special">()</span></code> and is associated with the submitted <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">task</span></code>.
+ </p>
+<a name="boost_task.async_completion_token.handle._act_interface_asynchronous_completion_token_interface"></a><h5>
+<a name="id638788"></a>
+ <a class="link" href="async_completion_token.html#boost_task.async_completion_token.handle._act_interface_asynchronous_completion_token_interface">:act_interface
+ Asynchronous completion token interface</a>
+ </h5>
+<p>
+ <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">handle</span></code> implements an interface in order
+ to check the state of computation and result transfer
+ </p>
+<div class="itemizedlist"><ul class="itemizedlist" type="disc">
+<li class="listitem">
+<code class="computeroutput"><span class="identifier">get_id</span><span class="special">()</span></code>:
+ return id of the associated task-id
+ </li>
+<li class="listitem">
+<code class="computeroutput"><span class="identifier">is_ready</span><span class="special">()</span></code>:
+ test if result is set
+ </li>
+<li class="listitem">
+<code class="computeroutput"><span class="identifier">has_value</span><span class="special">()</span></code>:
+ test if value-result is set
+ </li>
+<li class="listitem">
+<code class="computeroutput"><span class="identifier">has_exception</span><span class="special">()</span></code>:
+ test if exception-result is set
+ </li>
+<li class="listitem">
+<code class="computeroutput"><span class="identifier">get</span><span class="special">()</span></code>:
+ return value-result
+ </li>
+<li class="listitem">
+<code class="computeroutput"><span class="identifier">wait</span><span class="special">()</span></code>:
+ wait until result is set
+ </li>
+<li class="listitem">
+<code class="computeroutput"><span class="identifier">wait_for</span><span class="special">()</span></code>:
+ wait until result is set or time-duration has elapsed
+ </li>
+<li class="listitem">
+<code class="computeroutput"><span class="identifier">wait_until</span><span class="special">()</span></code>:
+ wait until result ist set or time-point has elapsed
+ </li>
+</ul></div>
+<p>
+
+</p>
+<pre class="programlisting"><span class="keyword">long</span> <span class="identifier">fibonacci</span><span class="special">(</span> <span class="keyword">long</span> <span class="identifier">n</span><span class="special">)</span>
+<span class="special">{</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">this_thread</span><span class="special">::</span><span class="identifier">interruption_point</span><span class="special">();</span> <span class="comment">// interruption point
+</span>
+ <span class="keyword">if</span> <span class="special">(</span> <span class="identifier">n</span> <span class="special">==</span> <span class="number">0</span><span class="special">)</span> <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span>
+ <span class="keyword">if</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="keyword">return</span> <span class="number">1</span><span class="special">;</span>
+ <span class="keyword">long</span> <span class="identifier">k1</span><span class="special">(</span> <span class="number">1</span><span class="special">),</span> <span class="identifier">k2</span><span class="special">(</span> <span class="number">0</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">2</span><span class="special">);</span> <span class="identifier">i</span> <span class="special">&lt;=</span> <span class="identifier">n</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span>
+ <span class="special">{</span>
+ <span class="keyword">if</span> <span class="special">(</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">this_thread</span><span class="special">::</span><span class="identifier">interruption_requested</span><span class="special">()</span> <span class="special">)</span> <span class="comment">// check if interruption was requested
+</span> <span class="keyword">return</span><span class="special">;</span>
+
+ <span class="keyword">long</span> <span class="identifier">tmp</span><span class="special">(</span> <span class="identifier">k1</span><span class="special">);</span>
+ <span class="identifier">k1</span> <span class="special">=</span> <span class="identifier">k1</span> <span class="special">+</span> <span class="identifier">k2</span><span class="special">;</span>
+ <span class="identifier">k2</span> <span class="special">=</span> <span class="identifier">tmp</span><span class="special">;</span>
+ <span class="special">}</span>
+
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">this_thread</span><span class="special">::</span><span class="identifier">interruption_point</span><span class="special">();</span> <span class="comment">// interruption point
+</span>
+ <span class="keyword">return</span> <span class="identifier">k1</span><span class="special">;</span>
+<span class="special">}</span>
+
+<span class="keyword">void</span> <span class="identifier">main</span><span class="special">()</span>
+<span class="special">{</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">handle</span><span class="special">&lt;</span> <span class="keyword">long</span> <span class="special">&gt;</span> <span class="identifier">h</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">async</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">new_thread</span><span class="special">(),</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">make_task</span><span class="special">(</span>
+ <span class="identifier">fibonacci</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">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"id == "</span> <span class="special">&lt;&lt;</span> <span class="identifier">h</span><span class="special">.</span><span class="identifier">get_id</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="string">"\n"</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">"is ready == "</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">boolalpha</span> <span class="special">&lt;&lt;</span> <span class="identifier">h</span><span class="special">.</span><span class="identifier">is_ready</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="string">"\n"</span><span class="special">;</span>
+ <span class="identifier">h</span><span class="special">.</span><span class="identifier">wait</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">"has value == "</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">boolalpha</span> <span class="special">&lt;&lt;</span> <span class="identifier">h</span><span class="special">.</span><span class="identifier">has_value</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="string">"\n"</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">"has exception == "</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">boolalpha</span> <span class="special">&lt;&lt;</span> <span class="identifier">h</span><span class="special">.</span><span class="identifier">has_exception</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="string">"\n"</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(10) == "</span> <span class="special">&lt;&lt;</span> <span class="identifier">h</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="special">}</span>
+</pre>
+<p>
+ </p>
+<a name="boost_task.async_completion_token.handle._task_interruption_task_interruption"></a><h5>
+<a name="id639994"></a>
+ <a class="link" href="async_completion_token.html#boost_task.async_completion_token.handle._task_interruption_task_interruption">:task_interruption
+ Task interruption</a>
+ </h5>
+<div class="itemizedlist"><ul class="itemizedlist" type="disc">
+<li class="listitem">
+<code class="computeroutput"><span class="identifier">interrupt</span><span class="special">()</span></code>:
+ interrupt <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">task</span></code> and return immediately
+ </li>
+<li class="listitem">
+ __fn_interrupt_and<span class="underline">wait</span>_: interrupt
+ and wait until <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">task</span></code> was removed from <span class="emphasis"><em>worker-thread</em></span>
+</li>
+<li class="listitem">
+<code class="computeroutput"><span class="identifier">interrupt_and_wait_for</span><span class="special">()</span></code>: interrupt and wait until <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">task</span></code> was removed from <span class="emphasis"><em>worker-thread</em></span>
+ or time duration has elapsed
+ </li>
+<li class="listitem">
+<code class="computeroutput"><span class="identifier">interrupt_and_wait_until</span><span class="special">()</span></code>: interrupt and wait until <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">task</span></code> was removed from <span class="emphasis"><em>worker-thread</em></span>
+ or time point has elapsed
+ </li>
+<li class="listitem">
+<code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">this_thread</span><span class="special">::</span><span class="identifier">interruption_requested</span><span class="special">()</span></code>:
+ return bool if interruption was requested
+ </li>
+</ul></div>
+<p>
+
+</p>
+<pre class="programlisting"><span class="keyword">long</span> <span class="identifier">cooperative</span><span class="special">(</span> <span class="keyword">long</span> <span class="identifier">n</span><span class="special">)</span>
+<span class="special">{</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">this_thread</span><span class="special">::</span><span class="identifier">interruption_point</span><span class="special">();</span> <span class="comment">// interruption point
+</span>
+ <span class="keyword">if</span> <span class="special">(</span> <span class="identifier">n</span> <span class="special">==</span> <span class="number">0</span><span class="special">)</span> <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span>
+ <span class="keyword">if</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="keyword">return</span> <span class="number">1</span><span class="special">;</span>
+ <span class="keyword">long</span> <span class="identifier">k1</span><span class="special">(</span> <span class="number">1</span><span class="special">),</span> <span class="identifier">k2</span><span class="special">(</span> <span class="number">0</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">2</span><span class="special">);</span> <span class="identifier">i</span> <span class="special">&lt;=</span> <span class="identifier">n</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span>
+ <span class="special">{</span>
+ <span class="keyword">if</span> <span class="special">(</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">this_thread</span><span class="special">::</span><span class="identifier">interruption_requested</span><span class="special">()</span> <span class="special">)</span> <span class="comment">// check if interruption was requested
+</span> <span class="keyword">return</span><span class="special">;</span>
+
+ <span class="keyword">long</span> <span class="identifier">tmp</span><span class="special">(</span> <span class="identifier">k1</span><span class="special">);</span>
+ <span class="identifier">k1</span> <span class="special">=</span> <span class="identifier">k1</span> <span class="special">+</span> <span class="identifier">k2</span><span class="special">;</span>
+ <span class="identifier">k2</span> <span class="special">=</span> <span class="identifier">tmp</span><span class="special">;</span>
+ <span class="special">}</span>
+
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">this_thread</span><span class="special">::</span><span class="identifier">interruption_point</span><span class="special">();</span> <span class="comment">// interruption point
+</span>
+ <span class="keyword">return</span> <span class="identifier">k1</span><span class="special">;</span>
+<span class="special">}</span>
+
+<span class="keyword">void</span> <span class="identifier">main</span><span class="special">()</span>
+<span class="special">{</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">handle</span><span class="special">&lt;</span> <span class="keyword">long</span> <span class="special">&gt;</span> <span class="identifier">h</span><span class="special">(</span> <span class="comment">// get handle associated with the task
+</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">async</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">new_thread</span><span class="special">(),</span> <span class="comment">// asynchronous executor
+</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">make_task</span><span class="special">(</span> <span class="comment">// task, to be executed asynchronously
+</span> <span class="identifier">cooperative</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">h</span><span class="special">.</span><span class="identifier">interrupt_and_wait</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">"id == "</span> <span class="special">&lt;&lt;</span> <span class="identifier">h</span><span class="special">.</span><span class="identifier">get_id</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="string">"\n"</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">"is ready == "</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">boolalpha</span> <span class="special">&lt;&lt;</span> <span class="identifier">h</span><span class="special">.</span><span class="identifier">is_ready</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="string">"\n"</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">"has value == "</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">boolalpha</span> <span class="special">&lt;&lt;</span> <span class="identifier">h</span><span class="special">.</span><span class="identifier">has_value</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="string">"\n"</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">"has exception == "</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">boolalpha</span> <span class="special">&lt;&lt;</span> <span class="identifier">h</span><span class="special">.</span><span class="identifier">has_exception</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="string">"\n"</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">h</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">// throws boost::task::task_interrupted
+</span><span class="special">}</span>
+</pre>
+<p>
+ </p>
+</div>
+<div class="footnotes">
+<br><hr width="100" align="left">
+<div class="footnote"><p><sup>[<a name="ftn.id638673" href="#id638673" class="para">3</a>] </sup>
+ see <a href="http://www.cs.wustl.edu/~schmidt/PDF/ACT.pdf" target="_top">'Asynchronous
+ Completion Token'</a>, Douglas Schmidt
+ </p></div>
+</div>
+</div>
+<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
+<td align="left"></td>
+<td align="right"><div class="copyright-footer">Copyright © 2009 Oliver Kowalke<p>
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ </p>
+</div></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="callable.html"><img src="../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="async_executor.html"><img src="../../../doc/html/images/next.png" alt="Next"></a>
+</div>
+</body>
+</html>

Added: sandbox/task/libs/task/doc/html/boost_task/async_executor.html
==============================================================================
--- (empty file)
+++ sandbox/task/libs/task/doc/html/boost_task/async_executor.html 2009-06-01 08:13:01 EDT (Mon, 01 Jun 2009)
@@ -0,0 +1,944 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>Asynchronous executor</title>
+<link rel="stylesheet" href="../boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.75.0">
+<link rel="home" href="../index.html" title="Chapter 1. Boost.Task">
+<link rel="up" href="../index.html" title="Chapter 1. Boost.Task">
+<link rel="prev" href="handle.html" title="Handle">
+<link rel="next" href="utilities.html" title="Utilities">
+</head>
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<table cellpadding="2" width="100%"><tr>
+<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td>
+<td align="center">Home</td>
+<td align="center">Libraries</td>
+<td align="center">People</td>
+<td align="center">FAQ</td>
+<td align="center">More</td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="handle.html"><img src="../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="utilities.html"><img src="../../../doc/html/images/next.png" alt="Next"></a>
+</div>
+<div class="section" title="Asynchronous executor">
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="boost_task.async_executor"></a><a class="link" href="async_executor.html" title="Asynchronous executor"> Asynchronous executor</a>
+</h2></div></div></div>
+<div class="toc"><dl>
+<dt><span class="section"> boost::task::own_thread</span></dt>
+<dt><span class="section"> boost::task::new_thread</span></dt>
+<dt><span class="section"> Thread pool</span></dt>
+<dt><span class="section"> boost::task::as_sub_task</span></dt>
+</dl></div>
+<p>
+ In contrast to synchronous methods asynchronous methods do not block the program
+ flow when a time consuming operation is executed. The application continues
+ executing the current context and when the result of the asynchronous method
+ is required the <span class="emphasis"><em>asynchronous-completion-token</em></span> can be used.
+ </p>
+<p>
+ An <span class="emphasis"><em>asynchronous-executor</em></span> executes a <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">task</span></code> asynchronously and provides a link<span class="underline">handle(</span><span class="underline">act</span>_)
+ to manage the <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">task</span></code>.
+ </p>
+<div class="section" title="boost::task::own_thread">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_task.async_executor.own_thread"></a><a class="link" href="async_executor.html#boost_task.async_executor.own_thread" title="boost::task::own_thread"> <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">own_thread</span></code></a>
+</h3></div></div></div>
+<p>
+ <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">own_thread</span></code> executes the task in the current
+ thread (synchronous execution - concerns of N2802
+ do not aply).
+ </p>
+<p>
+
+</p>
+<pre class="programlisting"><span class="keyword">long</span> <span class="identifier">fibonacci</span><span class="special">(</span> <span class="keyword">long</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">==</span> <span class="number">0</span><span class="special">)</span> <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span>
+ <span class="keyword">if</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="keyword">return</span> <span class="number">1</span><span class="special">;</span>
+ <span class="keyword">long</span> <span class="identifier">k1</span><span class="special">(</span> <span class="number">1</span><span class="special">),</span> <span class="identifier">k2</span><span class="special">(</span> <span class="number">0</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">2</span><span class="special">);</span> <span class="identifier">i</span> <span class="special">&lt;=</span> <span class="identifier">n</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span>
+ <span class="special">{</span>
+ <span class="keyword">long</span> <span class="identifier">tmp</span><span class="special">(</span> <span class="identifier">k1</span><span class="special">);</span>
+ <span class="identifier">k1</span> <span class="special">=</span> <span class="identifier">k1</span> <span class="special">+</span> <span class="identifier">k2</span><span class="special">;</span>
+ <span class="identifier">k2</span> <span class="special">=</span> <span class="identifier">tmp</span><span class="special">;</span>
+ <span class="special">}</span>
+ <span class="keyword">return</span> <span class="identifier">k1</span><span class="special">;</span>
+<span class="special">}</span>
+
+<span class="keyword">void</span> <span class="identifier">main</span><span class="special">()</span>
+<span class="special">{</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">handle</span><span class="special">&lt;</span> <span class="keyword">long</span> <span class="special">&gt;</span> <span class="identifier">h</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">async</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">own_thread</span><span class="special">(),</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">make_task</span><span class="special">(</span>
+ <span class="identifier">fibonacci</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">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"fibonacci(10) == "</span> <span class="special">&lt;&lt;</span> <span class="identifier">h</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="special">}</span>
+</pre>
+<p>
+ </p>
+</div>
+<div class="section" title="boost::task::new_thread">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_task.async_executor.new_thread"></a><a class="link" href="async_executor.html#boost_task.async_executor.new_thread" title="boost::task::new_thread"> <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">new_thread</span></code></a>
+</h3></div></div></div>
+<p>
+ _new<span class="underline">thread</span>_ creates a new <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">thread</span></code> and executes the task in this thread
+ (asynchronous). The created thread gets joined by handle.
+ </p>
+<div class="caution" title="Caution"><table border="0" summary="Caution">
+<tr>
+<td rowspan="2" align="center" valign="top" width="25"><img alt="[Caution]" src="../../../doc/html/images/caution.png"></td>
+<th align="left">Caution</th>
+</tr>
+<tr><td align="left" valign="top"><p>
+ Always store the returned <span class="emphasis"><em>asynchronous-completion-token</em></span>
+ in a variable because <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">handle</span></code>
+ joins the thread in its destructor (if the last reference gets out of scope).
+ </p></td></tr>
+</table></div>
+<p>
+ The topic of N2802
+ should be addressed.
+ </p>
+<p>
+
+</p>
+<pre class="programlisting"><span class="keyword">long</span> <span class="identifier">fibonacci</span><span class="special">(</span> <span class="keyword">long</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">==</span> <span class="number">0</span><span class="special">)</span> <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span>
+ <span class="keyword">if</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="keyword">return</span> <span class="number">1</span><span class="special">;</span>
+ <span class="keyword">long</span> <span class="identifier">k1</span><span class="special">(</span> <span class="number">1</span><span class="special">),</span> <span class="identifier">k2</span><span class="special">(</span> <span class="number">0</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">2</span><span class="special">);</span> <span class="identifier">i</span> <span class="special">&lt;=</span> <span class="identifier">n</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span>
+ <span class="special">{</span>
+ <span class="keyword">long</span> <span class="identifier">tmp</span><span class="special">(</span> <span class="identifier">k1</span><span class="special">);</span>
+ <span class="identifier">k1</span> <span class="special">=</span> <span class="identifier">k1</span> <span class="special">+</span> <span class="identifier">k2</span><span class="special">;</span>
+ <span class="identifier">k2</span> <span class="special">=</span> <span class="identifier">tmp</span><span class="special">;</span>
+ <span class="special">}</span>
+ <span class="keyword">return</span> <span class="identifier">k1</span><span class="special">;</span>
+<span class="special">}</span>
+
+<span class="keyword">void</span> <span class="identifier">main</span><span class="special">()</span>
+<span class="special">{</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">handle</span><span class="special">&lt;</span> <span class="keyword">long</span> <span class="special">&gt;</span> <span class="identifier">h</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">async</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">new_thread</span><span class="special">(),</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">make_task</span><span class="special">(</span>
+ <span class="identifier">fibonacci</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">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"fibonacci(10) == "</span> <span class="special">&lt;&lt;</span> <span class="identifier">h</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="special">}</span>
+</pre>
+<p>
+ </p>
+<p>
+ In the example below both <code class="computeroutput"><span class="identifier">a_function</span></code>
+ and <code class="computeroutput"><span class="identifier">another_function</span></code> are
+ executed synchron (see link_own<span class="underline">thread[</span>_own<span class="underline">thread</span>_] for synchronous execution)!
+ </p>
+<p>
+
+</p>
+<pre class="programlisting"> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">async</span><span class="special">(</span>
+<span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">new_thread</span><span class="special">(),</span>
+<span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">make_task</span><span class="special">(</span>
+ <span class="identifier">a_function</span><span class="special">)</span> <span class="special">)</span> <span class="special">);</span>
+
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">async</span><span class="special">(</span>
+<span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">new_thread</span><span class="special">(),</span>
+<span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">make_task</span><span class="special">(</span>
+ <span class="identifier">another_function</span><span class="special">)</span> <span class="special">)</span> <span class="special">);</span>
+</pre>
+<p>
+ </p>
+</div>
+<div class="section" title="Thread pool">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_task.async_executor.pool"></a><a class="link" href="async_executor.html#boost_task.async_executor.pool" title="Thread pool"> Thread pool</a>
+</h3></div></div></div>
+<div class="toc"><dl>
+<dt><span class="section"> boost::task::static_pool</span></dt>
+<dt><span class="section"> Channel</span></dt>
+<dt><span class="section"> Scheduling</span></dt>
+<dt><span class="section"><a href="async_executor.html#boost_task.async_executor.pool.pool_shutdown"> Pool
+ shutdown</a></span></dt>
+<dt><span class="section"><a href="async_executor.html#boost_task.async_executor.pool.default_pool"> Default
+ pool</a></span></dt>
+<dt><span class="section"><a href="async_executor.html#boost_task.async_executor.pool.processor_binding">
+ Processor binding</a></span></dt>
+<dt><span class="section"> Work-Stealing</span></dt>
+<dt><span class="section"> Fork/Join</span></dt>
+</dl></div>
+<p>
+ Instead of creating a new thread and quickly throwing it away after the task
+ is done, the overhead related to thread creation and destruction can be avoided
+ by running the <span class="emphasis"><em>work-items</em></span> on a <span class="emphasis"><em>thread-pool</em></span>
+ (reusing an existing <span class="underline">_worker</span><span class="underline">thread</span>_ instead).
+ </p>
+<p>
+ A <span class="emphasis"><em>thread-pool</em></span> maintains a queue (or queues) of <span class="emphasis"><em>work-items</em></span>
+ to be done, and a pool of <span class="emphasis"><em>worker-threads</em></span> which execute
+ <span class="emphasis"><em>work-items</em></span> from the queue(s).
+ </p>
+<p>
+ <span class="bold"><strong>Boost.Task</strong></span> provides <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">async</span><span class="special">()</span></code> with support of executing an <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">task</span></code> in <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">default_pool</span></code>
+ (using <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">default_pool</span><span class="special">()</span></code>):
+ </p>
+<p>
+
+</p>
+<pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="identifier">echo</span><span class="special">(</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">msg</span><span class="special">)</span>
+<span class="special">{</span> <span class="keyword">return</span> <span class="identifier">msg</span><span class="special">;</span> <span class="special">}</span>
+
+<span class="keyword">void</span> <span class="identifier">main</span><span class="special">()</span>
+<span class="special">{</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">handle</span><span class="special">&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="special">&gt;</span> <span class="identifier">h</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">async</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">default_pool</span><span class="special">(),</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">make_task</span><span class="special">(</span>
+ <span class="identifier">echo</span><span class="special">,</span>
+ <span class="string">"Hello World!"</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">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">h</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="special">}</span>
+</pre>
+<p>
+ </p>
+<p>
+ and a custom <span class="emphasis"><em>thread-pool</em></span> (passing pool instance as an
+ argument to <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">async</span><span class="special">()</span></code>):
+ </p>
+<p>
+
+</p>
+<pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="identifier">echo</span><span class="special">(</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">msg</span><span class="special">)</span>
+<span class="special">{</span> <span class="keyword">return</span> <span class="identifier">msg</span><span class="special">;</span> <span class="special">}</span>
+
+<span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">static_pool</span><span class="special">&lt;</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</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">task</span><span class="special">::</span><span class="identifier">fifo</span>
+ <span class="special">&gt;</span>
+<span class="special">&gt;</span> <span class="identifier">pool</span><span class="special">(</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">poolsize</span><span class="special">(</span> <span class="number">5</span><span class="special">)</span> <span class="special">);</span>
+
+<span class="keyword">void</span> <span class="identifier">main</span><span class="special">()</span>
+<span class="special">{</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">handle</span><span class="special">&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="special">&gt;</span> <span class="identifier">h</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">async</span><span class="special">(</span>
+ <span class="identifier">pool</span><span class="special">,</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">make_task</span><span class="special">(</span>
+ <span class="identifier">echo</span><span class="special">,</span>
+ <span class="string">"Hello World!"</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">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">h</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="special">}</span>
+</pre>
+<p>
+ .
+ </p>
+<div class="important" title="Important"><table border="0" summary="Important">
+<tr>
+<td rowspan="2" align="center" valign="top" width="25"><img alt="[Important]" src="../../../doc/html/images/important.png"></td>
+<th align="left">Important</th>
+</tr>
+<tr><td align="left" valign="top"><p>
+ <span class="underline">_tasks</span>_ should not be too small (performance
+ overhead dominates) and avoid blocking <span class="underline">_tasks</span>_
+ <sup>[<a name="id665925" href="#ftn.id665925" class="footnote">4</a>]</sup>
+ .
+ </p></td></tr>
+</table></div>
+<div class="section" title="boost::task::static_pool">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_task.async_executor.pool.static_pool"></a><a class="link" href="async_executor.html#boost_task.async_executor.pool.static_pool" title="boost::task::static_pool"> <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">static_pool</span></code></a>
+</h4></div></div></div>
+<p>
+ <span class="bold"><strong>Boost.Task</strong></span> provides <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">static_pool</span></code>
+ - which contains an fixed set of pre-forked <span class="emphasis"><em>worker-threads</em></span>
+ (the size of the pool doesn't change during its lifetime).
+ </p>
+<p>
+
+</p>
+<pre class="programlisting"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">_static_pool</span><span class="special">&lt;</span> <span class="comment">// pool type
+</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">unbounded_channel</span><span class="special">&lt;</span> <span class="comment">// queuing policy (unbounded_channel, bounded_channel)
+</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">fifo</span> <span class="comment">// scheduling policy (fifo, priority, smart)
+</span> <span class="special">&gt;</span>
+<span class="special">&gt;</span> <span class="identifier">pool</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">poolsize</span><span class="special">(</span> <span class="number">6</span><span class="special">),</span> <span class="comment">// pool with 6 pre-forked worker-threads
+</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">posix_time</span><span class="special">::</span><span class="identifier">posix_time</span><span class="special">::</span><span class="identifier">milliseconds</span><span class="special">(</span> <span class="number">50</span><span class="special">),</span> <span class="comment">// time to sleep if no work-item available
+</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">scanns</span><span class="special">(</span> <span class="number">10</span><span class="special">)</span> <span class="special">);</span> <span class="comment">// iterations over local-queues before sleep
+</span></pre>
+<p>
+ </p>
+<p>
+ The first argument of the constructor specifies how many <span class="emphasis"><em>worker-threads</em></span>
+ the pool will contain. The second and third argument are used by the link_work<span class="underline">stealing[</span>_work<span class="underline">stealing</span>_]
+ algorithm.
+ </p>
+<div class="note" title="Note"><table border="0" summary="Note">
+<tr>
+<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../doc/html/images/note.png"></td>
+<th align="left">Note</th>
+</tr>
+<tr><td align="left" valign="top"><p>
+ If <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">bounded_channel</span></code> is used as queuing
+ policy the constructor has two additional arguments .
+ </p></td></tr>
+</table></div>
+<p>
+ <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">static_pool</span></code> provides functionality to
+ check the status of the pool - <code class="computeroutput"><span class="identifier">close</span><span class="special">()</span></code> returns true when the pool was shutdown
+ and <code class="computeroutput"><span class="identifier">active</span><span class="special">()</span></code>
+ as well as <span class="underline">_fn</span><span class="underline">idle</span>_
+ returning how many <span class="emphasis"><em>worker-threads</em></span> are active (executing
+ a task) or idle. The size of the pool can be accessed over <code class="computeroutput"><span class="identifier">size</span><span class="special">()</span></code>.
+ </p>
+<p>
+ For infomational pruposes <code class="computeroutput"><span class="identifier">empty</span><span class="special">()</span></code> and <code class="computeroutput"><span class="identifier">pending</span><span class="special">()()</span></code> can be used in order to know if the
+ global task-queue is empty or how many <span class="underline">_tasks</span>_
+ are waiting for execution. __fn<span class="underline">clear</span>_
+ removes all <span class="underline">_tasks</span>_ from the global-queue.
+ </p>
+<div class="note" title="Note"><table border="0" summary="Note">
+<tr>
+<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../doc/html/images/note.png"></td>
+<th align="left">Note</th>
+</tr>
+<tr><td align="left" valign="top"><p>
+ <code class="computeroutput"><span class="identifier">pending</span><span class="special">()()</span></code>
+ does not count <span class="underline">_tasks</span>_ in the local-queues
+ of the <span class="emphasis"><em>worker-threads</em></span>.
+ </p></td></tr>
+</table></div>
+</div>
+<div class="section" title="Channel">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_task.async_executor.pool.channel"></a><a class="link" href="async_executor.html#boost_task.async_executor.pool.channel" title="Channel"> Channel</a>
+</h4></div></div></div>
+<p>
+ The channel synchronizes the access between non-pool threads (application
+ threads) and <span class="emphasis"><em>worker-threads</em></span> and implements a queuing
+ policy (limitation of queued <span class="underline">tasks</span>_).
+ </p>
+<a name="boost_task.async_executor.pool.channel._code__phrase_role__identifier__boost__phrase__phrase_role__special______phrase__phrase_role__identifier__task__phrase__phrase_role__special______phrase__phrase_role__identifier__bounded_channel__phrase___code_"></a><h6>
+<a name="id666571"></a>
+ <a class="link" href="async_executor.html#boost_task.async_executor.pool.channel._code__phrase_role__identifier__boost__phrase__phrase_role__special______phrase__phrase_role__identifier__task__phrase__phrase_role__special______phrase__phrase_role__identifier__bounded_channel__phrase___code_"><code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">bounded_channel</span></code></a>
+ </h6>
+<p>
+ <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">bounded_channel</span></code> contains a single lock
+ in order to synchronize access to the queue. The number of pending <span class="underline">_tasks</span>_ is limited in order to prevent resource
+ exhaustion. For this purpose a high- and low-watermark has to be passed
+ at construction. <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">high_watermark</span></code>
+ sets the maximum of pending tasks. If this limited is reached all threads
+ which submit a task will be set to sleep (blocked). If it is equal to
+ <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">low_watermark</span></code> everytime a sleeping producer
+ thread will be woken up and puts its task if one worker thread has taken
+ a task from the channel. <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">low_watermark</span></code>
+ sets the threshold when blocked threads get woken up. If it is less than
+ <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">high_watermark</span></code> all sleeping producer
+ threads will be woken up if the amount of pending tasks reaches <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">low_watermark</span></code>.
+ </p>
+<a name="boost_task.async_executor.pool.channel._code__phrase_role__identifier__boost__phrase__phrase_role__special______phrase__phrase_role__identifier__task__phrase__phrase_role__special______phrase__phrase_role__identifier__unbounded_channel__phrase___code_"></a><h6>
+<a name="id666810"></a>
+ <a class="link" href="async_executor.html#boost_task.async_executor.pool.channel._code__phrase_role__identifier__boost__phrase__phrase_role__special______phrase__phrase_role__identifier__task__phrase__phrase_role__special______phrase__phrase_role__identifier__unbounded_channel__phrase___code_"><code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">unbounded_channel</span></code></a>
+ </h6>
+<p>
+ <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">unbounded_channel</span></code> contains a single lock
+ in order to synchronize access to the queue. An unlimited number of <span class="underline">_tasks</span>_ can be queued into this channel. The
+ insertion of an <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">task</span></code> will never block. If the channel
+ becomes empty <span class="emphasis"><em>worker-threads</em></span> will be set to sleep
+ until new <span class="underline">_tasks</span>_ are enqueued.
+ </p>
+</div>
+<div class="section" title="Scheduling">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_task.async_executor.pool.scheduling"></a><a class="link" href="async_executor.html#boost_task.async_executor.pool.scheduling" title="Scheduling"> Scheduling</a>
+</h4></div></div></div>
+<p>
+ The scheduling policy determines how <span class="underline">_tasks</span>_
+ are scheduled inside the <span class="underline">_channel</span>_.
+ </p>
+<a name="boost_task.async_executor.pool.scheduling.fifo"></a><h6>
+<a name="id666972"></a>
+ <a class="link" href="async_executor.html#boost_task.async_executor.pool.scheduling.fifo">fifo</a>
+ </h6>
+<p>
+ First inserted pending <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">task</span></code>
+ gets taken first.
+ </p>
+<a name="boost_task.async_executor.pool.scheduling.priority"></a><h6>
+<a name="id667024"></a>
+ <a class="link" href="async_executor.html#boost_task.async_executor.pool.scheduling.priority">priority</a>
+ </h6>
+<p>
+ Each <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">task</span></code> is submitted to the pool with a
+ priority attribute. The type and ordering of the priority is user-defined.
+ </p>
+<p>
+
+</p>
+<pre class="programlisting"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">static_pool</span><span class="special">&lt;</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">unbounded_channel</span><span class="special">&lt;</span> <span class="comment">// allow unlimited tasks to be queue in global-queue
+</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">priority</span><span class="special">&lt;</span> <span class="keyword">int</span> <span class="special">&gt;</span> <span class="special">&gt;</span> <span class="comment">// tasks with lower priority are scheduled first
+</span><span class="special">&gt;</span> <span class="identifier">pool</span><span class="special">(</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">poolsize</span><span class="special">(</span> <span class="number">5</span><span class="special">)</span> <span class="special">);</span>
+
+<span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">async</span><span class="special">(</span>
+ <span class="identifier">pool</span><span class="special">,</span> <span class="comment">// thread-pool
+</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">make_task</span><span class="special">(</span> <span class="identifier">some_fn</span><span class="special">),</span> <span class="comment">// task to be executed
+</span> <span class="number">5</span><span class="special">);</span> <span class="comment">// priority is 5
+</span>
+<span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">async</span><span class="special">(</span>
+ <span class="identifier">pool</span><span class="special">,</span> <span class="comment">// thread-pool
+</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">make_task</span><span class="special">(</span> <span class="identifier">another_fn</span><span class="special">),</span> <span class="comment">// task to be executed
+</span> <span class="number">3</span><span class="special">);</span> <span class="comment">// priority is 3
+</span></pre>
+<p>
+ </p>
+<p>
+ In this example the <span class="underline">_tasks</span>_ get scheduled
+ by the assigned integer (third argument of <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">async</span><span class="special">()</span></code>). The <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">task</span></code>
+ with the lowest priority gets scheduled first (taken by a <span class="emphasis"><em>worker-thread</em></span>).
+ The ordering can be changed by the second argument of <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">priority</span></code>
+ (the default is <code class="computeroutput"><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></code>).
+ </p>
+<p>
+
+</p>
+<pre class="programlisting"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">static_pool</span><span class="special">&lt;</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</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">task</span><span class="special">::</span><span class="identifier">priority</span><span class="special">&lt;</span> <span class="keyword">int</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">greater</span><span class="special">&lt;</span> <span class="keyword">int</span> <span class="special">&gt;</span> <span class="special">&gt;</span> <span class="special">&gt;</span> <span class="comment">// tasks with higher priority are scheduled first
+</span>
+<span class="special">&gt;</span> <span class="identifier">pool</span><span class="special">(</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">poolsize</span><span class="special">(</span> <span class="number">5</span><span class="special">)</span> <span class="special">);</span>
+</pre>
+<p>
+ </p>
+<a name="boost_task.async_executor.pool.scheduling.smart"></a><h6>
+<a name="id667817"></a>
+ <a class="link" href="async_executor.html#boost_task.async_executor.pool.scheduling.smart">smart</a>
+ </h6>
+<p>
+ Each inserted <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">task</span></code> is associated with an attribute.
+ The scheduler gets an put- and take-policy as template arguments. The corresponding
+ policy gets applied for each insertion and removal.
+ </p>
+<p>
+ <span class="bold"><strong>Boost.Task</strong></span> provides <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">replace_oldest</span></code>
+ as put- policy and <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">take_oldest</span></code>
+ as take-policy. Both policies allow the replacement of older (pending)
+ <span class="underline">_tasks</span>_ in the scheduler by new ones.
+ </p>
+<pre class="programlisting"><span class="comment">// creates a pool with unbounded channel
+</span><span class="comment">// tasks are processed depending on the associated attributed
+</span><span class="comment">// oldest tasks with the same attributed pending in the channel
+</span><span class="comment">// will be replaced by the new task
+</span><span class="comment">// this example would execute add( 1, 2) and add( 5, 6)
+</span><span class="comment">// add( 2, 3) is removed (if pending when add( 5, 6) is submitted)
+</span></pre>
+<p>
+
+</p>
+<pre class="programlisting"><span class="keyword">long</span> <span class="identifier">fibonacci_fn</span><span class="special">(</span> <span class="keyword">long</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">==</span> <span class="number">0</span><span class="special">)</span> <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span>
+ <span class="keyword">if</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="keyword">return</span> <span class="number">1</span><span class="special">;</span>
+ <span class="keyword">long</span> <span class="identifier">k1</span><span class="special">(</span> <span class="number">1</span><span class="special">),</span> <span class="identifier">k2</span><span class="special">(</span> <span class="number">0</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">2</span><span class="special">);</span> <span class="identifier">i</span> <span class="special">&lt;=</span> <span class="identifier">n</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span>
+ <span class="special">{</span>
+ <span class="keyword">long</span> <span class="identifier">tmp</span><span class="special">(</span> <span class="identifier">k1</span><span class="special">);</span>
+ <span class="identifier">k1</span> <span class="special">=</span> <span class="identifier">k1</span> <span class="special">+</span> <span class="identifier">k2</span><span class="special">;</span>
+ <span class="identifier">k2</span> <span class="special">=</span> <span class="identifier">tmp</span><span class="special">;</span>
+ <span class="special">}</span>
+ <span class="keyword">return</span> <span class="identifier">k1</span><span class="special">;</span>
+<span class="special">}</span>
+
+<span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">static_pool</span><span class="special">&lt;</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</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">task</span><span class="special">::</span><span class="identifier">smart</span><span class="special">&lt;</span>
+ <span class="keyword">int</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="keyword">int</span> <span class="special">&gt;,</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">replace_oldest</span><span class="special">,</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">take_oldest</span>
+ <span class="special">&gt;</span>
+ <span class="special">&gt;</span>
+<span class="special">&gt;</span> <span class="identifier">pool_type</span><span class="special">;</span>
+
+<span class="keyword">void</span> <span class="identifier">main</span><span class="special">()</span>
+<span class="special">{</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">task</span><span class="special">::</span><span class="identifier">poolsize</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">// replaced by later task with same attribute == 2
+</span> <span class="comment">// if still pending in pool
+</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">async</span><span class="special">(</span>
+ <span class="identifier">pool</span><span class="special">,</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">make_task</span><span class="special">(</span> <span class="identifier">fibonacci_fn</span><span class="special">,</span> <span class="number">10</span><span class="special">),</span>
+ <span class="number">2</span><span class="special">);</span> <span class="comment">// attribute is 2
+</span>
+ <span class="comment">// will replace previous pending task with attribute == 2
+</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">async</span><span class="special">(</span>
+ <span class="identifier">pool</span><span class="special">,</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">make_task</span><span class="special">(</span> <span class="identifier">fibonacci_fn</span><span class="special">,</span> <span class="number">5</span><span class="special">),</span>
+ <span class="number">2</span><span class="special">);</span> <span class="comment">// attribute is 2 too
+</span><span class="special">}</span>
+</pre>
+<p>
+ </p>
+</div>
+<div class="section" title="Pool shutdown">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_task.async_executor.pool.pool_shutdown"></a><a class="link" href="async_executor.html#boost_task.async_executor.pool.pool_shutdown" title="Pool shutdown"> Pool
+ shutdown</a>
+</h4></div></div></div>
+<p>
+ <span class="bold"><strong>Boost.Task</strong></span> allows to shutdown a <span class="emphasis"><em>thread-pool</em></span>
+ explicitly via functions <code class="computeroutput"><span class="identifier">shutdown</span><span class="special">()</span></code> and <code class="computeroutput"><span class="identifier">shutdown_now</span><span class="special">()</span></code>. The destructor of the pool calls <code class="computeroutput"><span class="identifier">shutdown</span><span class="special">()</span></code>
+ if not already done so that all <span class="emphasis"><em>worker-threads</em></span> are
+ joined and the topic of N2802
+ should be addressed.
+ </p>
+<a name="boost_task.async_executor.pool.pool_shutdown.shutdown"></a><h6>
+<a name="id668957"></a>
+ <a class="link" href="async_executor.html#boost_task.async_executor.pool.pool_shutdown.shutdown">Shutdown</a>
+ </h6>
+<p>
+ If <code class="computeroutput"><span class="identifier">shutdown</span><span class="special">()</span></code>
+ is called - the the pool is set the closed state and all <span class="emphasis"><em>worker-threads</em></span>
+ are joined until all pending <span class="underline">_tasks</span>_
+ are processed. No futher <span class="underline">_tasks</span>_
+ can be submitted.
+ </p>
+<div class="note" title="Note"><table border="0" summary="Note">
+<tr>
+<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../doc/html/images/note.png"></td>
+<th align="left">Note</th>
+</tr>
+<tr><td align="left" valign="top"><p>
+ The deconstructor calls <code class="computeroutput"><span class="identifier">shutdown</span><span class="special">()</span></code> if the pool was not shutdown yet.
+ </p></td></tr>
+</table></div>
+<p>
+
+</p>
+<pre class="programlisting"><span class="keyword">long</span> <span class="identifier">fibonacci_fn</span><span class="special">(</span> <span class="keyword">long</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">==</span> <span class="number">0</span><span class="special">)</span> <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span>
+ <span class="keyword">if</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="keyword">return</span> <span class="number">1</span><span class="special">;</span>
+ <span class="keyword">long</span> <span class="identifier">k1</span><span class="special">(</span> <span class="number">1</span><span class="special">),</span> <span class="identifier">k2</span><span class="special">(</span> <span class="number">0</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">2</span><span class="special">);</span> <span class="identifier">i</span> <span class="special">&lt;=</span> <span class="identifier">n</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span>
+ <span class="special">{</span>
+ <span class="keyword">long</span> <span class="identifier">tmp</span><span class="special">(</span> <span class="identifier">k1</span><span class="special">);</span>
+ <span class="identifier">k1</span> <span class="special">=</span> <span class="identifier">k1</span> <span class="special">+</span> <span class="identifier">k2</span><span class="special">;</span>
+ <span class="identifier">k2</span> <span class="special">=</span> <span class="identifier">tmp</span><span class="special">;</span>
+ <span class="special">}</span>
+ <span class="keyword">return</span> <span class="identifier">k1</span><span class="special">;</span>
+<span class="special">}</span>
+
+<span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">static_pool</span><span class="special">&lt;</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</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">task</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">void</span> <span class="identifier">main</span><span class="special">()</span>
+<span class="special">{</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">task</span><span class="special">::</span><span class="identifier">poolsize</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">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">handle</span><span class="special">&lt;</span> <span class="keyword">long</span> <span class="special">&gt;</span> <span class="identifier">h1</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">async</span><span class="special">(</span>
+ <span class="identifier">pool</span><span class="special">,</span> <span class="comment">// asynchronous executor
+</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">make_task</span><span class="special">(</span> <span class="identifier">fibonacci_fn</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">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">handle</span><span class="special">&lt;</span> <span class="keyword">long</span> <span class="special">&gt;</span> <span class="identifier">h2</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">async</span><span class="special">(</span>
+ <span class="identifier">pool</span><span class="special">,</span> <span class="comment">// asynchronous executor
+</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">make_task</span><span class="special">(</span> <span class="identifier">fibonacci_fn</span><span class="special">,</span> <span class="number">5</span><span class="special">)</span> <span class="special">)</span> <span class="special">);</span>
+
+ <span class="identifier">pool</span><span class="special">.</span><span class="identifier">shutdown</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(10) == "</span> <span class="special">&lt;&lt;</span> <span class="identifier">h1</span><span class="special">.</span><span class="identifier">get</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="string">"\n"</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(5) == "</span> <span class="special">&lt;&lt;</span> <span class="identifier">h2</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="special">}</span>
+</pre>
+<p>
+ </p>
+<a name="boost_task.async_executor.pool.pool_shutdown.shutdown_immediatly"></a><h6>
+<a name="id670068"></a>
+ <a class="link" href="async_executor.html#boost_task.async_executor.pool.pool_shutdown.shutdown_immediatly">Shutdown
+ immediatly</a>
+ </h6>
+<p>
+ The function <code class="computeroutput"><span class="identifier">shutdown_now</span><span class="special">()</span></code> closes the pool, interrupts and then
+ joins all <span class="emphasis"><em>worker-threads</em></span>. Pending <span class="underline">_tasks</span>_
+ are unprocessed.
+ </p>
+<p>
+
+</p>
+<pre class="programlisting"><span class="keyword">long</span> <span class="identifier">fibonacci_fn</span><span class="special">(</span> <span class="keyword">long</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">==</span> <span class="number">0</span><span class="special">)</span> <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span>
+ <span class="keyword">if</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="keyword">return</span> <span class="number">1</span><span class="special">;</span>
+ <span class="keyword">long</span> <span class="identifier">k1</span><span class="special">(</span> <span class="number">1</span><span class="special">),</span> <span class="identifier">k2</span><span class="special">(</span> <span class="number">0</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">2</span><span class="special">);</span> <span class="identifier">i</span> <span class="special">&lt;=</span> <span class="identifier">n</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span>
+ <span class="special">{</span>
+ <span class="keyword">long</span> <span class="identifier">tmp</span><span class="special">(</span> <span class="identifier">k1</span><span class="special">);</span>
+ <span class="identifier">k1</span> <span class="special">=</span> <span class="identifier">k1</span> <span class="special">+</span> <span class="identifier">k2</span><span class="special">;</span>
+ <span class="identifier">k2</span> <span class="special">=</span> <span class="identifier">tmp</span><span class="special">;</span>
+ <span class="special">}</span>
+ <span class="keyword">return</span> <span class="identifier">k1</span><span class="special">;</span>
+<span class="special">}</span>
+
+<span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">static_pool</span><span class="special">&lt;</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</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">task</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">void</span> <span class="identifier">main</span><span class="special">()</span>
+<span class="special">{</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">task</span><span class="special">::</span><span class="identifier">poolsize</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">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">handle</span><span class="special">&lt;</span> <span class="keyword">long</span> <span class="special">&gt;</span> <span class="identifier">h1</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">async</span><span class="special">(</span>
+ <span class="identifier">pool</span><span class="special">,</span> <span class="comment">// asynchronous executor
+</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">make_task</span><span class="special">(</span> <span class="identifier">fibonacci_fn</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">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">handle</span><span class="special">&lt;</span> <span class="keyword">long</span> <span class="special">&gt;</span> <span class="identifier">h2</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">async</span><span class="special">(</span>
+ <span class="identifier">pool</span><span class="special">,</span> <span class="comment">// asynchronous executor
+</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">make_task</span><span class="special">(</span> <span class="identifier">fibonacci_fn</span><span class="special">,</span> <span class="number">5</span><span class="special">)</span> <span class="special">)</span> <span class="special">);</span>
+
+ <span class="identifier">pool</span><span class="special">.</span><span class="identifier">shutdown_now</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(10) == "</span> <span class="special">&lt;&lt;</span> <span class="identifier">h1</span><span class="special">.</span><span class="identifier">get</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="string">"\n"</span><span class="special">;</span> <span class="comment">// may throw broken_task or task_interrupted
+</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(5) == "</span> <span class="special">&lt;&lt;</span> <span class="identifier">h2</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">// may throw broken_task or task_interrupted
+</span><span class="special">}</span>
+</pre>
+<p>
+ </p>
+</div>
+<div class="section" title="Default pool">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_task.async_executor.pool.default_pool"></a><a class="link" href="async_executor.html#boost_task.async_executor.pool.default_pool" title="Default pool"> Default
+ pool</a>
+</h4></div></div></div>
+<p>
+ The library provides a default-pool accessible via <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">default_pool</span><span class="special">()</span></code>. The function returns a reference to
+ <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">static_pool</span><span class="special">&lt;</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</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">task</span><span class="special">::</span><span class="identifier">fifo</span> <span class="special">&gt;</span> <span class="special">&gt;</span></code>. The static instance of <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">default_pool</span></code> contains as many <span class="emphasis"><em>worker-threads</em></span>
+ as <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">thread</span><span class="special">::</span><span class="identifier">hardware_concurrency</span><span class="special">()</span></code>
+ returns, queues unlimited amount of <span class="underline">_tasks</span>_
+ and schedules the <span class="underline">_tasks</span>_ in FIFO-order.
+ </p>
+<p>
+
+</p>
+<pre class="programlisting"><span class="keyword">long</span> <span class="identifier">fibonacci_fn</span><span class="special">(</span> <span class="keyword">long</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">==</span> <span class="number">0</span><span class="special">)</span> <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span>
+ <span class="keyword">if</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="keyword">return</span> <span class="number">1</span><span class="special">;</span>
+ <span class="keyword">long</span> <span class="identifier">k1</span><span class="special">(</span> <span class="number">1</span><span class="special">),</span> <span class="identifier">k2</span><span class="special">(</span> <span class="number">0</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">2</span><span class="special">);</span> <span class="identifier">i</span> <span class="special">&lt;=</span> <span class="identifier">n</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span>
+ <span class="special">{</span>
+ <span class="keyword">long</span> <span class="identifier">tmp</span><span class="special">(</span> <span class="identifier">k1</span><span class="special">);</span>
+ <span class="identifier">k1</span> <span class="special">=</span> <span class="identifier">k1</span> <span class="special">+</span> <span class="identifier">k2</span><span class="special">;</span>
+ <span class="identifier">k2</span> <span class="special">=</span> <span class="identifier">tmp</span><span class="special">;</span>
+ <span class="special">}</span>
+ <span class="keyword">return</span> <span class="identifier">k1</span><span class="special">;</span>
+<span class="special">}</span>
+
+<span class="keyword">void</span> <span class="identifier">main</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="string">"worker-threads running in default-pool == "</span> <span class="special">&lt;&lt;</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">default_pool</span><span class="special">().</span><span class="identifier">size</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="string">"\n"</span><span class="special">;</span>
+
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">handle</span><span class="special">&lt;</span> <span class="keyword">long</span> <span class="special">&gt;</span> <span class="identifier">h1</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">async</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">default_pool</span><span class="special">(),</span> <span class="comment">// asynchronous executor == default-pool
+</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">make_task</span><span class="special">(</span> <span class="identifier">fibonacci_fn</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">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">handle</span><span class="special">&lt;</span> <span class="keyword">long</span> <span class="special">&gt;</span> <span class="identifier">h2</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">async</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">default_pool</span><span class="special">(),</span> <span class="comment">// asynchronous executor == default-pool
+</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">make_task</span><span class="special">(</span> <span class="identifier">fibonacci_fn</span><span class="special">,</span> <span class="number">5</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">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"fibonacci(10) == "</span> <span class="special">&lt;&lt;</span> <span class="identifier">h1</span><span class="special">.</span><span class="identifier">get</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="string">"\n"</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(5) == "</span> <span class="special">&lt;&lt;</span> <span class="identifier">h2</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="special">}</span>
+</pre>
+<p>
+ </p>
+</div>
+<div class="section" title="Processor binding">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_task.async_executor.pool.processor_binding"></a><a class="link" href="async_executor.html#boost_task.async_executor.pool.processor_binding" title="Processor binding">
+ Processor binding</a>
+</h4></div></div></div>
+<p>
+ For some applications it is convenient to bind the <span class="emphasis"><em>worker-threads</em></span>
+ to processors/cores of the system. For this purpose <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">poolsize</span></code>
+ must not be given to the constructor so that a <span class="emphasis"><em>worker-thread</em></span>
+ is created an bound the the core.
+ </p>
+<p>
+
+</p>
+<pre class="programlisting"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">static_pool</span><span class="special">&lt;</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</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</span><span class="special">;</span> <span class="comment">// constructs thread-pool with worker-threads as hardware_concurrency() returns
+</span></pre>
+<p>
+ </p>
+<p>
+ The constructor takes additional arguments for the link_work_stealing[work-stealing
+ algorithm] and link_channel[high-] and link_channel[low-watermark] too.
+ </p>
+<div class="note" title="Note"><table border="0" summary="Note">
+<tr>
+<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../doc/html/images/note.png"></td>
+<th align="left">Note</th>
+</tr>
+<tr><td align="left" valign="top"><p>
+ <span class="bold"><strong>Boost.Task</strong></span> does only provide this feature
+ for Windows, Linux, AIX, HP-UX and Solaris.
+ </p></td></tr>
+</table></div>
+</div>
+<div class="section" title="Work-Stealing">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_task.async_executor.pool.work_stealing"></a><a class="link" href="async_executor.html#boost_task.async_executor.pool.work_stealing" title="Work-Stealing"> Work-Stealing</a>
+</h4></div></div></div>
+<p>
+ The most important aspect of <span class="emphasis"><em>work-stealing</em></span> is that
+ it enables fast enqueue and dequeue in the typical case, often requiring
+ no synchronization at all. This virtually eliminates a large part of the
+ overhead of QUWI, when working with child tasks. We still do need to allocate
+ memory for the Task itself, and for the work-stealing queue, but like the
+ improvements to the FIFO queue these data structures have been optimized
+ for good GC performance. Parent tasks are fast; child tasks are much faster.
+ </p>
+<p>
+ Traditional <span class="emphasis"><em>thread-pools</em></span> do not scale because they
+ use a single global-queue protected by a global-lock. The frequency at
+ which <span class="emphasis"><em>worker-threads</em></span> aquire the global-lock becomes
+ a limiting factor for the throughput if:
+ </p>
+<div class="itemizedlist"><ul class="itemizedlist" type="disc">
+<li class="listitem">
+ the <span class="underline">_tasks</span>_ become smaller
+ </li>
+<li class="listitem">
+ more processors are added
+ </li>
+</ul></div>
+<p>
+ A <span class="emphasis"><em>work-stealing</em></span> algorithm can be used to solve this
+ problem. It uses a special kind of queue which has two ends, and allows
+ lock-free pushes and pops from the <span class="emphasis"><em>private end</em></span> (accessed
+ by the <span class="emphasis"><em>worker-thread</em></span> owning the queue), but requires
+ synchronization from the <span class="emphasis"><em>public end</em></span> (accessed by the
+ other <span class="emphasis"><em>worker-threads</em></span>). Synchronization is necessary
+ when the queue is sufficiently small that private and public operations
+ could conflict.
+ </p>
+<p>
+ The pool contains one global-queue (<code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">bounded_channel</span></code>
+ or <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">unbounded_channel</span></code>) protected by a global-lock
+ and each <span class="emphasis"><em>worker-thread</em></span> has its own private local worker-queue.
+ If work is enqueued by a <span class="emphasis"><em>worker-thread</em></span> the <span class="underline">_action</span>_ is stored in the worker queue. If
+ the work is enqueued by a application thread it goes into the global queue.
+ When <span class="emphasis"><em>worker-threads</em></span> are looking for work, they have
+ following search order:
+ </p>
+<div class="itemizedlist"><ul class="itemizedlist" type="disc">
+<li class="listitem">
+ look into the private worker-queue - <span class="underline">_tasks</span>_
+ can be dequeued without locks
+ </li>
+<li class="listitem">
+ look in the global-queue - locks are used for synchronization
+ </li>
+<li class="listitem">
+ check other worker-queues ('stealing' <span class="underline">_tasks</span>_
+ from private worker queues of other <span class="emphasis"><em>worker-threads</em></span>)
+ - requires locks
+ </li>
+</ul></div>
+<p>
+ For a lot of recursively queued <span class="underline">_tasks</span>_
+ (so called <span class="emphasis"><em>sub-tasks</em></span>), the use of a worker-queue per
+ thread substantially reduces the synchronization necessary to complete
+ the work. There are also fewer cache effects due to sharing of the global-queue
+ information.
+ </p>
+<p>
+ Operations on the private worker queue are executed in LIFO order and operations
+ on worker queues of other <span class="emphasis"><em>worker-threads</em></span> in FIFO order
+ (steals).
+ </p>
+<div class="itemizedlist"><ul class="itemizedlist" type="disc">
+<li class="listitem">
+ There are chances that memory is still hot in the cache, if the <span class="underline">_tasks</span>_ are pushed in LIFO order into the
+ private worker queue.
+ </li>
+<li class="listitem">
+ If a <span class="emphasis"><em>worker-thread</em></span> steals work in FIFO order, increases
+ the chances that a larger 'chunk' of work will be stolen (the need for
+ other steals will be possibly reduced). Because the <span class="emphasis"><em>sub-tasks</em></span>
+ are stored in LIFO order, the oldest items are closer to the <span class="emphasis"><em>public
+ end</em></span> of the queue (forming a tree). Stealing such an older
+ <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">task</span></code> also steals a (probably) larger
+ subtree of <span class="underline">_tasks</span>_ unfolded if
+ the stolen work item get executed. Since a <span class="emphasis"><em>sub-task</em></span>
+ is just part of a larger <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">task</span></code>,
+ we don&#8217;t need to worry about execution order.
+ </li>
+</ul></div>
+</div>
+<p>
+ / Copyright Oliver Kowalke 2009. Distributed under the Boost Software License,
+ Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
+ ]
+ </p>
+<div class="section" title="Fork/Join">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_task.async_executor.pool.forkjoin"></a><a class="link" href="async_executor.html#boost_task.async_executor.pool.forkjoin" title="Fork/Join"> Fork/Join</a>
+</h4></div></div></div>
+<p>
+ Fork/Join algorithms are recursive divide-and-conquer algorithms which
+ repeatedly splitt __sub<span class="underline">taskss</span>_ until
+ they become small enough to solve using simple, short sequential methods,
+ so that they run in parallel on multiple cores.
+ </p>
+<p>
+ The fork operation creates new <span class="emphasis"><em>sub-tasks</em></span> which can
+ run in parallel. The current <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">task</span></code>
+ is not proceeded in the join operation until the forked <span class="emphasis"><em>sub-tasks</em></span>
+ have completed. In the meantime the <span class="emphasis"><em>worker-thread</em></span>
+ executes other <span class="underline">_tasks</span>_ from its local
+ worker-queue.
+ </p>
+<p>
+
+</p>
+<pre class="programlisting"><span class="keyword">long</span> <span class="identifier">serial_fib</span><span class="special">(</span> <span class="keyword">long</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">2</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">serial_fib</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="identifier">serial_fib</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="keyword">long</span> <span class="identifier">parallel_fib</span><span class="special">(</span> <span class="keyword">long</span> <span class="identifier">n</span><span class="special">,</span> <span class="keyword">long</span> <span class="identifier">cutof</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">cutof</span><span class="special">)</span> <span class="keyword">return</span> <span class="identifier">serial_fib</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 sub-task calculating fibonacci(n-1)
+</span> <span class="identifier">h1</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">async</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">as_sub_task</span><span class="special">(),</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">make_task</span><span class="special">(</span>
+ <span class="identifier">parallel_fib</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="identifier">cutof</span><span class="special">)</span> <span class="special">);</span>
+ <span class="comment">// fork a sub-task calculating fibonacci(n-2)
+</span> <span class="identifier">h2</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">async</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">as_sub_task</span><span class="special">(),</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">make_task</span><span class="special">(</span>
+ <span class="identifier">parallel_fib</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="identifier">cutof</span><span class="special">)</span> <span class="special">);</span>
+ <span class="comment">// join the results of both sub-tasks
+</span> <span class="comment">// if one of the both sub-tasks is not ready
+</span> <span class="comment">// the worker-thread does not block, it executes other
+</span> <span class="comment">// task from its local-queue
+</span> <span class="keyword">return</span> <span class="identifier">h1</span><span class="special">.</span><span class="identifier">get</span><span class="special">()</span> <span class="special">+</span> <span class="identifier">h2</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">void</span> <span class="identifier">main</span><span class="special">()</span>
+<span class="special">{</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">handle</span><span class="special">&lt;</span> <span class="keyword">long</span> <span class="special">&gt;</span> <span class="identifier">h</span><span class="special">(</span> <span class="comment">// handle for fibonacci calculation
+</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">async</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">default_pool</span><span class="special">(),</span> <span class="comment">// access the default thread-pool
+</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">make_task</span><span class="special">(</span> <span class="comment">// calculate fibonacci number 10
+</span> <span class="identifier">parallel_fib</span><span class="special">,</span> <span class="comment">// for numbers &lt; 5 do inline recursive calculation
+</span> <span class="number">10</span><span class="special">,</span>
+ <span class="number">5</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">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">h</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="special">}</span>
+</pre>
+<p>
+ </p>
+</div>
+</div>
+<div class="section" title="boost::task::as_sub_task">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_task.async_executor.as_sub_task"></a><a class="link" href="async_executor.html#boost_task.async_executor.as_sub_task" title="boost::task::as_sub_task"> <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">as_sub_task</span></code></a>
+</h3></div></div></div>
+<p>
+ <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">as_sub_task</span></code> is a convenient way to execute
+ a <span class="emphasis"><em>sub-task</em></span>. If the parent task is executed inside a
+ <span class="emphasis"><em>thread-pool</em></span> the <span class="emphasis"><em>sub-task</em></span> is put
+ into the local-queue of the <span class="emphasis"><em>worker-thread</em></span> in the other
+ case the <span class="emphasis"><em>sub-task</em></span> will be executed in a new thread.
+ </p>
+<p>
+
+</p>
+<pre class="programlisting"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">handle</span><span class="special">&lt;</span> <span class="keyword">long</span> <span class="special">&gt;</span> <span class="identifier">h</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">async</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">as_sub_task</span><span class="special">(),</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">make_task</span><span class="special">(</span>
+ <span class="identifier">fibonacci</span><span class="special">,</span>
+ <span class="number">10</span><span class="special">)</span> <span class="special">)</span> <span class="special">);</span>
+</pre>
+<p>
+ </p>
+<p>
+ is equivalent to:
+ </p>
+<p>
+
+</p>
+<pre class="programlisting"><span class="keyword">if</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">runs_in_pool</span><span class="special">()</span> <span class="special">)</span>
+<span class="special">{</span>
+ <span class="comment">// put the sub-task into worker-threads local-queue
+</span><span class="special">}</span>
+<span class="keyword">else</span>
+<span class="special">{</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">async</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">new_thread</span><span class="special">(),</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">make_task</span><span class="special">(...)</span> <span class="special">);</span>
+<span class="special">}</span>
+</pre>
+<p>
+ </p>
+</div>
+<div class="footnotes">
+<br><hr width="100" align="left">
+<div class="footnote"><p><sup>[<a name="ftn.id665925" href="#id665925" class="para">4</a>] </sup>
+ see <a href="http://www.ddj.com/go-parallel/article/showArticle.jhtml?articleID=216500409" target="_top">'Use
+ Thread Pools Correctly'</a>, Herb Sutter
+ </p></div>
+</div>
+</div>
+<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
+<td align="left"></td>
+<td align="right"><div class="copyright-footer">Copyright © 2009 Oliver Kowalke<p>
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ </p>
+</div></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="handle.html"><img src="../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="utilities.html"><img src="../../../doc/html/images/next.png" alt="Next"></a>
+</div>
+</body>
+</html>

Added: sandbox/task/libs/task/doc/html/boost_task/callable.html
==============================================================================
--- (empty file)
+++ sandbox/task/libs/task/doc/html/boost_task/callable.html 2009-06-01 08:13:01 EDT (Mon, 01 Jun 2009)
@@ -0,0 +1,321 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>Callable</title>
+<link rel="stylesheet" href="../boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.75.0">
+<link rel="home" href="../index.html" title="Chapter 1. Boost.Task">
+<link rel="up" href="../index.html" title="Chapter 1. Boost.Task">
+<link rel="prev" href="motivation.html" title="Motivation">
+<link rel="next" href="async_completion_token.html" title="Asynchronous completion token">
+</head>
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<table cellpadding="2" width="100%"><tr>
+<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td>
+<td align="center">Home</td>
+<td align="center">Libraries</td>
+<td align="center">People</td>
+<td align="center">FAQ</td>
+<td align="center">More</td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="motivation.html"><img src="../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="async_completion_token.html"><img src="../../../doc/html/images/next.png" alt="Next"></a>
+</div>
+<div class="section" title="Callable">
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="boost_task.callable"></a><a class="link" href="callable.html" title="Callable"> Callable</a>
+</h2></div></div></div>
+<div class="toc"><dl><dt><span class="section"> Task</span></dt></dl></div>
+<p>
+ The <span class="emphasis"><em>callable</em></span> encapsulates the function object and provides
+ for this purpose <code class="computeroutput"><span class="keyword">operator</span><span class="special">()()</span></code>.
+ </p>
+<div class="section" title="Task">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_task.callable.task"></a><a class="link" href="callable.html#boost_task.callable.task" title="Task"> Task</a>
+</h3></div></div></div>
+<p>
+ A task is a chunk of code that can be executed independently.
+ </p>
+<p>
+ <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">task</span></code> represents a <span class="emphasis"><em>callable</em></span>
+ (provides <code class="computeroutput"><span class="keyword">operator</span><span class="special">()()</span></code>)
+ object containing the unit of code to be execute by a link<span class="underline">ae[</span><span class="underline">ae</span>_]. Function <code class="computeroutput"><span class="identifier">get_future</span><span class="special">()</span></code> returns a link<span class="underline">act[</span><span class="underline">act</span>_] allowing to wait for the completion of
+ the computation of the task, for getting the result of a computation or for
+ transfering exceptions. Each <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">task</span></code>
+ has a unique identifier
+ </p>
+<a name="boost_task.callable.task.creation"></a><h5>
+<a name="id635193"></a>
+ <a class="link" href="callable.html#boost_task.callable.task.creation">Creation</a>
+ </h5>
+<p>
+ <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">make_task</span><span class="special">()</span></code>
+ can be used to create <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">task</span></code>
+ by passing free-functions or member-functions of objects and its arguments:
+ <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">make_task</span><span class="special">()</span></code>
+ accepts up to ten arguments per default (can be overriden by defining BOOST_TASK_MAKE_TASK_MAX_ARITY
+ with the new value).
+ </p>
+<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem">
+ create task from free-function with arguments:
+ </li></ul></div>
+<p>
+
+</p>
+<pre class="programlisting"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</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">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">make_task</span><span class="special">(</span>
+ <span class="identifier">parallel_fib</span><span class="special">,</span>
+ <span class="number">10</span><span class="special">)</span> <span class="special">);</span>
+</pre>
+<p>
+ </p>
+<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem">
+ create task from member-function with arguments:
+ </li></ul></div>
+<p>
+
+</p>
+<pre class="programlisting"><span class="keyword">struct</span> <span class="identifier">X</span>
+<span class="special">{</span>
+ <span class="keyword">void</span> <span class="identifier">f</span><span class="special">(</span> <span class="keyword">int</span> <span class="identifier">i</span><span class="special">);</span>
+<span class="special">};</span>
+
+<span class="identifier">X</span> <span class="identifier">x</span><span class="special">;</span>
+<span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</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">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">make_task</span><span class="special">(</span>
+ <span class="special">&amp;</span> <span class="identifier">X</span><span class="special">::</span><span class="identifier">f</span><span class="special">,</span>
+ <span class="identifier">x</span><span class="special">,</span>
+ <span class="number">10</span><span class="special">)</span> <span class="special">);</span>
+</pre>
+<p>
+ </p>
+<p>
+ It is possible to create <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">task</span></code>
+ from a <span class="emphasis"><em>callable</em></span> too:
+ </p>
+<p>
+
+</p>
+<pre class="programlisting"><span class="keyword">struct</span> <span class="identifier">Y</span>
+<span class="special">{</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="keyword">operator</span><span class="special">()();</span>
+<span class="special">};</span>
+
+<span class="identifier">Y</span> <span class="identifier">y</span><span class="special">;</span>
+<span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">task</span><span class="special">&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="special">&gt;</span> <span class="identifier">t</span><span class="special">(</span> <span class="identifier">y</span><span class="special">);</span>
+</pre>
+<p>
+ </p>
+<a name="boost_task.callable.task.cooperative_task_amd_interruption"></a><h5>
+<a name="id635764"></a>
+ <a class="link" href="callable.html#boost_task.callable.task.cooperative_task_amd_interruption">Cooperative
+ task amd interruption</a>
+ </h5>
+<p>
+ Sometimes it is desired to stop a running task if it is no longer needed.
+ In this case the thread is not killed - it stops only at well-defined points
+ (<span class="underline">_interruption</span><span class="underline">points</span>_)
+ its execution. In the context of task-interruption a task is known as cooperative
+ if it checks for an interruption request between two <span class="underline">_interruption</span><span class="underline">points</span>_ via <span class="underline">_fn</span>_interruption<span class="underline">requested</span>_
+ <sup>[<a name="id635810" href="#ftn.id635810" class="footnote">2</a>]</sup>
+ .
+ </p>
+<p>
+ <span class="underline">_interruption</span><span class="underline">points</span>_
+ are:
+ </p>
+<div class="itemizedlist"><ul class="itemizedlist" type="disc">
+<li class="listitem"><code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">thread</span><span class="special">::</span><span class="identifier">join</span><span class="special">()</span></code></li>
+<li class="listitem"><code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">thread</span><span class="special">::</span><span class="identifier">timed_join</span><span class="special">()</span></code></li>
+<li class="listitem"><code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">condition_variable</span><span class="special">::</span><span class="identifier">wait</span><span class="special">()</span></code></li>
+<li class="listitem"><code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">condition_variable</span><span class="special">::</span><span class="identifier">timed_wait</span><span class="special">()</span></code></li>
+<li class="listitem"><code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">condition_variable_any</span><span class="special">::</span><span class="identifier">wait</span><span class="special">()</span></code></li>
+<li class="listitem"><code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">condition_variable_any</span><span class="special">::</span><span class="identifier">timed_wait</span><span class="special">()</span></code></li>
+<li class="listitem"><code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">thread</span><span class="special">::</span><span class="identifier">sleep</span><span class="special">()</span></code></li>
+<li class="listitem"><code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">this_thread</span><span class="special">::</span><span class="identifier">sleep</span><span class="special">()</span></code></li>
+<li class="listitem"><code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">this_thread</span><span class="special">::</span><span class="identifier">interruption_point</span><span class="special">()</span></code></li>
+</ul></div>
+<p>
+ A <span class="underline">_interruption</span><span class="underline">point</span>_
+ throws <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">task_interrupted</span></code> if an interruption was
+ requested.
+ </p>
+<p>
+
+</p>
+<pre class="programlisting"><span class="keyword">long</span> <span class="identifier">cooperative</span><span class="special">(</span> <span class="keyword">long</span> <span class="identifier">n</span><span class="special">)</span>
+<span class="special">{</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">this_thread</span><span class="special">::</span><span class="identifier">interruption_point</span><span class="special">();</span> <span class="comment">// interruption point
+</span>
+ <span class="keyword">if</span> <span class="special">(</span> <span class="identifier">n</span> <span class="special">==</span> <span class="number">0</span><span class="special">)</span> <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span>
+ <span class="keyword">if</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="keyword">return</span> <span class="number">1</span><span class="special">;</span>
+ <span class="keyword">long</span> <span class="identifier">k1</span><span class="special">(</span> <span class="number">1</span><span class="special">),</span> <span class="identifier">k2</span><span class="special">(</span> <span class="number">0</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">2</span><span class="special">);</span> <span class="identifier">i</span> <span class="special">&lt;=</span> <span class="identifier">n</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span>
+ <span class="special">{</span>
+ <span class="keyword">if</span> <span class="special">(</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">this_thread</span><span class="special">::</span><span class="identifier">interruption_requested</span><span class="special">()</span> <span class="special">)</span> <span class="comment">// check if interruption was requested
+</span> <span class="keyword">return</span><span class="special">;</span>
+
+ <span class="keyword">long</span> <span class="identifier">tmp</span><span class="special">(</span> <span class="identifier">k1</span><span class="special">);</span>
+ <span class="identifier">k1</span> <span class="special">=</span> <span class="identifier">k1</span> <span class="special">+</span> <span class="identifier">k2</span><span class="special">;</span>
+ <span class="identifier">k2</span> <span class="special">=</span> <span class="identifier">tmp</span><span class="special">;</span>
+ <span class="special">}</span>
+
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">this_thread</span><span class="special">::</span><span class="identifier">interruption_point</span><span class="special">();</span> <span class="comment">// interruption point
+</span>
+ <span class="keyword">return</span> <span class="identifier">k1</span><span class="special">;</span>
+<span class="special">}</span>
+
+<span class="keyword">void</span> <span class="identifier">main</span><span class="special">()</span>
+<span class="special">{</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">handle</span><span class="special">&lt;</span> <span class="keyword">long</span> <span class="special">&gt;</span> <span class="identifier">h</span><span class="special">(</span> <span class="comment">// get handle associated with the task
+</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">async</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">new_thread</span><span class="special">(),</span> <span class="comment">// asynchronous executor
+</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">make_task</span><span class="special">(</span> <span class="comment">// task, to be executed asynchronously
+</span> <span class="identifier">cooperative</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">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">h</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">// throws boost::task::task_interrupted
+</span><span class="special">}</span>
+</pre>
+<p>
+ </p>
+<a name="boost_task.callable.task.exceptions"></a><h5>
+<a name="id636888"></a>
+ <a class="link" href="callable.html#boost_task.callable.task.exceptions">Exceptions</a>
+ </h5>
+<p>
+ Exceptions thrown by <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">task</span></code>
+ are transported by the <span class="emphasis"><em>asynchronous-completion-token</em></span>.
+ </p>
+<p>
+
+</p>
+<pre class="programlisting"><span class="keyword">void</span> <span class="identifier">throwing</span><span class="special">()</span>
+<span class="special">{</span>
+ <span class="special">...</span>
+ <span class="keyword">throw</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">domain_error</span><span class="special">(</span><span class="string">"domain error"</span><span class="special">);</span>
+ <span class="special">...</span>
+<span class="special">}</span>
+
+<span class="keyword">void</span> <span class="identifier">main</span><span class="special">()</span>
+<span class="special">{</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">handle</span><span class="special">&lt;</span> <span class="keyword">void</span> <span class="special">&gt;</span> <span class="identifier">h</span><span class="special">(</span> <span class="comment">// get handle associated with the task
+</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">async</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">new_thread</span><span class="special">(),</span> <span class="comment">// asynchronous executor
+</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">make_task</span><span class="special">(</span> <span class="comment">// task, to be executed asynchronously
+</span> <span class="identifier">throwing</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">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">h</span><span class="special">.</span><span class="identifier">wait</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">// throws std::domain_error
+</span><span class="special">}</span>
+</pre>
+<p>
+ </p>
+<p>
+ Exceptions rethrown by type are:
+ </p>
+<div class="itemizedlist"><ul class="itemizedlist" type="disc">
+<li class="listitem"><code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">bad_alloc</span></code></li>
+<li class="listitem"><code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">bad_cast</span></code></li>
+<li class="listitem"><code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">bad_exception</span></code></li>
+<li class="listitem"><code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">bad_typeid</span></code></li>
+<li class="listitem"><code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">domain_error</span></code></li>
+<li class="listitem"><code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">invalid_argument</span></code></li>
+<li class="listitem"><code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">ios_base</span><span class="special">::</span><span class="identifier">failure</span></code></li>
+<li class="listitem"><code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">length_error</span></code></li>
+<li class="listitem"><code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">logic_error</span></code></li>
+<li class="listitem"><code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">out_of_range</span></code></li>
+<li class="listitem"><code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">overflow_error</span></code></li>
+<li class="listitem"><code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">range_error</span></code></li>
+<li class="listitem"><code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">runtime_error</span></code></li>
+<li class="listitem"><code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">underflow_error</span></code></li>
+<li class="listitem"><code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">future_already_set</span></code></li>
+<li class="listitem"><code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">future_cancel</span></code></li>
+<li class="listitem"><code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">exception</span></code></li>
+<li class="listitem"><code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">invalid_thread_argument</span></code></li>
+<li class="listitem"><code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">lock_error</span></code></li>
+<li class="listitem"><code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">task_interrupted</span></code></li>
+<li class="listitem"><code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">broken_task</span></code></li>
+</ul></div>
+<a name="boost_task.callable.task.parent_task"></a><h5>
+<a name="id637692"></a>
+ <a class="link" href="callable.html#boost_task.callable.task.parent_task">Parent-task</a>
+ </h5>
+<p>
+ Top-level tasks have no parent. A parent task can create child tasks when
+ it creates another task by using <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">as_sub_task</span></code>
+ as <span class="emphasis"><em>asynchronous-executor</em></span>. These children are implicitly
+ treated as <span class="emphasis"><em>sub-tasks</em></span> of the larger task. It is assumed
+ that that <span class="emphasis"><em>sub-tasks</em></span> can be executed in any order because
+ only overall operation speed matters (enabling strategies for fast execution
+ of unordered <span class="emphasis"><em>work-items</em></span> as <a class="link" href="../"><span class="emphasis"><em>work-stealing</em></span></a>).
+ </p>
+<p>
+
+</p>
+<pre class="programlisting"><span class="keyword">long</span> <span class="identifier">serial_fib</span><span class="special">(</span> <span class="keyword">long</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">2</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">serial_fib</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="identifier">serial_fib</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="keyword">long</span> <span class="identifier">parallel_fib</span><span class="special">(</span> <span class="keyword">long</span> <span class="identifier">n</span><span class="special">,</span> <span class="keyword">long</span> <span class="identifier">cutof</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">cutof</span><span class="special">)</span> <span class="keyword">return</span> <span class="identifier">serial_fib</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">// submit a sub-task to pool calculating fibonacci(n-1)
+</span> <span class="identifier">h1</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">async</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">as_sub_task</span><span class="special">(),</span> <span class="comment">// execute a sub-task
+</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">make_task</span><span class="special">(</span>
+ <span class="identifier">parallel_fib</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="identifier">cutof</span><span class="special">)</span> <span class="special">);</span>
+ <span class="comment">// submit a sub-task to pool calculating fibonacci(n-2)
+</span> <span class="identifier">h2</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">async</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">as_sub_task</span><span class="special">(),</span> <span class="comment">// execute a sub-task
+</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">make_task</span><span class="special">(</span>
+ <span class="identifier">parallel_fib</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="identifier">cutof</span><span class="special">)</span> <span class="special">);</span>
+ <span class="comment">// calculate fibonacci(n) from the results of both sub-tasks
+</span> <span class="keyword">return</span> <span class="identifier">h1</span><span class="special">.</span><span class="identifier">get</span><span class="special">()</span> <span class="special">+</span> <span class="identifier">h2</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">void</span> <span class="identifier">main</span><span class="special">()</span>
+<span class="special">{</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">handle</span><span class="special">&lt;</span> <span class="keyword">long</span> <span class="special">&gt;</span> <span class="identifier">h</span><span class="special">(</span> <span class="comment">// handle for fibonacci calculation
+</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">async</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">default_pool</span><span class="special">(),</span> <span class="comment">// access the default thread-pool
+</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">make_task</span><span class="special">(</span> <span class="comment">// calculate fibonacci number 10
+</span> <span class="identifier">parallel_fib</span><span class="special">,</span> <span class="comment">// for numbers &lt; 5 do inline recursive calculation
+</span> <span class="number">10</span><span class="special">,</span>
+ <span class="number">5</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">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">h</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="special">}</span>
+</pre>
+<p>
+ </p>
+</div>
+<div class="footnotes">
+<br><hr width="100" align="left">
+<div class="footnote"><p><sup>[<a name="ftn.id635810" href="#id635810" class="para">2</a>] </sup>
+ see 'Interrupt Politely',
+ Herb Sutter
+ </p></div>
+</div>
+</div>
+<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
+<td align="left"></td>
+<td align="right"><div class="copyright-footer">Copyright © 2009 Oliver Kowalke<p>
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ </p>
+</div></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="motivation.html"><img src="../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="async_completion_token.html"><img src="../../../doc/html/images/next.png" alt="Next"></a>
+</div>
+</body>
+</html>

Added: sandbox/task/libs/task/doc/html/boost_task/description.html
==============================================================================
--- (empty file)
+++ sandbox/task/libs/task/doc/html/boost_task/description.html 2009-06-01 08:13:01 EDT (Mon, 01 Jun 2009)
@@ -0,0 +1,41 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>Description</title>
+<link rel="stylesheet" href="../boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.75.0">
+<link rel="home" href="../index.html" title="Chapter 1. Boost.Task">
+<link rel="up" href="../index.html" title="Chapter 1. Boost.Task">
+<link rel="prev" href="motivation.html" title="Motivation">
+<link rel="next" href="task.html" title="Task">
+</head>
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<table cellpadding="2" width="100%"><tr>
+<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td>
+<td align="center">Home</td>
+<td align="center">Libraries</td>
+<td align="center">People</td>
+<td align="center">FAQ</td>
+<td align="center">More</td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="motivation.html"><img src="../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="task.html"><img src="../../../doc/html/images/next.png" alt="Next"></a>
+</div>
+<div class="section" title="Description"><div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="boost_task.description"></a><a class="link" href="description.html" title="Description"> Description</a>
+</h2></div></div></div></div>
+<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
+<td align="left"></td>
+<td align="right"><div class="copyright-footer">Copyright © 2009 Oliver Kowalke<p>
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ </p>
+</div></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="motivation.html"><img src="../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="task.html"><img src="../../../doc/html/images/next.png" alt="Next"></a>
+</div>
+</body>
+</html>

Added: sandbox/task/libs/task/doc/html/boost_task/handle.html
==============================================================================
--- (empty file)
+++ sandbox/task/libs/task/doc/html/boost_task/handle.html 2009-06-01 08:13:01 EDT (Mon, 01 Jun 2009)
@@ -0,0 +1,222 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>Handle</title>
+<link rel="stylesheet" href="../boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.75.0">
+<link rel="home" href="../index.html" title="Chapter 1. Boost.Task">
+<link rel="up" href="../index.html" title="Chapter 1. Boost.Task">
+<link rel="prev" href="task.html" title="Task">
+<link rel="next" href="own_thread.html" title="Execute in own thread">
+</head>
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<table cellpadding="2" width="100%"><tr>
+<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td>
+<td align="center">Home</td>
+<td align="center">Libraries</td>
+<td align="center">People</td>
+<td align="center">FAQ</td>
+<td align="center">More</td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="task.html"><img src="../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="own_thread.html"><img src="../../../doc/html/images/next.png" alt="Next"></a>
+</div>
+<div class="section" title="Handle">
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="boost_task.handle"></a><a class="link" href="handle.html" title="Handle"> Handle</a>
+</h2></div></div></div>
+<p>
+ The <span class="emphasis"><em>asynchronous-completion-token</em></span> dispatches tasks in
+ response to the completion of asynchronous operations. <span class="emphasis"><em>asynchronous-completion-token</em></span>
+ uniquely identifies the task and state necessary to process the result of the
+ operation
+ <sup>[<a name="id569908" href="#ftn.id569908" class="footnote">3</a>]</sup>
+ .
+ </p>
+<p>
+ <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">handle</span></code>
+ represents an <span class="emphasis"><em>asynchronous-completion-token</em></span>. It will be
+ returned by <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">async</span><span class="special">()</span></code> and is associated with the submitted <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">task</span></code>.
+ </p>
+<a name="boost_task.handle.asynchronous_completion_token_interface"></a><h4>
+<a name="id570012"></a>
+ <a class="link" href="handle.html#boost_task.handle.asynchronous_completion_token_interface">Asynchronous
+ completion token interface</a>
+ </h4>
+<p>
+ <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">handle</span></code>
+ implements an interface in order to check the state of computation and result
+ transfer
+ </p>
+<div class="itemizedlist"><ul class="itemizedlist" type="disc">
+<li class="listitem">
+<code class="computeroutput"><span class="identifier">get_id</span><span class="special">()</span></code>:
+ return id of the associated task-id
+ </li>
+<li class="listitem">
+<code class="computeroutput"><span class="identifier">is_ready</span><span class="special">()</span></code>:
+ test if result is set
+ </li>
+<li class="listitem">
+<code class="computeroutput"><span class="identifier">has_value</span><span class="special">()</span></code>:
+ test if value-result is set
+ </li>
+<li class="listitem">
+<code class="computeroutput"><span class="identifier">has_exception</span><span class="special">()</span></code>:
+ test if exception-result is set
+ </li>
+<li class="listitem">
+<code class="computeroutput"><span class="identifier">get</span><span class="special">()</span></code>:
+ return value-result
+ </li>
+<li class="listitem">
+<code class="computeroutput"><span class="identifier">wait</span><span class="special">()</span></code>:
+ wait until result is set
+ </li>
+<li class="listitem">
+<code class="computeroutput"><span class="identifier">wait_for</span><span class="special">()</span></code>:
+ wait until result is set or time-duration has elapsed
+ </li>
+<li class="listitem">
+<code class="computeroutput"><span class="identifier">wait_until</span><span class="special">()</span></code>:
+ wait until result ist set or time-point has elapsed
+ </li>
+</ul></div>
+<p>
+
+</p>
+<pre class="programlisting"><span class="keyword">long</span> <span class="identifier">fibonacci</span><span class="special">(</span> <span class="keyword">long</span> <span class="identifier">n</span><span class="special">)</span>
+<span class="special">{</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">this_thread</span><span class="special">::</span><span class="identifier">interruption_point</span><span class="special">();</span> <span class="comment">// interruption point
+</span>
+ <span class="keyword">if</span> <span class="special">(</span> <span class="identifier">n</span> <span class="special">==</span> <span class="number">0</span><span class="special">)</span> <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span>
+ <span class="keyword">if</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="keyword">return</span> <span class="number">1</span><span class="special">;</span>
+ <span class="keyword">long</span> <span class="identifier">k1</span><span class="special">(</span> <span class="number">1</span><span class="special">),</span> <span class="identifier">k2</span><span class="special">(</span> <span class="number">0</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">2</span><span class="special">);</span> <span class="identifier">i</span> <span class="special">&lt;=</span> <span class="identifier">n</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span>
+ <span class="special">{</span>
+ <span class="keyword">if</span> <span class="special">(</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">this_thread</span><span class="special">::</span><span class="identifier">interruption_requested</span><span class="special">()</span> <span class="special">)</span> <span class="comment">// check if interruption was requested
+</span> <span class="keyword">return</span><span class="special">;</span>
+
+ <span class="keyword">long</span> <span class="identifier">tmp</span><span class="special">(</span> <span class="identifier">k1</span><span class="special">);</span>
+ <span class="identifier">k1</span> <span class="special">=</span> <span class="identifier">k1</span> <span class="special">+</span> <span class="identifier">k2</span><span class="special">;</span>
+ <span class="identifier">k2</span> <span class="special">=</span> <span class="identifier">tmp</span><span class="special">;</span>
+ <span class="special">}</span>
+
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">this_thread</span><span class="special">::</span><span class="identifier">interruption_point</span><span class="special">();</span> <span class="comment">// interruption point
+</span>
+ <span class="keyword">return</span> <span class="identifier">k1</span><span class="special">;</span>
+<span class="special">}</span>
+
+<span class="keyword">void</span> <span class="identifier">main</span><span class="special">()</span>
+<span class="special">{</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">handle</span><span class="special">&lt;</span> <span class="keyword">long</span> <span class="special">&gt;</span> <span class="identifier">h</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">async</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">new_thread</span><span class="special">(),</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">make_task</span><span class="special">(</span>
+ <span class="identifier">fibonacci</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">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"id == "</span> <span class="special">&lt;&lt;</span> <span class="identifier">h</span><span class="special">.</span><span class="identifier">get_id</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="string">"\n"</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">"is ready == "</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">boolalpha</span> <span class="special">&lt;&lt;</span> <span class="identifier">h</span><span class="special">.</span><span class="identifier">is_ready</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="string">"\n"</span><span class="special">;</span>
+ <span class="identifier">h</span><span class="special">.</span><span class="identifier">wait</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">"has value == "</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">boolalpha</span> <span class="special">&lt;&lt;</span> <span class="identifier">h</span><span class="special">.</span><span class="identifier">has_value</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="string">"\n"</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">"has exception == "</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">boolalpha</span> <span class="special">&lt;&lt;</span> <span class="identifier">h</span><span class="special">.</span><span class="identifier">has_exception</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="string">"\n"</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(10) == "</span> <span class="special">&lt;&lt;</span> <span class="identifier">h</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="special">}</span>
+</pre>
+<p>
+ </p>
+<a name="boost_task.handle.task_interruption"></a><h4>
+<a name="id571214"></a>
+ <a class="link" href="handle.html#boost_task.handle.task_interruption">Task interruption</a>
+ </h4>
+<div class="itemizedlist"><ul class="itemizedlist" type="disc">
+<li class="listitem">
+<code class="computeroutput"><span class="identifier">interrupt</span><span class="special">()</span></code>:
+ interrupt <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">task</span></code> and return immediately
+ </li>
+<li class="listitem">
+<code class="computeroutput"><span class="identifier">interrupt_and_wait</span><span class="special">()</span></code>:
+ interrupt and wait until <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">task</span></code>
+ was removed from <span class="emphasis"><em>worker-thread</em></span>
+</li>
+<li class="listitem">
+<code class="computeroutput"><span class="identifier">interrupt_and_wait_for</span><span class="special">()</span></code>:
+ interrupt and wait until <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">task</span></code>
+ was removed from <span class="emphasis"><em>worker-thread</em></span> or time duration has
+ elapsed
+ </li>
+<li class="listitem">
+<code class="computeroutput"><span class="identifier">interrupt_and_wait_until</span><span class="special">()</span></code>: interrupt and wait until <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">task</span></code> was removed from <span class="emphasis"><em>worker-thread</em></span>
+ or time point has elapsed
+ </li>
+<li class="listitem">
+<code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">this_thread</span><span class="special">::</span><span class="identifier">interruption_requested</span><span class="special">()</span></code>:
+ return bool if interruption was requested
+ </li>
+</ul></div>
+<p>
+
+</p>
+<pre class="programlisting"><span class="keyword">long</span> <span class="identifier">cooperative</span><span class="special">(</span> <span class="keyword">long</span> <span class="identifier">n</span><span class="special">)</span>
+<span class="special">{</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">this_thread</span><span class="special">::</span><span class="identifier">interruption_point</span><span class="special">();</span> <span class="comment">// interruption point
+</span>
+ <span class="keyword">if</span> <span class="special">(</span> <span class="identifier">n</span> <span class="special">==</span> <span class="number">0</span><span class="special">)</span> <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span>
+ <span class="keyword">if</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="keyword">return</span> <span class="number">1</span><span class="special">;</span>
+ <span class="keyword">long</span> <span class="identifier">k1</span><span class="special">(</span> <span class="number">1</span><span class="special">),</span> <span class="identifier">k2</span><span class="special">(</span> <span class="number">0</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">2</span><span class="special">);</span> <span class="identifier">i</span> <span class="special">&lt;=</span> <span class="identifier">n</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span>
+ <span class="special">{</span>
+ <span class="keyword">if</span> <span class="special">(</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">this_thread</span><span class="special">::</span><span class="identifier">interruption_requested</span><span class="special">()</span> <span class="special">)</span> <span class="comment">// check if interruption was requested
+</span> <span class="keyword">return</span><span class="special">;</span>
+
+ <span class="keyword">long</span> <span class="identifier">tmp</span><span class="special">(</span> <span class="identifier">k1</span><span class="special">);</span>
+ <span class="identifier">k1</span> <span class="special">=</span> <span class="identifier">k1</span> <span class="special">+</span> <span class="identifier">k2</span><span class="special">;</span>
+ <span class="identifier">k2</span> <span class="special">=</span> <span class="identifier">tmp</span><span class="special">;</span>
+ <span class="special">}</span>
+
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">this_thread</span><span class="special">::</span><span class="identifier">interruption_point</span><span class="special">();</span> <span class="comment">// interruption point
+</span>
+ <span class="keyword">return</span> <span class="identifier">k1</span><span class="special">;</span>
+<span class="special">}</span>
+
+<span class="keyword">void</span> <span class="identifier">main</span><span class="special">()</span>
+<span class="special">{</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">handle</span><span class="special">&lt;</span> <span class="keyword">long</span> <span class="special">&gt;</span> <span class="identifier">h</span><span class="special">(</span> <span class="comment">// get handle associated with the task
+</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">async</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">new_thread</span><span class="special">(),</span> <span class="comment">// asynchronous executor
+</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">make_task</span><span class="special">(</span> <span class="comment">// task, to be executed asynchronously
+</span> <span class="identifier">cooperative</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">h</span><span class="special">.</span><span class="identifier">interrupt_and_wait</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">"id == "</span> <span class="special">&lt;&lt;</span> <span class="identifier">h</span><span class="special">.</span><span class="identifier">get_id</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="string">"\n"</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">"is ready == "</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">boolalpha</span> <span class="special">&lt;&lt;</span> <span class="identifier">h</span><span class="special">.</span><span class="identifier">is_ready</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="string">"\n"</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">"has value == "</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">boolalpha</span> <span class="special">&lt;&lt;</span> <span class="identifier">h</span><span class="special">.</span><span class="identifier">has_value</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="string">"\n"</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">"has exception == "</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">boolalpha</span> <span class="special">&lt;&lt;</span> <span class="identifier">h</span><span class="special">.</span><span class="identifier">has_exception</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="string">"\n"</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">h</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">// throws boost::task::task_interrupted
+</span><span class="special">}</span>
+</pre>
+<p>
+ </p>
+<div class="footnotes">
+<br><hr width="100" align="left">
+<div class="footnote"><p><sup>[<a name="ftn.id569908" href="#id569908" class="para">3</a>] </sup>
+ see <a href="http://www.cs.wustl.edu/~schmidt/PDF/ACT.pdf" target="_top">'Asynchronous
+ Completion Token'</a>, Douglas Schmidt
+ </p></div>
+</div>
+</div>
+<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
+<td align="left"></td>
+<td align="right"><div class="copyright-footer">Copyright © 2009 Oliver Kowalke<p>
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ </p>
+</div></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="task.html"><img src="../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="own_thread.html"><img src="../../../doc/html/images/next.png" alt="Next"></a>
+</div>
+</body>
+</html>

Added: sandbox/task/libs/task/doc/html/boost_task/meta_functions.html
==============================================================================
--- (empty file)
+++ sandbox/task/libs/task/doc/html/boost_task/meta_functions.html 2009-06-01 08:13:01 EDT (Mon, 01 Jun 2009)
@@ -0,0 +1,63 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>Meta functions</title>
+<link rel="stylesheet" href="../boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.75.0">
+<link rel="home" href="../index.html" title="Chapter 1. Boost.Task">
+<link rel="up" href="../index.html" title="Chapter 1. Boost.Task">
+<link rel="prev" href="utilities.html" title="Utilities">
+<link rel="next" href="reference.html" title="Reference">
+</head>
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<table cellpadding="2" width="100%"><tr>
+<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td>
+<td align="center">Home</td>
+<td align="center">Libraries</td>
+<td align="center">People</td>
+<td align="center">FAQ</td>
+<td align="center">More</td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="utilities.html"><img src="../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="reference.html"><img src="../../../doc/html/images/next.png" alt="Next"></a>
+</div>
+<div class="section" title="Meta functions">
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="boost_task.meta_functions"></a><a class="link" href="meta_functions.html" title="Meta functions"> Meta functions</a>
+</h2></div></div></div>
+<p>
+ If the <span class="emphasis"><em>thread-pool</em></span> supports attributes (like priorities)
+ <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">has_attribute</span></code>
+ evaluates to <code class="computeroutput"><span class="keyword">true</span></code> at compile-time
+ (derived from boost::mpl::bool_). The type of the attribute is determined by
+ <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">attribute_type</span></code>.
+ </p>
+<p>
+
+</p>
+<pre class="programlisting"><span class="identifier">typdef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">static_pool</span><span class="special">&lt;</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</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">task</span><span class="special">::</span><span class="identifier">priority</span><span class="special">&lt;</span> <span class="keyword">int</span> <span class="special">&gt;</span> <span class="special">&gt;</span> <span class="comment">// pool with priority scheduling; integer as priority type
+</span><span class="special">&gt;</span> <span class="identifier">pool_type</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">std</span><span class="special">::</span><span class="identifier">boolalpha</span> <span class="special">&lt;&lt;</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">has_attribute</span><span class="special">&lt;</span> <span class="identifier">pool_type</span> <span class="special">&gt;::</span><span class="identifier">value</span> <span class="special">&lt;&lt;</span> <span class="string">"\n"</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="keyword">typeid</span><span class="special">(</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">attribute_type</span><span class="special">&lt;</span> <span class="identifier">pool_type</span> <span class="special">&gt;::</span><span class="identifier">type</span><span class="special">).</span><span class="identifier">name</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>
+</pre>
+<p>
+ </p>
+</div>
+<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
+<td align="left"></td>
+<td align="right"><div class="copyright-footer">Copyright © 2009 Oliver Kowalke<p>
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ </p>
+</div></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="utilities.html"><img src="../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="reference.html"><img src="../../../doc/html/images/next.png" alt="Next"></a>
+</div>
+</body>
+</html>

Added: sandbox/task/libs/task/doc/html/boost_task/motivation.html
==============================================================================
--- (empty file)
+++ sandbox/task/libs/task/doc/html/boost_task/motivation.html 2009-06-01 08:13:01 EDT (Mon, 01 Jun 2009)
@@ -0,0 +1,223 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>Motivation</title>
+<link rel="stylesheet" href="../boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.75.0">
+<link rel="home" href="../index.html" title="Chapter 1. Boost.Task">
+<link rel="up" href="../index.html" title="Chapter 1. Boost.Task">
+<link rel="prev" href="../index.html" title="Chapter 1. Boost.Task">
+<link rel="next" href="task.html" title="Task">
+</head>
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<table cellpadding="2" width="100%"><tr>
+<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td>
+<td align="center">Home</td>
+<td align="center">Libraries</td>
+<td align="center">People</td>
+<td align="center">FAQ</td>
+<td align="center">More</td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="../index.html"><img src="../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="task.html"><img src="../../../doc/html/images/next.png" alt="Next"></a>
+</div>
+<div class="section" title="Motivation">
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="boost_task.motivation"></a><a class="link" href="motivation.html" title="Motivation"> Motivation</a>
+</h2></div></div></div>
+<p>
+ To speed-up computer-bound work and/or increase the computation-throughput
+ is a common motivation for parallelizing a program. Especially for interactive
+ applications that have to process user input while performing some background
+ tasks responsivness iss very important. Parallelizing a program requires partitioning
+ the program into smaller chunks that can run in parallel. The code can scale
+ as the hardware gets better without changing the code.
+ </p>
+<p>
+ The evolution from one-core to many-core architectures and the usage of threads
+ (of course processes fit too) support this paradigm.
+ </p>
+<div class="note" title="Note"><table border="0" summary="Note">
+<tr>
+<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../doc/html/images/note.png"></td>
+<th align="left">Note</th>
+</tr>
+<tr><td align="left" valign="top"><p>
+ <span class="quote">&#8220;<span class="quote">You can have multithreading on a single core machine, but you can
+ only have parallelism on a multi core machine ... .</span>&#8221;</span> -- Daniel Moth
+ <sup>[<a name="id563974" href="#ftn.id563974" class="footnote">1</a>]</sup>
+ </p></td></tr>
+</table></div>
+<p>
+ <span class="bold"><strong>Boost.Task</strong></span> provides a framework to utilize
+ the available hardware and provide a way for efficient asynchronous processing
+ of time consuming operations. The framework provides some <span class="emphasis"><em>asynchronous-executors</em></span>,
+ like <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">new_thread</span></code>,
+ in order to execute the task asynchronously in another execution context (<span class="bold"><strong>Boost.Task</strong></span> uses preemptible threads for this purpose).
+ </p>
+<p>
+
+</p>
+<pre class="programlisting"><span class="keyword">void</span> <span class="identifier">print</span><span class="special">(</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">msg</span><span class="special">)</span>
+<span class="special">{</span> <span class="identifier">printf</span><span class="special">(</span><span class="string">"%s\n"</span><span class="special">,</span> <span class="identifier">msg</span><span class="special">.</span><span class="identifier">c_str</span><span class="special">()</span> <span class="special">);</span> <span class="special">}</span>
+
+<span class="keyword">void</span> <span class="identifier">main</span><span class="special">()</span>
+<span class="special">{</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">async</span><span class="special">(</span> <span class="comment">// dispatchs task
+</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">new_thread</span><span class="special">(),</span> <span class="comment">// asynchronous executor
+</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">make_task</span><span class="special">(</span> <span class="comment">// task, to be executed asynchronously
+</span> <span class="identifier">print</span><span class="special">,</span>
+ <span class="string">"Hello World!"</span><span class="special">)</span> <span class="special">)</span> <span class="special">);</span>
+<span class="special">}</span>
+</pre>
+<p>
+ </p>
+<p>
+ In order to manage the task <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">async</span><span class="special">()</span></code> returns
+ a handle <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">handle</span></code>
+ (associated with the submitted task). It functions as a <span class="emphasis"><em>asynchronous-completion-token</em></span>
+ - that means it transfers the result of the execution back to the caller thread.
+ </p>
+<p>
+
+</p>
+<pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="identifier">echo</span><span class="special">(</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">msg</span><span class="special">)</span>
+<span class="special">{</span> <span class="keyword">return</span> <span class="identifier">msg</span><span class="special">;</span> <span class="special">}</span>
+
+<span class="keyword">void</span> <span class="identifier">main</span><span class="special">()</span>
+<span class="special">{</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">handle</span><span class="special">&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="special">&gt;</span> <span class="identifier">h</span><span class="special">(</span> <span class="comment">// get handle associated with the task
+</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">async</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">new_thread</span><span class="special">(),</span> <span class="comment">// asynchronous executor
+</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">make_task</span><span class="special">(</span> <span class="comment">// task, to be executed asynchronously
+</span> <span class="identifier">echo</span><span class="special">,</span>
+ <span class="string">"Hello World!"</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">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">h</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">// wait until task is finished and return the result
+</span><span class="special">}</span>
+</pre>
+<p>
+ </p>
+<p>
+ The task can also be interrupted via <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">handle</span></code> if it is a so-called <a class="link" href="task.html" title="Task"><span class="emphasis"><em>cooperative
+ task</em></span></a>.
+ </p>
+<p>
+
+</p>
+<pre class="programlisting"><span class="keyword">void</span> <span class="identifier">long_running</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="identifier">time_duration</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">rel_time</span><span class="special">)</span>
+<span class="special">{</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">this_thread</span><span class="special">::</span><span class="identifier">sleep</span><span class="special">(</span> <span class="identifier">rel_time</span><span class="special">);</span>
+
+<span class="keyword">void</span> <span class="identifier">main</span><span class="special">()</span>
+<span class="special">{</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">handle</span><span class="special">&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="special">&gt;</span> <span class="identifier">h</span><span class="special">(</span> <span class="comment">// get handle associated with the task
+</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">async</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">new_thread</span><span class="special">(),</span> <span class="comment">// asynchronous executor
+</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">make_task</span><span class="special">(</span> <span class="comment">// long runing task, to be executed asynchronously
+</span> <span class="identifier">long_running</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="identifier">millisec</span><span class="special">(</span> <span class="number">500</span><span class="special">)</span> <span class="special">)</span> <span class="special">)</span> <span class="special">);</span>
+ <span class="identifier">h</span><span class="special">.</span><span class="identifier">interrupt</span><span class="special">();</span> <span class="comment">// interrupt execution of task
+</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">h</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">// wait until task is finished, will throw an exeception
+</span><span class="special">}</span>
+</pre>
+<p>
+ </p>
+<p>
+ Beside <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">new_thread</span></code>
+ (which creates a new task for each submitted task) <span class="bold"><strong>Boost.Task</strong></span>
+ provides <a class="link" href="pool.html" title="Thread-pool"><span class="emphasis"><em>thread-pools</em></span></a>
+ to prevent the overhead of thread creation and destruction for each task.
+ <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">default_pool</span></code>
+ submitts the tasks to the default <span class="emphasis"><em>thread-pool</em></span> which contains
+ a fixed number of pre-spawned <span class="emphasis"><em>worker-threads</em></span> (custom
+ <span class="emphasis"><em>thread-pools</em></span> are supported too).
+ </p>
+<p>
+
+</p>
+<pre class="programlisting"><span class="keyword">long</span> <span class="identifier">serial_fib</span><span class="special">(</span> <span class="keyword">long</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">2</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">serial_fib</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="identifier">serial_fib</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="keyword">long</span> <span class="identifier">parallel_fib</span><span class="special">(</span> <span class="keyword">long</span> <span class="identifier">n</span><span class="special">,</span> <span class="keyword">long</span> <span class="identifier">cutof</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">cutof</span><span class="special">)</span> <span class="keyword">return</span> <span class="identifier">serial_fib</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 sub-task calculating fibonacci(n-1)
+</span> <span class="identifier">h1</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">async</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_pool</span><span class="special">(),</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">make_task</span><span class="special">(</span>
+ <span class="identifier">parallel_fib</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="identifier">cutof</span><span class="special">)</span> <span class="special">);</span>
+ <span class="comment">// fork a sub-task calculating fibonacci(n-2)
+</span> <span class="identifier">h2</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">async</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_pool</span><span class="special">(),</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">make_task</span><span class="special">(</span>
+ <span class="identifier">parallel_fib</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="identifier">cutof</span><span class="special">)</span> <span class="special">);</span>
+ <span class="comment">// join the results of both sub-tasks
+</span> <span class="keyword">return</span> <span class="identifier">h1</span><span class="special">.</span><span class="identifier">get</span><span class="special">()</span> <span class="special">+</span> <span class="identifier">h2</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">void</span> <span class="identifier">main</span><span class="special">()</span>
+<span class="special">{</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">handle</span><span class="special">&lt;</span> <span class="keyword">long</span> <span class="special">&gt;</span> <span class="identifier">h</span><span class="special">(</span> <span class="comment">// handle for fibonacci calculation
+</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">async</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">default_pool</span><span class="special">(),</span> <span class="comment">// access the default thread-pool
+</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">make_task</span><span class="special">(</span> <span class="comment">// calculate fibonacci number 10
+</span> <span class="identifier">parallel_fib</span><span class="special">,</span> <span class="comment">// for numbers &lt; 5 do inline recursive calculation
+</span> <span class="number">10</span><span class="special">,</span>
+ <span class="number">5</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">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">h</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="special">}</span>
+</pre>
+<p>
+ </p>
+<p>
+ With 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">runs_in_pool</span><span class="special">()</span></code>
+ a task can detect if it is executed inside a <span class="emphasis"><em>thread-pool</em></span>.
+ <span class="emphasis"><em>sub-tasks</em></span> arecreated by <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">as_sub_task</span></code>. Where the <span class="emphasis"><em>sub-task</em></span>
+ is executed by a new thread if the parent task is not executed inside a <span class="emphasis"><em>thread-pool</em></span>.
+ In the other case the <span class="emphasis"><em>sub-task</em></span> is put into the local
+ <span class="emphasis"><em>worker-queue</em></span> which enables <a class="link" href="pool.html#boost_task.pool.work_stealing" title="Work-Stealing"><span class="emphasis"><em>work-stealing</em></span></a>
+ and <a class="link" href="pool.html#boost_task.pool.forkjoin" title="Fork/Join">inline execution</a> of tasks.
+ </p>
+<p>
+
+</p>
+<pre class="programlisting"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">async</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">as_sub_task</span><span class="special">(),</span> <span class="comment">// sub-task executed in a new thread or inside
+</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">make_task</span><span class="special">(</span> <span class="comment">// the thread-pool depending upon the parent
+</span> <span class="identifier">parallel_fib</span><span class="special">,</span> <span class="comment">// task is executed inside a thread-pool or not
+</span> <span class="number">10</span><span class="special">,</span>
+ <span class="number">5</span><span class="special">)</span> <span class="special">)</span> <span class="special">);</span>
+</pre>
+<p>
+ </p>
+<div class="footnotes">
+<br><hr width="100" align="left">
+<div class="footnote"><p><sup>[<a name="ftn.id563974" href="#id563974" class="para">1</a>] </sup>
+ more to read at Daniel's blog
+ </p></div>
+</div>
+</div>
+<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
+<td align="left"></td>
+<td align="right"><div class="copyright-footer">Copyright © 2009 Oliver Kowalke<p>
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ </p>
+</div></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="../index.html"><img src="../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="task.html"><img src="../../../doc/html/images/next.png" alt="Next"></a>
+</div>
+</body>
+</html>

Added: sandbox/task/libs/task/doc/html/boost_task/new_thread.html
==============================================================================
--- (empty file)
+++ sandbox/task/libs/task/doc/html/boost_task/new_thread.html 2009-06-01 08:13:01 EDT (Mon, 01 Jun 2009)
@@ -0,0 +1,109 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>Execute in new thread</title>
+<link rel="stylesheet" href="../boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.75.0">
+<link rel="home" href="../index.html" title="Chapter 1. Boost.Task">
+<link rel="up" href="../index.html" title="Chapter 1. Boost.Task">
+<link rel="prev" href="own_thread.html" title="Execute in own thread">
+<link rel="next" href="pool.html" title="Thread-pool">
+</head>
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<table cellpadding="2" width="100%"><tr>
+<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td>
+<td align="center">Home</td>
+<td align="center">Libraries</td>
+<td align="center">People</td>
+<td align="center">FAQ</td>
+<td align="center">More</td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="own_thread.html"><img src="../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="pool.html"><img src="../../../doc/html/images/next.png" alt="Next"></a>
+</div>
+<div class="section" title="Execute in new thread">
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="boost_task.new_thread"></a><a class="link" href="new_thread.html" title="Execute in new thread"> Execute in new thread</a>
+</h2></div></div></div>
+<p>
+ <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">new_thread</span></code>
+ creates a new <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">thread</span></code> and executes the task in this thread
+ (asynchronous). The created thread gets joined by handle (so N2802
+ should be addressed).
+ </p>
+<div class="caution" title="Caution"><table border="0" summary="Caution">
+<tr>
+<td rowspan="2" align="center" valign="top" width="25"><img alt="[Caution]" src="../../../doc/html/images/caution.png"></td>
+<th align="left">Caution</th>
+</tr>
+<tr><td align="left" valign="top"><p>
+ Always store the returned <span class="emphasis"><em>asynchronous-completion-token</em></span>
+ in a variable because <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">handle</span></code>
+ joins the thread in its destructor (if the last reference gets out of scope).
+ </p></td></tr>
+</table></div>
+<p>
+
+</p>
+<pre class="programlisting"><span class="keyword">long</span> <span class="identifier">fibonacci</span><span class="special">(</span> <span class="keyword">long</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">==</span> <span class="number">0</span><span class="special">)</span> <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span>
+ <span class="keyword">if</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="keyword">return</span> <span class="number">1</span><span class="special">;</span>
+ <span class="keyword">long</span> <span class="identifier">k1</span><span class="special">(</span> <span class="number">1</span><span class="special">),</span> <span class="identifier">k2</span><span class="special">(</span> <span class="number">0</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">2</span><span class="special">);</span> <span class="identifier">i</span> <span class="special">&lt;=</span> <span class="identifier">n</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span>
+ <span class="special">{</span>
+ <span class="keyword">long</span> <span class="identifier">tmp</span><span class="special">(</span> <span class="identifier">k1</span><span class="special">);</span>
+ <span class="identifier">k1</span> <span class="special">=</span> <span class="identifier">k1</span> <span class="special">+</span> <span class="identifier">k2</span><span class="special">;</span>
+ <span class="identifier">k2</span> <span class="special">=</span> <span class="identifier">tmp</span><span class="special">;</span>
+ <span class="special">}</span>
+ <span class="keyword">return</span> <span class="identifier">k1</span><span class="special">;</span>
+<span class="special">}</span>
+
+<span class="keyword">void</span> <span class="identifier">main</span><span class="special">()</span>
+<span class="special">{</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">handle</span><span class="special">&lt;</span> <span class="keyword">long</span> <span class="special">&gt;</span> <span class="identifier">h</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">async</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">new_thread</span><span class="special">(),</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">make_task</span><span class="special">(</span>
+ <span class="identifier">fibonacci</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">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"fibonacci(10) == "</span> <span class="special">&lt;&lt;</span> <span class="identifier">h</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="special">}</span>
+</pre>
+<p>
+ </p>
+<p>
+ In the example below both <code class="computeroutput"><span class="identifier">a_function</span><span class="special">()</span></code> and <code class="computeroutput"><span class="identifier">another_function</span><span class="special">()</span></code> are executed synchron (see <a class="link" href="own_thread.html" title="Execute in own thread"><code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">own_thread</span></code></a>
+ for synchronous execution)!
+ </p>
+<p>
+
+</p>
+<pre class="programlisting"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">async</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">new_thread</span><span class="special">(),</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">make_task</span><span class="special">(</span>
+ <span class="identifier">a_function</span><span class="special">)</span> <span class="special">)</span> <span class="special">);</span>
+
+<span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">async</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">new_thread</span><span class="special">(),</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">make_task</span><span class="special">(</span>
+ <span class="identifier">another_function</span><span class="special">)</span> <span class="special">)</span> <span class="special">);</span>
+</pre>
+<p>
+ </p>
+</div>
+<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
+<td align="left"></td>
+<td align="right"><div class="copyright-footer">Copyright © 2009 Oliver Kowalke<p>
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ </p>
+</div></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="own_thread.html"><img src="../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="pool.html"><img src="../../../doc/html/images/next.png" alt="Next"></a>
+</div>
+</body>
+</html>

Added: sandbox/task/libs/task/doc/html/boost_task/own_thread.html
==============================================================================
--- (empty file)
+++ sandbox/task/libs/task/doc/html/boost_task/own_thread.html 2009-06-01 08:13:01 EDT (Mon, 01 Jun 2009)
@@ -0,0 +1,79 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>Execute in own thread</title>
+<link rel="stylesheet" href="../boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.75.0">
+<link rel="home" href="../index.html" title="Chapter 1. Boost.Task">
+<link rel="up" href="../index.html" title="Chapter 1. Boost.Task">
+<link rel="prev" href="handle.html" title="Handle">
+<link rel="next" href="new_thread.html" title="Execute in new thread">
+</head>
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<table cellpadding="2" width="100%"><tr>
+<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td>
+<td align="center">Home</td>
+<td align="center">Libraries</td>
+<td align="center">People</td>
+<td align="center">FAQ</td>
+<td align="center">More</td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="handle.html"><img src="../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="new_thread.html"><img src="../../../doc/html/images/next.png" alt="Next"></a>
+</div>
+<div class="section" title="Execute in own thread">
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="boost_task.own_thread"></a><a class="link" href="own_thread.html" title="Execute in own thread"> Execute in own thread</a>
+</h2></div></div></div>
+<p>
+ <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">own_thread</span></code>
+ executes the task in the current thread (synchronous execution - concerns of
+ N2802
+ do not aply).
+ </p>
+<p>
+
+</p>
+<pre class="programlisting"><span class="keyword">long</span> <span class="identifier">fibonacci</span><span class="special">(</span> <span class="keyword">long</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">==</span> <span class="number">0</span><span class="special">)</span> <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span>
+ <span class="keyword">if</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="keyword">return</span> <span class="number">1</span><span class="special">;</span>
+ <span class="keyword">long</span> <span class="identifier">k1</span><span class="special">(</span> <span class="number">1</span><span class="special">),</span> <span class="identifier">k2</span><span class="special">(</span> <span class="number">0</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">2</span><span class="special">);</span> <span class="identifier">i</span> <span class="special">&lt;=</span> <span class="identifier">n</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span>
+ <span class="special">{</span>
+ <span class="keyword">long</span> <span class="identifier">tmp</span><span class="special">(</span> <span class="identifier">k1</span><span class="special">);</span>
+ <span class="identifier">k1</span> <span class="special">=</span> <span class="identifier">k1</span> <span class="special">+</span> <span class="identifier">k2</span><span class="special">;</span>
+ <span class="identifier">k2</span> <span class="special">=</span> <span class="identifier">tmp</span><span class="special">;</span>
+ <span class="special">}</span>
+ <span class="keyword">return</span> <span class="identifier">k1</span><span class="special">;</span>
+<span class="special">}</span>
+
+<span class="keyword">void</span> <span class="identifier">main</span><span class="special">()</span>
+<span class="special">{</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">handle</span><span class="special">&lt;</span> <span class="keyword">long</span> <span class="special">&gt;</span> <span class="identifier">h</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">async</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">own_thread</span><span class="special">(),</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">make_task</span><span class="special">(</span>
+ <span class="identifier">fibonacci</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">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"fibonacci(10) == "</span> <span class="special">&lt;&lt;</span> <span class="identifier">h</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="special">}</span>
+</pre>
+<p>
+ </p>
+</div>
+<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
+<td align="left"></td>
+<td align="right"><div class="copyright-footer">Copyright © 2009 Oliver Kowalke<p>
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ </p>
+</div></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="handle.html"><img src="../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="new_thread.html"><img src="../../../doc/html/images/next.png" alt="Next"></a>
+</div>
+</body>
+</html>

Added: sandbox/task/libs/task/doc/html/boost_task/pool.html
==============================================================================
--- (empty file)
+++ sandbox/task/libs/task/doc/html/boost_task/pool.html 2009-06-01 08:13:01 EDT (Mon, 01 Jun 2009)
@@ -0,0 +1,729 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>Thread-pool</title>
+<link rel="stylesheet" href="../boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.75.0">
+<link rel="home" href="../index.html" title="Chapter 1. Boost.Task">
+<link rel="up" href="../index.html" title="Chapter 1. Boost.Task">
+<link rel="prev" href="new_thread.html" title="Execute in new thread">
+<link rel="next" href="as_sub_task.html" title="Execute as sub-task">
+</head>
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<table cellpadding="2" width="100%"><tr>
+<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td>
+<td align="center">Home</td>
+<td align="center">Libraries</td>
+<td align="center">People</td>
+<td align="center">FAQ</td>
+<td align="center">More</td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="new_thread.html"><img src="../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="as_sub_task.html"><img src="../../../doc/html/images/next.png" alt="Next"></a>
+</div>
+<div class="section" title="Thread-pool">
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="boost_task.pool"></a><a class="link" href="pool.html" title="Thread-pool"> Thread-pool</a>
+</h2></div></div></div>
+<div class="toc"><dl>
+<dt><span class="section"> Static thread-pool</span></dt>
+<dt><span class="section"> Channel</span></dt>
+<dt><span class="section"> Scheduling</span></dt>
+<dt><span class="section"> Pool shutdown</span></dt>
+<dt><span class="section"> Default pool</span></dt>
+<dt><span class="section"> Processor binding</span></dt>
+<dt><span class="section"> Work-Stealing</span></dt>
+<dt><span class="section"> Fork/Join</span></dt>
+</dl></div>
+<p>
+ Instead of creating a new thread and quickly throwing it away after the task
+ is done, the overhead related to thread creation and destruction can be avoided
+ by running the <span class="emphasis"><em>work-items</em></span> on a <span class="emphasis"><em>thread-pool</em></span>
+ (reusing an existing <span class="emphasis"><em>worker-thread</em></span> instead).
+ </p>
+<p>
+ A <span class="emphasis"><em>thread-pool</em></span> maintains a queue (or queues) of <span class="emphasis"><em>work-items</em></span>
+ to be done, and a pool of <span class="emphasis"><em>worker-threads</em></span> which execute
+ <span class="emphasis"><em>work-items</em></span> from the queue(s).
+ </p>
+<p>
+ <span class="bold"><strong>Boost.Task</strong></span> provides <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">async</span><span class="special">()</span></code> with
+ support of executing an <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">task</span></code> in <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">default_pool</span></code> (using <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">default_pool</span><span class="special">()</span></code>):
+ </p>
+<p>
+
+</p>
+<pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="identifier">echo</span><span class="special">(</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">msg</span><span class="special">)</span>
+<span class="special">{</span> <span class="keyword">return</span> <span class="identifier">msg</span><span class="special">;</span> <span class="special">}</span>
+
+<span class="keyword">void</span> <span class="identifier">main</span><span class="special">()</span>
+<span class="special">{</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">handle</span><span class="special">&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="special">&gt;</span> <span class="identifier">h</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">async</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">default_pool</span><span class="special">(),</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">make_task</span><span class="special">(</span>
+ <span class="identifier">echo</span><span class="special">,</span>
+ <span class="string">"Hello World!"</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">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">h</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="special">}</span>
+</pre>
+<p>
+ </p>
+<p>
+ and a custom <span class="emphasis"><em>thread-pool</em></span> (passing pool instance as an
+ argument to <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">async</span><span class="special">()</span></code>):
+ </p>
+<p>
+
+</p>
+<pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="identifier">echo</span><span class="special">(</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">msg</span><span class="special">)</span>
+<span class="special">{</span> <span class="keyword">return</span> <span class="identifier">msg</span><span class="special">;</span> <span class="special">}</span>
+
+<span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">static_pool</span><span class="special">&lt;</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</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">task</span><span class="special">::</span><span class="identifier">fifo</span>
+ <span class="special">&gt;</span>
+<span class="special">&gt;</span> <span class="identifier">pool</span><span class="special">(</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">poolsize</span><span class="special">(</span> <span class="number">5</span><span class="special">)</span> <span class="special">);</span>
+
+<span class="keyword">void</span> <span class="identifier">main</span><span class="special">()</span>
+<span class="special">{</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">handle</span><span class="special">&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="special">&gt;</span> <span class="identifier">h</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">async</span><span class="special">(</span>
+ <span class="identifier">pool</span><span class="special">,</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">make_task</span><span class="special">(</span>
+ <span class="identifier">echo</span><span class="special">,</span>
+ <span class="string">"Hello World!"</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">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">h</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="special">}</span>
+</pre>
+<p>
+ .
+ </p>
+<div class="important" title="Important"><table border="0" summary="Important">
+<tr>
+<td rowspan="2" align="center" valign="top" width="25"><img alt="[Important]" src="../../../doc/html/images/important.png"></td>
+<th align="left">Important</th>
+</tr>
+<tr><td align="left" valign="top"><p>
+ Tasks should not be too small (performance overhead dominates) and avoid
+ blocking tasks
+ <sup>[<a name="id575100" href="#ftn.id575100" class="footnote">4</a>]</sup>
+ .
+ </p></td></tr>
+</table></div>
+<div class="section" title="Static thread-pool">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_task.pool.static_pool"></a><a class="link" href="pool.html#boost_task.pool.static_pool" title="Static thread-pool"> Static thread-pool</a>
+</h3></div></div></div>
+<p>
+ <span class="bold"><strong>Boost.Task</strong></span> provides <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">static_pool</span></code>
+ - which contains an fixed set of pre-forked <span class="emphasis"><em>worker-threads</em></span>
+ (the size of the pool doesn't change during its lifetime).
+ </p>
+<p>
+
+</p>
+<pre class="programlisting"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">_static_pool</span><span class="special">&lt;</span> <span class="comment">// pool type
+</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">unbounded_channel</span><span class="special">&lt;</span> <span class="comment">// queuing policy (unbounded_channel, bounded_channel)
+</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">fifo</span> <span class="comment">// scheduling policy (fifo, priority, smart)
+</span> <span class="special">&gt;</span>
+<span class="special">&gt;</span> <span class="identifier">pool</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">poolsize</span><span class="special">(</span> <span class="number">6</span><span class="special">),</span> <span class="comment">// pool with 6 pre-forked worker-threads
+</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">posix_time</span><span class="special">::</span><span class="identifier">posix_time</span><span class="special">::</span><span class="identifier">milliseconds</span><span class="special">(</span> <span class="number">50</span><span class="special">),</span> <span class="comment">// time to sleep if no work-item available
+</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">scanns</span><span class="special">(</span> <span class="number">10</span><span class="special">)</span> <span class="special">);</span> <span class="comment">// iterations over local-queues before sleep
+</span></pre>
+<p>
+ </p>
+<p>
+ The first argument of the constructor specifies how many <span class="emphasis"><em>worker-threads</em></span>
+ the pool will contain. The second and third argument are used by the <a class="link" href="pool.html#boost_task.pool.work_stealing" title="Work-Stealing"><span class="emphasis"><em>work-stealing</em></span></a>
+ algorithm.
+ </p>
+<div class="note" title="Note"><table border="0" summary="Note">
+<tr>
+<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../doc/html/images/note.png"></td>
+<th align="left">Note</th>
+</tr>
+<tr><td align="left" valign="top"><p>
+ If <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">bounded_channel</span></code> is used as queuing policy
+ the constructor has two additional arguments .
+ </p></td></tr>
+</table></div>
+<p>
+ <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">static_pool</span></code> provides functionality to check
+ the status of the pool - <code class="computeroutput"><span class="identifier">close</span><span class="special">()</span></code> returns true when the pool was shutdown
+ and <code class="computeroutput"><span class="identifier">active</span><span class="special">()</span></code>
+ as well as <code class="computeroutput"><span class="identifier">idle</span><span class="special">()</span></code>
+ returning how many <span class="emphasis"><em>worker-threads</em></span> are active (executing
+ a task) or idle. The size of the pool can be accessed over <code class="computeroutput"><span class="identifier">size</span><span class="special">()</span></code>.
+ </p>
+<p>
+ For infomational pruposes <code class="computeroutput"><span class="identifier">empty</span><span class="special">()</span></code> and <code class="computeroutput"><span class="identifier">pending</span><span class="special">()()</span></code> can be used in order to know if the global
+ task-queue is empty or how many tasks are waiting for execution. With <code class="computeroutput"><span class="identifier">clear</span><span class="special">()</span></code>
+ all tasks are removed from the global-queue.
+ </p>
+<div class="note" title="Note"><table border="0" summary="Note">
+<tr>
+<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../doc/html/images/note.png"></td>
+<th align="left">Note</th>
+</tr>
+<tr><td align="left" valign="top"><p>
+ <code class="computeroutput"><span class="identifier">pending</span><span class="special">()()</span></code>
+ does not count tasks in the local-queues of the <span class="emphasis"><em>worker-threads</em></span>.
+ </p></td></tr>
+</table></div>
+</div>
+<div class="section" title="Channel">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_task.pool.channel"></a><a class="link" href="pool.html#boost_task.pool.channel" title="Channel"> Channel</a>
+</h3></div></div></div>
+<p>
+ The channel synchronizes the access between non-pool threads (application
+ threads) and <span class="emphasis"><em>worker-threads</em></span> and implements a queuing
+ policy (limitation of queued tasks).
+ </p>
+<a name="boost_task.pool.channel._code__phrase_role__identifier__boost__phrase__phrase_role__special______phrase__phrase_role__identifier__task__phrase__phrase_role__special______phrase__phrase_role__identifier__bounded_channel__phrase___code_"></a><h5>
+<a name="id575703"></a>
+ <a class="link" href="pool.html#boost_task.pool.channel._code__phrase_role__identifier__boost__phrase__phrase_role__special______phrase__phrase_role__identifier__task__phrase__phrase_role__special______phrase__phrase_role__identifier__bounded_channel__phrase___code_"><code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">bounded_channel</span></code></a>
+ </h5>
+<p>
+ <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">bounded_channel</span></code> contains a single lock
+ in order to synchronize access to the queue. The number of pending tasks
+ is limited in order to prevent resource exhaustion. For this purpose a high-
+ and low-watermark has to be passed at construction. <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">high_watermark</span></code>
+ sets the maximum of pending tasks. If this limited is reached all threads
+ which submit a task will be set to sleep (blocked). If it is equal to <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">low_watermark</span></code> everytime a sleeping producer
+ thread will be woken up and puts its task if one worker thread has taken
+ a task from the channel. <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">low_watermark</span></code>
+ sets the threshold when blocked threads get woken up. If it is less than
+ <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">high_watermark</span></code> all sleeping producer threads
+ will be woken up if the amount of pending tasks reaches <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">low_watermark</span></code>.
+ </p>
+<a name="boost_task.pool.channel._code__phrase_role__identifier__boost__phrase__phrase_role__special______phrase__phrase_role__identifier__task__phrase__phrase_role__special______phrase__phrase_role__identifier__unbounded_channel__phrase___code_"></a><h5>
+<a name="id575935"></a>
+ <a class="link" href="pool.html#boost_task.pool.channel._code__phrase_role__identifier__boost__phrase__phrase_role__special______phrase__phrase_role__identifier__task__phrase__phrase_role__special______phrase__phrase_role__identifier__unbounded_channel__phrase___code_"><code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">unbounded_channel</span></code></a>
+ </h5>
+<p>
+ <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">unbounded_channel</span></code> contains a single lock
+ in order to synchronize access to the queue. An unlimited number of tasks
+ can be queued into this channel. The insertion of an <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">task</span></code>
+ will never block. If the channel becomes empty <span class="emphasis"><em>worker-threads</em></span>
+ will be set to sleep until new tasks are enqueued.
+ </p>
+</div>
+<div class="section" title="Scheduling">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_task.pool.scheduling"></a><a class="link" href="pool.html#boost_task.pool.scheduling" title="Scheduling"> Scheduling</a>
+</h3></div></div></div>
+<p>
+ The scheduling policy determines how tasks are scheduled inside the <span class="emphasis"><em>channel</em></span>.
+ </p>
+<a name="boost_task.pool.scheduling.fifo"></a><h5>
+<a name="id576076"></a>
+ <a class="link" href="pool.html#boost_task.pool.scheduling.fifo">fifo</a>
+ </h5>
+<p>
+ First inserted pending <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">task</span></code>
+ gets taken first.
+ </p>
+<a name="boost_task.pool.scheduling.priority"></a><h5>
+<a name="id576127"></a>
+ <a class="link" href="pool.html#boost_task.pool.scheduling.priority">priority</a>
+ </h5>
+<p>
+ Each <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">task</span></code> is submitted to the pool with a priority
+ attribute. The type and ordering of the priority is user-defined.
+ </p>
+<p>
+
+</p>
+<pre class="programlisting"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">static_pool</span><span class="special">&lt;</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">unbounded_channel</span><span class="special">&lt;</span> <span class="comment">// allow unlimited tasks to be queue in global-queue
+</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">priority</span><span class="special">&lt;</span> <span class="keyword">int</span> <span class="special">&gt;</span> <span class="special">&gt;</span> <span class="comment">// tasks with lower priority are scheduled first
+</span><span class="special">&gt;</span> <span class="identifier">pool</span><span class="special">(</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">poolsize</span><span class="special">(</span> <span class="number">5</span><span class="special">)</span> <span class="special">);</span>
+
+<span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">async</span><span class="special">(</span>
+ <span class="identifier">pool</span><span class="special">,</span> <span class="comment">// thread-pool
+</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">make_task</span><span class="special">(</span> <span class="identifier">some_fn</span><span class="special">),</span> <span class="comment">// task to be executed
+</span> <span class="number">5</span><span class="special">);</span> <span class="comment">// priority is 5
+</span>
+<span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">async</span><span class="special">(</span>
+ <span class="identifier">pool</span><span class="special">,</span> <span class="comment">// thread-pool
+</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">make_task</span><span class="special">(</span> <span class="identifier">another_fn</span><span class="special">),</span> <span class="comment">// task to be executed
+</span> <span class="number">3</span><span class="special">);</span> <span class="comment">// priority is 3
+</span></pre>
+<p>
+ </p>
+<p>
+ In this example the tasks get scheduled by the assigned integer (third argument
+ of <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">async</span><span class="special">()</span></code>).
+ The <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">task</span></code> with the lowest priority gets scheduled
+ first (taken by a <span class="emphasis"><em>worker-thread</em></span>). The ordering can be
+ changed by the second argument of <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">priority</span></code>
+ (the default is <code class="computeroutput"><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></code>).
+ </p>
+<p>
+
+</p>
+<pre class="programlisting"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">static_pool</span><span class="special">&lt;</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</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">task</span><span class="special">::</span><span class="identifier">priority</span><span class="special">&lt;</span> <span class="keyword">int</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">greater</span><span class="special">&lt;</span> <span class="keyword">int</span> <span class="special">&gt;</span> <span class="special">&gt;</span> <span class="special">&gt;</span> <span class="comment">// tasks with higher priority are scheduled first
+</span>
+<span class="special">&gt;</span> <span class="identifier">pool</span><span class="special">(</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">poolsize</span><span class="special">(</span> <span class="number">5</span><span class="special">)</span> <span class="special">);</span>
+</pre>
+<p>
+ </p>
+<a name="boost_task.pool.scheduling.smart"></a><h5>
+<a name="id576914"></a>
+ <a class="link" href="pool.html#boost_task.pool.scheduling.smart">smart</a>
+ </h5>
+<p>
+ Each inserted <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">task</span></code> is associated with an attribute. The
+ scheduler gets an put- and take-policy as template arguments. The corresponding
+ policy gets applied for each insertion and removal.
+ </p>
+<p>
+ <span class="bold"><strong>Boost.Task</strong></span> provides <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">replace_oldest</span></code>
+ as put- policy and <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">take_oldest</span></code>
+ as take-policy. Both policies allow the replacement of older (pending) tasks
+ in the scheduler by new ones.
+ </p>
+<p>
+
+</p>
+<pre class="programlisting"><span class="keyword">long</span> <span class="identifier">fibonacci_fn</span><span class="special">(</span> <span class="keyword">long</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">==</span> <span class="number">0</span><span class="special">)</span> <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span>
+ <span class="keyword">if</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="keyword">return</span> <span class="number">1</span><span class="special">;</span>
+ <span class="keyword">long</span> <span class="identifier">k1</span><span class="special">(</span> <span class="number">1</span><span class="special">),</span> <span class="identifier">k2</span><span class="special">(</span> <span class="number">0</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">2</span><span class="special">);</span> <span class="identifier">i</span> <span class="special">&lt;=</span> <span class="identifier">n</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span>
+ <span class="special">{</span>
+ <span class="keyword">long</span> <span class="identifier">tmp</span><span class="special">(</span> <span class="identifier">k1</span><span class="special">);</span>
+ <span class="identifier">k1</span> <span class="special">=</span> <span class="identifier">k1</span> <span class="special">+</span> <span class="identifier">k2</span><span class="special">;</span>
+ <span class="identifier">k2</span> <span class="special">=</span> <span class="identifier">tmp</span><span class="special">;</span>
+ <span class="special">}</span>
+ <span class="keyword">return</span> <span class="identifier">k1</span><span class="special">;</span>
+<span class="special">}</span>
+
+<span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">static_pool</span><span class="special">&lt;</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</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">task</span><span class="special">::</span><span class="identifier">smart</span><span class="special">&lt;</span>
+ <span class="keyword">int</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="keyword">int</span> <span class="special">&gt;,</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">replace_oldest</span><span class="special">,</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">take_oldest</span>
+ <span class="special">&gt;</span>
+ <span class="special">&gt;</span>
+<span class="special">&gt;</span> <span class="identifier">pool_type</span><span class="special">;</span>
+
+<span class="keyword">void</span> <span class="identifier">main</span><span class="special">()</span>
+<span class="special">{</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">task</span><span class="special">::</span><span class="identifier">poolsize</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">// replaced by later task with same attribute == 2
+</span> <span class="comment">// if still pending in pool
+</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">async</span><span class="special">(</span>
+ <span class="identifier">pool</span><span class="special">,</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">make_task</span><span class="special">(</span> <span class="identifier">fibonacci_fn</span><span class="special">,</span> <span class="number">10</span><span class="special">),</span>
+ <span class="number">2</span><span class="special">);</span> <span class="comment">// attribute is 2
+</span>
+ <span class="comment">// will replace previous pending task with attribute == 2
+</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">async</span><span class="special">(</span>
+ <span class="identifier">pool</span><span class="special">,</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">make_task</span><span class="special">(</span> <span class="identifier">fibonacci_fn</span><span class="special">,</span> <span class="number">5</span><span class="special">),</span>
+ <span class="number">2</span><span class="special">);</span> <span class="comment">// attribute is 2 too
+</span><span class="special">}</span>
+</pre>
+<p>
+ </p>
+</div>
+<div class="section" title="Pool shutdown">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_task.pool.pool_shutdown"></a><a class="link" href="pool.html#boost_task.pool.pool_shutdown" title="Pool shutdown"> Pool shutdown</a>
+</h3></div></div></div>
+<p>
+ <span class="bold"><strong>Boost.Task</strong></span> allows to shutdown a <span class="emphasis"><em>thread-pool</em></span>
+ explicitly via functions <code class="computeroutput"><span class="identifier">shutdown</span><span class="special">()</span></code> and <code class="computeroutput"><span class="identifier">shutdown_now</span><span class="special">()</span></code>. The destructor of the pool calls <code class="computeroutput"><span class="identifier">shutdown</span><span class="special">()</span></code>
+ if not already done so that all <span class="emphasis"><em>worker-threads</em></span> are joined
+ and the topic of N2802
+ should be addressed.
+ </p>
+<a name="boost_task.pool.pool_shutdown.shutdown"></a><h5>
+<a name="id578010"></a>
+ <a class="link" href="pool.html#boost_task.pool.pool_shutdown.shutdown">Shutdown</a>
+ </h5>
+<p>
+ If <code class="computeroutput"><span class="identifier">shutdown</span><span class="special">()</span></code>
+ is called - the the pool is set the closed state and all <span class="emphasis"><em>worker-threads</em></span>
+ are joined until all pending tasks are processed. No futher tasks can be
+ submitted.
+ </p>
+<div class="note" title="Note"><table border="0" summary="Note">
+<tr>
+<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../doc/html/images/note.png"></td>
+<th align="left">Note</th>
+</tr>
+<tr><td align="left" valign="top"><p>
+ The deconstructor calls <code class="computeroutput"><span class="identifier">shutdown</span><span class="special">()</span></code> if the pool was not shutdown yet.
+ </p></td></tr>
+</table></div>
+<p>
+
+</p>
+<pre class="programlisting"><span class="keyword">long</span> <span class="identifier">fibonacci_fn</span><span class="special">(</span> <span class="keyword">long</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">==</span> <span class="number">0</span><span class="special">)</span> <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span>
+ <span class="keyword">if</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="keyword">return</span> <span class="number">1</span><span class="special">;</span>
+ <span class="keyword">long</span> <span class="identifier">k1</span><span class="special">(</span> <span class="number">1</span><span class="special">),</span> <span class="identifier">k2</span><span class="special">(</span> <span class="number">0</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">2</span><span class="special">);</span> <span class="identifier">i</span> <span class="special">&lt;=</span> <span class="identifier">n</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span>
+ <span class="special">{</span>
+ <span class="keyword">long</span> <span class="identifier">tmp</span><span class="special">(</span> <span class="identifier">k1</span><span class="special">);</span>
+ <span class="identifier">k1</span> <span class="special">=</span> <span class="identifier">k1</span> <span class="special">+</span> <span class="identifier">k2</span><span class="special">;</span>
+ <span class="identifier">k2</span> <span class="special">=</span> <span class="identifier">tmp</span><span class="special">;</span>
+ <span class="special">}</span>
+ <span class="keyword">return</span> <span class="identifier">k1</span><span class="special">;</span>
+<span class="special">}</span>
+
+<span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">static_pool</span><span class="special">&lt;</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</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">task</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">void</span> <span class="identifier">main</span><span class="special">()</span>
+<span class="special">{</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">task</span><span class="special">::</span><span class="identifier">poolsize</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">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">handle</span><span class="special">&lt;</span> <span class="keyword">long</span> <span class="special">&gt;</span> <span class="identifier">h1</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">async</span><span class="special">(</span>
+ <span class="identifier">pool</span><span class="special">,</span> <span class="comment">// asynchronous executor
+</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">make_task</span><span class="special">(</span> <span class="identifier">fibonacci_fn</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">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">handle</span><span class="special">&lt;</span> <span class="keyword">long</span> <span class="special">&gt;</span> <span class="identifier">h2</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">async</span><span class="special">(</span>
+ <span class="identifier">pool</span><span class="special">,</span> <span class="comment">// asynchronous executor
+</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">make_task</span><span class="special">(</span> <span class="identifier">fibonacci_fn</span><span class="special">,</span> <span class="number">5</span><span class="special">)</span> <span class="special">)</span> <span class="special">);</span>
+
+ <span class="identifier">pool</span><span class="special">.</span><span class="identifier">shutdown</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(10) == "</span> <span class="special">&lt;&lt;</span> <span class="identifier">h1</span><span class="special">.</span><span class="identifier">get</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="string">"\n"</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(5) == "</span> <span class="special">&lt;&lt;</span> <span class="identifier">h2</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="special">}</span>
+</pre>
+<p>
+ </p>
+<a name="boost_task.pool.pool_shutdown.shutdown_immediatly"></a><h5>
+<a name="id579109"></a>
+ <a class="link" href="pool.html#boost_task.pool.pool_shutdown.shutdown_immediatly">Shutdown
+ immediatly</a>
+ </h5>
+<p>
+ The function <code class="computeroutput"><span class="identifier">shutdown_now</span><span class="special">()</span></code> closes the pool, interrupts and then joins
+ all <span class="emphasis"><em>worker-threads</em></span>. Pending tasks are unprocessed.
+ </p>
+<p>
+
+</p>
+<pre class="programlisting"><span class="keyword">long</span> <span class="identifier">fibonacci_fn</span><span class="special">(</span> <span class="keyword">long</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">==</span> <span class="number">0</span><span class="special">)</span> <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span>
+ <span class="keyword">if</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="keyword">return</span> <span class="number">1</span><span class="special">;</span>
+ <span class="keyword">long</span> <span class="identifier">k1</span><span class="special">(</span> <span class="number">1</span><span class="special">),</span> <span class="identifier">k2</span><span class="special">(</span> <span class="number">0</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">2</span><span class="special">);</span> <span class="identifier">i</span> <span class="special">&lt;=</span> <span class="identifier">n</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span>
+ <span class="special">{</span>
+ <span class="keyword">long</span> <span class="identifier">tmp</span><span class="special">(</span> <span class="identifier">k1</span><span class="special">);</span>
+ <span class="identifier">k1</span> <span class="special">=</span> <span class="identifier">k1</span> <span class="special">+</span> <span class="identifier">k2</span><span class="special">;</span>
+ <span class="identifier">k2</span> <span class="special">=</span> <span class="identifier">tmp</span><span class="special">;</span>
+ <span class="special">}</span>
+ <span class="keyword">return</span> <span class="identifier">k1</span><span class="special">;</span>
+<span class="special">}</span>
+
+<span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">static_pool</span><span class="special">&lt;</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</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">task</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">void</span> <span class="identifier">main</span><span class="special">()</span>
+<span class="special">{</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">task</span><span class="special">::</span><span class="identifier">poolsize</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">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">handle</span><span class="special">&lt;</span> <span class="keyword">long</span> <span class="special">&gt;</span> <span class="identifier">h1</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">async</span><span class="special">(</span>
+ <span class="identifier">pool</span><span class="special">,</span> <span class="comment">// asynchronous executor
+</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">make_task</span><span class="special">(</span> <span class="identifier">fibonacci_fn</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">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">handle</span><span class="special">&lt;</span> <span class="keyword">long</span> <span class="special">&gt;</span> <span class="identifier">h2</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">async</span><span class="special">(</span>
+ <span class="identifier">pool</span><span class="special">,</span> <span class="comment">// asynchronous executor
+</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">make_task</span><span class="special">(</span> <span class="identifier">fibonacci_fn</span><span class="special">,</span> <span class="number">5</span><span class="special">)</span> <span class="special">)</span> <span class="special">);</span>
+
+ <span class="identifier">pool</span><span class="special">.</span><span class="identifier">shutdown_now</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(10) == "</span> <span class="special">&lt;&lt;</span> <span class="identifier">h1</span><span class="special">.</span><span class="identifier">get</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="string">"\n"</span><span class="special">;</span> <span class="comment">// may throw broken_task or task_interrupted
+</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(5) == "</span> <span class="special">&lt;&lt;</span> <span class="identifier">h2</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">// may throw broken_task or task_interrupted
+</span><span class="special">}</span>
+</pre>
+<p>
+ </p>
+</div>
+<div class="section" title="Default pool">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_task.pool.default_pool"></a><a class="link" href="pool.html#boost_task.pool.default_pool" title="Default pool"> Default pool</a>
+</h3></div></div></div>
+<p>
+ The library provides a default-pool accessible via <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">default_pool</span><span class="special">()</span></code>. The function returns a reference to <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">static_pool</span><span class="special">&lt;</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</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">task</span><span class="special">::</span><span class="identifier">fifo</span> <span class="special">&gt;</span> <span class="special">&gt;</span></code>. The static instance of <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">default_pool</span></code> contains as many <span class="emphasis"><em>worker-threads</em></span>
+ as <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">thread</span><span class="special">::</span><span class="identifier">hardware_concurrency</span><span class="special">()</span></code>
+ returns, queues unlimited amount of tasks and schedules the tasks in FIFO-order.
+ </p>
+<p>
+
+</p>
+<pre class="programlisting"><span class="keyword">long</span> <span class="identifier">fibonacci_fn</span><span class="special">(</span> <span class="keyword">long</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">==</span> <span class="number">0</span><span class="special">)</span> <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span>
+ <span class="keyword">if</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="keyword">return</span> <span class="number">1</span><span class="special">;</span>
+ <span class="keyword">long</span> <span class="identifier">k1</span><span class="special">(</span> <span class="number">1</span><span class="special">),</span> <span class="identifier">k2</span><span class="special">(</span> <span class="number">0</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">2</span><span class="special">);</span> <span class="identifier">i</span> <span class="special">&lt;=</span> <span class="identifier">n</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span>
+ <span class="special">{</span>
+ <span class="keyword">long</span> <span class="identifier">tmp</span><span class="special">(</span> <span class="identifier">k1</span><span class="special">);</span>
+ <span class="identifier">k1</span> <span class="special">=</span> <span class="identifier">k1</span> <span class="special">+</span> <span class="identifier">k2</span><span class="special">;</span>
+ <span class="identifier">k2</span> <span class="special">=</span> <span class="identifier">tmp</span><span class="special">;</span>
+ <span class="special">}</span>
+ <span class="keyword">return</span> <span class="identifier">k1</span><span class="special">;</span>
+<span class="special">}</span>
+
+<span class="keyword">void</span> <span class="identifier">main</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="string">"worker-threads running in default-pool == "</span> <span class="special">&lt;&lt;</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">default_pool</span><span class="special">().</span><span class="identifier">size</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="string">"\n"</span><span class="special">;</span>
+
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">handle</span><span class="special">&lt;</span> <span class="keyword">long</span> <span class="special">&gt;</span> <span class="identifier">h1</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">async</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">default_pool</span><span class="special">(),</span> <span class="comment">// asynchronous executor == default-pool
+</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">make_task</span><span class="special">(</span> <span class="identifier">fibonacci_fn</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">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">handle</span><span class="special">&lt;</span> <span class="keyword">long</span> <span class="special">&gt;</span> <span class="identifier">h2</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">async</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">default_pool</span><span class="special">(),</span> <span class="comment">// asynchronous executor == default-pool
+</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">make_task</span><span class="special">(</span> <span class="identifier">fibonacci_fn</span><span class="special">,</span> <span class="number">5</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">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"fibonacci(10) == "</span> <span class="special">&lt;&lt;</span> <span class="identifier">h1</span><span class="special">.</span><span class="identifier">get</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="string">"\n"</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(5) == "</span> <span class="special">&lt;&lt;</span> <span class="identifier">h2</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="special">}</span>
+</pre>
+<p>
+ </p>
+</div>
+<div class="section" title="Processor binding">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_task.pool.processor_binding"></a><a class="link" href="pool.html#boost_task.pool.processor_binding" title="Processor binding"> Processor binding</a>
+</h3></div></div></div>
+<p>
+ For some applications it is convenient to bind the <span class="emphasis"><em>worker-threads</em></span>
+ to processors/cores of the system. For this purpose <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">poolsize</span></code>
+ must not be given to the constructor so that a <span class="emphasis"><em>worker-thread</em></span>
+ is created an bound the the core.
+ </p>
+<p>
+
+</p>
+<pre class="programlisting"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">static_pool</span><span class="special">&lt;</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</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</span><span class="special">;</span> <span class="comment">// constructs thread-pool with worker-threads as hardware_concurrency() returns
+</span></pre>
+<p>
+ </p>
+<p>
+ The constructor takes additional arguments for the link_work_stealing[work-stealing
+ algorithm] and link_channel[high-] and link_channel[low-watermark] too.
+ </p>
+<div class="note" title="Note"><table border="0" summary="Note">
+<tr>
+<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../doc/html/images/note.png"></td>
+<th align="left">Note</th>
+</tr>
+<tr><td align="left" valign="top"><p>
+ <span class="bold"><strong>Boost.Task</strong></span> does provide this feature only
+ for Windows, Linux, AIX, HP-UX and Solaris.
+ </p></td></tr>
+</table></div>
+</div>
+<div class="section" title="Work-Stealing">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_task.pool.work_stealing"></a><a class="link" href="pool.html#boost_task.pool.work_stealing" title="Work-Stealing"> Work-Stealing</a>
+</h3></div></div></div>
+<p>
+ Traditional <span class="emphasis"><em>thread-pools</em></span> do not scale because they use
+ a single global-queue protected by a global-lock. The frequency at which
+ <span class="emphasis"><em>worker-threads</em></span> aquire the global-lock becomes a limiting
+ factor for the throughput if:
+ </p>
+<div class="itemizedlist"><ul class="itemizedlist" type="disc">
+<li class="listitem">
+ the tasks become smaller
+ </li>
+<li class="listitem">
+ more processors are added
+ </li>
+</ul></div>
+<p>
+ A <span class="emphasis"><em>work-stealing</em></span> algorithm can be used to solve this
+ problem. It uses a special kind of queue which has two ends, and allows lock-free
+ pushes and pops from the <span class="emphasis"><em>private end</em></span> (accessed by the
+ <span class="emphasis"><em>worker-thread</em></span> owning the queue), but requires synchronization
+ from the <span class="emphasis"><em>public end</em></span> (accessed by the other <span class="emphasis"><em>worker-threads</em></span>).
+ Synchronization is necessary when the queue is sufficiently small that private
+ and public operations could conflict.
+ </p>
+<p>
+ The pool contains one global-queue (<code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">bounded_channel</span></code>
+ or <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">unbounded_channel</span></code>) protected by a global-lock
+ and each <span class="emphasis"><em>worker-thread</em></span> has its own private local worker-queue.
+ If work is enqueued by a <span class="emphasis"><em>worker-thread</em></span> the <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">task</span></code> is stored in the worker queue. If
+ the work is enqueued by a application thread it goes into the global queue.
+ When <span class="emphasis"><em>worker-threads</em></span> are looking for work, they have
+ following search order:
+ </p>
+<div class="itemizedlist"><ul class="itemizedlist" type="disc">
+<li class="listitem">
+ look into the private worker-queue - tasks can be dequeued without locks
+ </li>
+<li class="listitem">
+ look in the global-queue - locks are used for synchronization
+ </li>
+<li class="listitem">
+ check other worker-queues ('stealing' tasks from private worker queues
+ of other <span class="emphasis"><em>worker-threads</em></span>) - requires locks
+ </li>
+</ul></div>
+<p>
+ For a lot of recursively queued tasks (so called <span class="emphasis"><em>sub-tasks</em></span>),
+ the use of a worker-queue per thread substantially reduces the synchronization
+ necessary to complete the work. There are also fewer cache effects due to
+ sharing of the global-queue information.
+ </p>
+<p>
+ Operations on the private worker queue are executed in LIFO order and operations
+ on worker queues of other <span class="emphasis"><em>worker-threads</em></span> in FIFO order
+ (steals).
+ </p>
+<div class="itemizedlist"><ul class="itemizedlist" type="disc">
+<li class="listitem">
+ There are chances that memory is still hot in the cache, if the tasks are
+ pushed in LIFO order into the private worker queue.
+ </li>
+<li class="listitem">
+ If a <span class="emphasis"><em>worker-thread</em></span> steals work in FIFO order, increases
+ the chances that a larger 'chunk' of work will be stolen (the need for
+ other steals will be possibly reduced). Because the <span class="emphasis"><em>sub-tasks</em></span>
+ are stored in LIFO order, the oldest items are closer to the <span class="emphasis"><em>public
+ end</em></span> of the queue (forming a tree). Stealing such an older <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">task</span></code> also steals a (probably) larger
+ subtree of tasks unfolded if the stolen work item get executed. Since a
+ <span class="emphasis"><em>sub-task</em></span> is just part of a larger <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">task</span></code>,
+ we don&#8217;t need to worry about execution order.
+ </li>
+</ul></div>
+</div>
+<p>
+ / Copyright Oliver Kowalke 2009. Distributed under the Boost Software License,
+ Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
+ ]
+ </p>
+<div class="section" title="Fork/Join">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_task.pool.forkjoin"></a><a class="link" href="pool.html#boost_task.pool.forkjoin" title="Fork/Join"> Fork/Join</a>
+</h3></div></div></div>
+<p>
+ Fork/Join algorithms are recursive divide-and-conquer algorithms which repeatedly
+ splitt into sub-tasks until they become small enough to solve using simple,
+ short sequential methods, so that they run in parallel on multiple cores.
+ </p>
+<p>
+ The fork operation creates new <span class="emphasis"><em>sub-tasks</em></span> which can run
+ in parallel. The current <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">task</span></code>
+ is not proceeded in the join operation until the forked <span class="emphasis"><em>sub-tasks</em></span>
+ have completed. In the meantime the <span class="emphasis"><em>worker-thread</em></span> executes
+ other tasks from its local worker-queue.
+ </p>
+<p>
+
+</p>
+<pre class="programlisting"><span class="keyword">long</span> <span class="identifier">serial_fib</span><span class="special">(</span> <span class="keyword">long</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">2</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">serial_fib</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="identifier">serial_fib</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="keyword">long</span> <span class="identifier">parallel_fib</span><span class="special">(</span> <span class="keyword">long</span> <span class="identifier">n</span><span class="special">,</span> <span class="keyword">long</span> <span class="identifier">cutof</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">cutof</span><span class="special">)</span> <span class="keyword">return</span> <span class="identifier">serial_fib</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 sub-task calculating fibonacci(n-1)
+</span> <span class="identifier">h1</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">async</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">as_sub_task</span><span class="special">(),</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">make_task</span><span class="special">(</span>
+ <span class="identifier">parallel_fib</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="identifier">cutof</span><span class="special">)</span> <span class="special">);</span>
+ <span class="comment">// fork a sub-task calculating fibonacci(n-2)
+</span> <span class="identifier">h2</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">async</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">as_sub_task</span><span class="special">(),</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">make_task</span><span class="special">(</span>
+ <span class="identifier">parallel_fib</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="identifier">cutof</span><span class="special">)</span> <span class="special">);</span>
+ <span class="comment">// join the results of both sub-tasks
+</span> <span class="comment">// if one of the both sub-tasks is not ready
+</span> <span class="comment">// the worker-thread does not block, it executes other
+</span> <span class="comment">// task from its local-queue
+</span> <span class="keyword">return</span> <span class="identifier">h1</span><span class="special">.</span><span class="identifier">get</span><span class="special">()</span> <span class="special">+</span> <span class="identifier">h2</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">void</span> <span class="identifier">main</span><span class="special">()</span>
+<span class="special">{</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">handle</span><span class="special">&lt;</span> <span class="keyword">long</span> <span class="special">&gt;</span> <span class="identifier">h</span><span class="special">(</span> <span class="comment">// handle for fibonacci calculation
+</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">async</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">default_pool</span><span class="special">(),</span> <span class="comment">// access the default thread-pool
+</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">make_task</span><span class="special">(</span> <span class="comment">// calculate fibonacci number 10
+</span> <span class="identifier">parallel_fib</span><span class="special">,</span> <span class="comment">// for numbers &lt; 5 do inline recursive calculation
+</span> <span class="number">10</span><span class="special">,</span>
+ <span class="number">5</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">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">h</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="special">}</span>
+</pre>
+<p>
+ </p>
+</div>
+<div class="footnotes">
+<br><hr width="100" align="left">
+<div class="footnote"><p><sup>[<a name="ftn.id575100" href="#id575100" class="para">4</a>] </sup>
+ see <a href="http://www.ddj.com/go-parallel/article/showArticle.jhtml?articleID=216500409" target="_top">'Use
+ Thread Pools Correctly'</a>, Herb Sutter
+ </p></div>
+</div>
+</div>
+<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
+<td align="left"></td>
+<td align="right"><div class="copyright-footer">Copyright © 2009 Oliver Kowalke<p>
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ </p>
+</div></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="new_thread.html"><img src="../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="as_sub_task.html"><img src="../../../doc/html/images/next.png" alt="Next"></a>
+</div>
+</body>
+</html>

Added: sandbox/task/libs/task/doc/html/boost_task/reference.html
==============================================================================
--- (empty file)
+++ sandbox/task/libs/task/doc/html/boost_task/reference.html 2009-06-01 08:13:01 EDT (Mon, 01 Jun 2009)
@@ -0,0 +1,2233 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>Reference</title>
+<link rel="stylesheet" href="../boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.75.0">
+<link rel="home" href="../index.html" title="Chapter 1. Boost.Task">
+<link rel="up" href="../index.html" title="Chapter 1. Boost.Task">
+<link rel="prev" href="meta_functions.html" title="Meta functions">
+<link rel="next" href="appendices.html" title="Appendices">
+</head>
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<table cellpadding="2" width="100%"><tr>
+<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td>
+<td align="center">Home</td>
+<td align="center">Libraries</td>
+<td align="center">People</td>
+<td align="center">FAQ</td>
+<td align="center">More</td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="meta_functions.html"><img src="../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="appendices.html"><img src="../../../doc/html/images/next.png" alt="Next"></a>
+</div>
+<div class="section" title="Reference">
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="boost_task.reference"></a><a class="link" href="reference.html" title="Reference"> Reference</a>
+</h2></div></div></div>
+<div class="toc"><dl>
+<dt><span class="section"> Class template task</span></dt>
+<dt><span class="section"> Class template handle</span></dt>
+<dt><span class="section"> Function async()</span></dt>
+<dt><span class="section"> Class own_thread</span></dt>
+<dt><span class="section"> Class new_thread</span></dt>
+<dt><span class="section"> Class template static_pool</span></dt>
+<dt><span class="section"> Utilities</span></dt>
+<dt><span class="section"> Meta function has_attribute</span></dt>
+<dt><span class="section"><a href="reference.html#boost_task.reference.attribute_type"> Meta function
+ <code class="computeroutput"><span class="identifier">attribute_type</span></code></a></span></dt>
+<dt><span class="section"> Class invalid_poolsize</span></dt>
+<dt><span class="section"> Class invalid_scanns</span></dt>
+<dt><span class="section"> Class invalid_timeduration</span></dt>
+<dt><span class="section"> Class invalid_watermark</span></dt>
+<dt><span class="section"> Class task_rejected</span></dt>
+<dt><span class="section"> Class poolsize</span></dt>
+<dt><span class="section"> Class high_watermark</span></dt>
+<dt><span class="section"> Class low_watermark</span></dt>
+<dt><span class="section"> Class scanns</span></dt>
+</dl></div>
+<div class="section" title="Class template task">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_task.reference.task"></a><a class="link" href="reference.html#boost_task.reference.task" title="Class template task"> Class template <code class="computeroutput"><span class="identifier">task</span></code></a>
+</h3></div></div></div>
+<div class="toc"><dl>
+<dt><span class="section"> Constructor</span></dt>
+<dt><span class="section"><a href="reference.html#boost_task.reference.task.get_id"> Member function
+ <code class="computeroutput"><span class="identifier">get_id</span><span class="special">()</span></code></a></span></dt>
+<dt><span class="section"><a href="reference.html#boost_task.reference.task.get_future"> Member function
+ <code class="computeroutput"><span class="identifier">get_future</span><span class="special">()</span></code></a></span></dt>
+<dt><span class="section"> Member function swap()</span></dt>
+<dt><span class="section"><a href="reference.html#boost_task.reference.task.operator"> Member function
+ <code class="computeroutput"><span class="keyword">operator</span><span class="special">()()</span></code></a></span></dt>
+</dl></div>
+<p>
+
+</p>
+<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">task</span><span class="special">/</span><span class="identifier">task</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">R</span> <span class="special">&gt;</span>
+<span class="keyword">class</span> <span class="identifier">task</span>
+<span class="special">{</span>
+<span class="keyword">public</span><span class="special">:</span>
+ <span class="keyword">template</span><span class="special">&lt;</span> <span class="keyword">typename</span> <span class="identifier">Fn</span> <span class="special">&gt;</span>
+ <span class="identifier">task</span><span class="special">(</span> <span class="identifier">Fn</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">fn</span><span class="special">);</span>
+
+ <span class="keyword">const</span> <span class="identifier">id</span> <span class="identifier">get_id</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
+
+ <span class="identifier">shared_future</span><span class="special">&lt;</span> <span class="identifier">R</span> <span class="special">&gt;</span> <span class="special">&amp;</span> <span class="identifier">get_future</span><span class="special">();</span>
+
+ <span class="keyword">void</span> <span class="identifier">swap</span><span class="special">(</span> <span class="identifier">task</span><span class="special">&lt;</span> <span class="identifier">R</span> <span class="special">&gt;</span> <span class="special">&amp;</span> <span class="identifier">other</span><span class="special">)</span> <span class="comment">// throw();
+</span>
+ <span class="keyword">void</span> <span class="keyword">operator</span><span class="special">()()</span> <span class="comment">// throw();
+</span><span class="special">}</span>
+</pre>
+<p>
+ </p>
+<div class="section" title="Constructor">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_task.reference.task.constructor"></a><a class="link" href="reference.html#boost_task.reference.task.constructor" title="Constructor"> Constructor</a>
+</h4></div></div></div>
+<pre class="programlisting"><span class="keyword">template</span><span class="special">&lt;</span> <span class="keyword">typename</span> <span class="identifier">Fn</span> <span class="special">&gt;</span>
+<span class="identifier">task</span><span class="special">(</span> <span class="identifier">Fn</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">fn</span><span class="special">)</span>
+</pre>
+<div class="variablelist">
+<p class="title"><b></b></p>
+<dl>
+<dt><span class="term">Effects:</span></dt>
+<dd><p>
+ constructs a <code class="computeroutput"><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="identifier">R</span>
+ <span class="special">&gt;</span></code> from a function object
+ </p></dd>
+<dt><span class="term">Throws:</span></dt>
+<dd><p>
+ Nothing
+ </p></dd>
+</dl>
+</div>
+</div>
+<div class="section" title="Member function get_id()">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_task.reference.task.get_id"></a><a class="link" href="reference.html#boost_task.reference.task.get_id" title="Member function get_id()"> Member function
+ <code class="computeroutput"><span class="identifier">get_id</span><span class="special">()</span></code></a>
+</h4></div></div></div>
+<pre class="programlisting"><span class="keyword">const</span> <span class="identifier">id</span> <span class="identifier">get_id</span><span class="special">()</span> <span class="keyword">const</span>
+</pre>
+<div class="variablelist">
+<p class="title"><b></b></p>
+<dl>
+<dt><span class="term">Effects:</span></dt>
+<dd><p>
+ returns task identifier
+ </p></dd>
+<dt><span class="term">Throws:</span></dt>
+<dd><p>
+ Nothing
+ </p></dd>
+</dl>
+</div>
+</div>
+<div class="section" title="Member function get_future()">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_task.reference.task.get_future"></a><a class="link" href="reference.html#boost_task.reference.task.get_future" title="Member function get_future()"> Member function
+ <code class="computeroutput"><span class="identifier">get_future</span><span class="special">()</span></code></a>
+</h4></div></div></div>
+<pre class="programlisting"><span class="identifier">shared_future</span><span class="special">&lt;</span> <span class="identifier">R</span> <span class="special">&gt;</span> <span class="special">&amp;</span> <span class="identifier">get_future</span><span class="special">()</span>
+</pre>
+<div class="variablelist">
+<p class="title"><b></b></p>
+<dl>
+<dt><span class="term">Effects:</span></dt>
+<dd><p>
+ returns a future assiciated with the task
+ </p></dd>
+<dt><span class="term">Throws:</span></dt>
+<dd><p>
+ ???
+ </p></dd>
+</dl>
+</div>
+</div>
+<div class="section" title="Member function swap()">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_task.reference.task.swap"></a><a class="link" href="reference.html#boost_task.reference.task.swap" title="Member function swap()"> Member function <code class="computeroutput"><span class="identifier">swap</span><span class="special">()</span></code></a>
+</h4></div></div></div>
+<pre class="programlisting"><span class="keyword">void</span> <span class="identifier">swap</span><span class="special">(</span> <span class="identifier">task</span><span class="special">&lt;</span> <span class="identifier">R</span> <span class="special">&gt;</span> <span class="special">&amp;</span> <span class="identifier">other</span><span class="special">)</span>
+</pre>
+<div class="variablelist">
+<p class="title"><b></b></p>
+<dl>
+<dt><span class="term">Effects:</span></dt>
+<dd><p>
+ swaps the task
+ </p></dd>
+<dt><span class="term">Throws:</span></dt>
+<dd><p>
+ Nothing
+ </p></dd>
+</dl>
+</div>
+</div>
+<div class="section" title="Member function operator()()">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_task.reference.task.operator"></a><a class="link" href="reference.html#boost_task.reference.task.operator" title="Member function operator()()"> Member function
+ <code class="computeroutput"><span class="keyword">operator</span><span class="special">()()</span></code></a>
+</h4></div></div></div>
+<pre class="programlisting"><span class="keyword">void</span> <span class="keyword">operator</span><span class="special">()()</span>
+</pre>
+<div class="variablelist">
+<p class="title"><b></b></p>
+<dl>
+<dt><span class="term">Effects:</span></dt>
+<dd><p>
+ executes tasks internal function object
+ </p></dd>
+<dt><span class="term">Throws:</span></dt>
+<dd><p>
+ Nothing
+ </p></dd>
+</dl>
+</div>
+</div>
+</div>
+<div class="section" title="Class template handle">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_task.reference.handle"></a><a class="link" href="reference.html#boost_task.reference.handle" title="Class template handle"> Class template <code class="computeroutput"><span class="identifier">handle</span></code></a>
+</h3></div></div></div>
+<div class="toc"><dl>
+<dt><span class="section"> Constructor</span></dt>
+<dt><span class="section"><a href="reference.html#boost_task.reference.handle.get_id"> Member function
+ <code class="computeroutput"><span class="identifier">get_id</span><span class="special">()</span></code></a></span></dt>
+<dt><span class="section"><a href="reference.html#boost_task.reference.handle.interruption_requested">
+ Member function <code class="computeroutput"><span class="identifier">interruption_requested</span><span class="special">()</span></code></a></span></dt>
+<dt><span class="section"><a href="reference.html#boost_task.reference.handle.interrupt"> Member function
+ <code class="computeroutput"><span class="identifier">interrupt</span><span class="special">()</span></code></a></span></dt>
+<dt><span class="section"><a href="reference.html#boost_task.reference.handle.interrupt_and_wait"> Member
+ function <code class="computeroutput"><span class="identifier">interrupt_and_wait</span><span class="special">()</span></code></a></span></dt>
+<dt><span class="section"><a href="reference.html#boost_task.reference.handle.interrupt_and_wait_until">
+ Member function <code class="computeroutput"><span class="identifier">interrupt_and_wait_until</span><span class="special">()</span></code></a></span></dt>
+<dt><span class="section"><a href="reference.html#boost_task.reference.handle.interrupt_and_wait_for">
+ Member function <code class="computeroutput"><span class="identifier">interrupt_and_wait_for</span><span class="special">()</span></code></a></span></dt>
+<dt><span class="section"><a href="reference.html#boost_task.reference.handle.get"> Member function
+ <code class="computeroutput"><span class="identifier">get</span><span class="special">()</span></code></a></span></dt>
+<dt><span class="section"><a href="reference.html#boost_task.reference.handle.wait"> Member function
+ <code class="computeroutput"><span class="identifier">wait</span><span class="special">()</span></code></a></span></dt>
+<dt><span class="section"><a href="reference.html#boost_task.reference.handle.is_ready"> Member function
+ <code class="computeroutput"><span class="identifier">is_ready</span><span class="special">()</span></code></a></span></dt>
+<dt><span class="section"><a href="reference.html#boost_task.reference.handle.has_value"> Member function
+ <code class="computeroutput"><span class="identifier">has_value</span><span class="special">()</span></code></a></span></dt>
+<dt><span class="section"><a href="reference.html#boost_task.reference.handle.has_exception"> Member
+ function <code class="computeroutput"><span class="identifier">has_exception</span><span class="special">()</span></code></a></span></dt>
+<dt><span class="section"><a href="reference.html#boost_task.reference.handle.swap"> Member function
+ <code class="computeroutput"><span class="identifier">swap</span><span class="special">()</span></code></a></span></dt>
+</dl></div>
+<p>
+
+</p>
+<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">task</span><span class="special">/</span><span class="identifier">handle</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">R</span> <span class="special">&gt;</span>
+<span class="keyword">class</span> <span class="identifier">handle</span>
+<span class="special">{</span>
+ <span class="identifier">handle</span><span class="special">();</span>
+
+ <span class="keyword">const</span> <span class="identifier">id</span> <span class="identifier">get_id</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
+
+ <span class="keyword">void</span> <span class="identifier">interrupt</span><span class="special">();</span>
+
+ <span class="keyword">void</span> <span class="identifier">interrupt_and_wait</span><span class="special">();</span>
+
+ <span class="keyword">void</span> <span class="identifier">interrupt_and_wait_until</span><span class="special">(</span> <span class="identifier">system_time</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">abs_time</span><span class="special">);</span>
+
+ <span class="keyword">template</span><span class="special">&lt;</span> <span class="keyword">typename</span> <span class="identifier">Duration</span> <span class="special">&gt;</span>
+ <span class="keyword">void</span> <span class="identifier">interrupt_and_wait_for</span><span class="special">(</span> <span class="identifier">Duration</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">rel_time</span><span class="special">);</span>
+
+ <span class="keyword">bool</span> <span class="identifier">interruption_requested</span><span class="special">();</span>
+
+ <span class="identifier">R</span> <span class="identifier">get</span><span class="special">();</span>
+
+ <span class="keyword">bool</span> <span class="identifier">is_ready</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
+
+ <span class="keyword">bool</span> <span class="identifier">has_value</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
+
+ <span class="keyword">bool</span> <span class="identifier">has_exception</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
+
+ <span class="keyword">void</span> <span class="identifier">wait</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
+
+ <span class="keyword">void</span> <span class="identifier">swap</span><span class="special">(</span> <span class="identifier">handle</span><span class="special">&lt;</span> <span class="identifier">R</span> <span class="special">&gt;</span> <span class="special">&amp;</span> <span class="identifier">other</span><span class="special">);</span>
+<span class="special">};</span>
+</pre>
+<p>
+ </p>
+<div class="section" title="Constructor">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_task.reference.handle.constructor"></a><a class="link" href="reference.html#boost_task.reference.handle.constructor" title="Constructor"> Constructor</a>
+</h4></div></div></div>
+<pre class="programlisting"><span class="identifier">handle</span><span class="special">()</span>
+</pre>
+<div class="variablelist">
+<p class="title"><b></b></p>
+<dl>
+<dt><span class="term">Effects:</span></dt>
+<dd><p>
+ constructs an empty (invalid) handle
+ </p></dd>
+<dt><span class="term">Throws:</span></dt>
+<dd><p>
+ Nothing
+ </p></dd>
+</dl>
+</div>
+</div>
+<div class="section" title="Member function get_id()">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_task.reference.handle.get_id"></a><a class="link" href="reference.html#boost_task.reference.handle.get_id" title="Member function get_id()"> Member function
+ <code class="computeroutput"><span class="identifier">get_id</span><span class="special">()</span></code></a>
+</h4></div></div></div>
+<pre class="programlisting"><span class="keyword">const</span> <span class="identifier">id</span> <span class="identifier">get_id</span><span class="special">()</span> <span class="keyword">const</span>
+</pre>
+<div class="variablelist">
+<p class="title"><b></b></p>
+<dl>
+<dt><span class="term">Effects:</span></dt>
+<dd><p>
+ returns identifier of the associated task
+ </p></dd>
+<dt><span class="term">Throws:</span></dt>
+<dd><p>
+ Nothing
+ </p></dd>
+</dl>
+</div>
+</div>
+<div class="section" title="Member function interruption_requested()">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_task.reference.handle.interruption_requested"></a><a class="link" href="reference.html#boost_task.reference.handle.interruption_requested" title="Member function interruption_requested()">
+ Member function <code class="computeroutput"><span class="identifier">interruption_requested</span><span class="special">()</span></code></a>
+</h4></div></div></div>
+<pre class="programlisting"><span class="keyword">bool</span> <span class="identifier">interruption_requested</span><span class="special">()</span>
+</pre>
+<div class="variablelist">
+<p class="title"><b></b></p>
+<dl>
+<dt><span class="term">Effects:</span></dt>
+<dd><p>
+ checks if interruption is already requested
+ </p></dd>
+<dt><span class="term">Throws:</span></dt>
+<dd><p>
+ Nothing
+ </p></dd>
+</dl>
+</div>
+</div>
+<div class="section" title="Member function interrupt()">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_task.reference.handle.interrupt"></a><a class="link" href="reference.html#boost_task.reference.handle.interrupt" title="Member function interrupt()"> Member function
+ <code class="computeroutput"><span class="identifier">interrupt</span><span class="special">()</span></code></a>
+</h4></div></div></div>
+<pre class="programlisting"><span class="keyword">void</span> <span class="identifier">interrupt</span><span class="special">()</span>
+</pre>
+<div class="variablelist">
+<p class="title"><b></b></p>
+<dl>
+<dt><span class="term">Effects:</span></dt>
+<dd><p>
+ requests task interruption; doesn not block (immediatly returns)
+ </p></dd>
+<dt><span class="term">Throws:</span></dt>
+<dd><p>
+ ???
+ </p></dd>
+</dl>
+</div>
+</div>
+<div class="section" title="Member function interrupt_and_wait()">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_task.reference.handle.interrupt_and_wait"></a><a class="link" href="reference.html#boost_task.reference.handle.interrupt_and_wait" title="Member function interrupt_and_wait()"> Member
+ function <code class="computeroutput"><span class="identifier">interrupt_and_wait</span><span class="special">()</span></code></a>
+</h4></div></div></div>
+<pre class="programlisting"><span class="keyword">void</span> <span class="identifier">interrupt_and_wait</span><span class="special">()</span>
+</pre>
+<div class="variablelist">
+<p class="title"><b></b></p>
+<dl>
+<dt><span class="term">Effects:</span></dt>
+<dd><p>
+ requests task interruption and blocks until worker-thread stops task
+ </p></dd>
+<dt><span class="term">Throws:</span></dt>
+<dd><p>
+ ???
+ </p></dd>
+</dl>
+</div>
+</div>
+<div class="section" title="Member function interrupt_and_wait_until()">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_task.reference.handle.interrupt_and_wait_until"></a><a class="link" href="reference.html#boost_task.reference.handle.interrupt_and_wait_until" title="Member function interrupt_and_wait_until()">
+ Member function <code class="computeroutput"><span class="identifier">interrupt_and_wait_until</span><span class="special">()</span></code></a>
+</h4></div></div></div>
+<pre class="programlisting"><span class="keyword">void</span> <span class="identifier">interrupt_and_wait_until</span><span class="special">(</span> <span class="identifier">system_time</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">abs_time</span><span class="special">)</span>
+</pre>
+<div class="variablelist">
+<p class="title"><b></b></p>
+<dl>
+<dt><span class="term">Effects:</span></dt>
+<dd><p>
+ requests task interruption and blocks until worker-thread stops task
+ or time-point elapsed
+ </p></dd>
+<dt><span class="term">Throws:</span></dt>
+<dd><p>
+ ???
+ </p></dd>
+</dl>
+</div>
+</div>
+<div class="section" title="Member function interrupt_and_wait_for()">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_task.reference.handle.interrupt_and_wait_for"></a><a class="link" href="reference.html#boost_task.reference.handle.interrupt_and_wait_for" title="Member function interrupt_and_wait_for()">
+ Member function <code class="computeroutput"><span class="identifier">interrupt_and_wait_for</span><span class="special">()</span></code></a>
+</h4></div></div></div>
+<pre class="programlisting"><span class="keyword">template</span><span class="special">&lt;</span> <span class="keyword">typename</span> <span class="identifier">Duration</span> <span class="special">&gt;</span>
+<span class="keyword">void</span> <span class="identifier">interrupt_and_wait_for</span><span class="special">(</span> <span class="identifier">Duration</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">rel_time</span><span class="special">)</span>
+</pre>
+<div class="variablelist">
+<p class="title"><b></b></p>
+<dl>
+<dt><span class="term">Effects:</span></dt>
+<dd><p>
+ requests task interruption and blocks until worker-thread stops task
+ or time-duration elapsed
+ </p></dd>
+<dt><span class="term">Throws:</span></dt>
+<dd><p>
+ ???
+ </p></dd>
+</dl>
+</div>
+</div>
+<div class="section" title="Member function get()">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_task.reference.handle.get"></a><a class="link" href="reference.html#boost_task.reference.handle.get" title="Member function get()"> Member function
+ <code class="computeroutput"><span class="identifier">get</span><span class="special">()</span></code></a>
+</h4></div></div></div>
+<pre class="programlisting"><span class="identifier">R</span> <span class="identifier">get</span><span class="special">()</span>
+</pre>
+<div class="variablelist">
+<p class="title"><b></b></p>
+<dl>
+<dt><span class="term">Effects:</span></dt>
+<dd><p>
+ requests the result
+ </p></dd>
+<dt><span class="term">Throws:</span></dt>
+<dd><p>
+ task_interrupted, task_uninialized
+ </p></dd>
+</dl>
+</div>
+</div>
+<div class="section" title="Member function wait()">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_task.reference.handle.wait"></a><a class="link" href="reference.html#boost_task.reference.handle.wait" title="Member function wait()"> Member function
+ <code class="computeroutput"><span class="identifier">wait</span><span class="special">()</span></code></a>
+</h4></div></div></div>
+<pre class="programlisting"><span class="keyword">void</span> <span class="identifier">wait</span><span class="special">()</span>
+</pre>
+<div class="variablelist">
+<p class="title"><b></b></p>
+<dl>
+<dt><span class="term">Effects:</span></dt>
+<dd><p>
+ blocks caller until task is done
+ </p></dd>
+<dt><span class="term">Throws:</span></dt>
+<dd><p>
+ task_interrupted, task_uninialized
+ </p></dd>
+</dl>
+</div>
+</div>
+<div class="section" title="Member function is_ready()">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_task.reference.handle.is_ready"></a><a class="link" href="reference.html#boost_task.reference.handle.is_ready" title="Member function is_ready()"> Member function
+ <code class="computeroutput"><span class="identifier">is_ready</span><span class="special">()</span></code></a>
+</h4></div></div></div>
+<pre class="programlisting"><span class="keyword">bool</span> <span class="identifier">is_ready</span><span class="special">()</span>
+</pre>
+<div class="variablelist">
+<p class="title"><b></b></p>
+<dl>
+<dt><span class="term">Effects:</span></dt>
+<dd><p>
+ checks if task is done
+ </p></dd>
+<dt><span class="term">Throws:</span></dt>
+<dd><p>
+ Nothing
+ </p></dd>
+</dl>
+</div>
+</div>
+<div class="section" title="Member function has_value()">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_task.reference.handle.has_value"></a><a class="link" href="reference.html#boost_task.reference.handle.has_value" title="Member function has_value()"> Member function
+ <code class="computeroutput"><span class="identifier">has_value</span><span class="special">()</span></code></a>
+</h4></div></div></div>
+<pre class="programlisting"><span class="keyword">bool</span> <span class="identifier">has_value</span><span class="special">()</span>
+</pre>
+<div class="variablelist">
+<p class="title"><b></b></p>
+<dl>
+<dt><span class="term">Effects:</span></dt>
+<dd><p>
+ checks if task is done and a result value is set
+ </p></dd>
+<dt><span class="term">Throws:</span></dt>
+<dd><p>
+ Nothing
+ </p></dd>
+</dl>
+</div>
+</div>
+<div class="section" title="Member function has_exception()">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_task.reference.handle.has_exception"></a><a class="link" href="reference.html#boost_task.reference.handle.has_exception" title="Member function has_exception()"> Member
+ function <code class="computeroutput"><span class="identifier">has_exception</span><span class="special">()</span></code></a>
+</h4></div></div></div>
+<pre class="programlisting"><span class="keyword">bool</span> <span class="identifier">has_exception</span><span class="special">()</span>
+</pre>
+<div class="variablelist">
+<p class="title"><b></b></p>
+<dl>
+<dt><span class="term">Effects:</span></dt>
+<dd><p>
+ checks if task is done and an exception is set
+ </p></dd>
+<dt><span class="term">Throws:</span></dt>
+<dd><p>
+ Nothing
+ </p></dd>
+</dl>
+</div>
+</div>
+<div class="section" title="Member function swap()">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_task.reference.handle.swap"></a><a class="link" href="reference.html#boost_task.reference.handle.swap" title="Member function swap()"> Member function
+ <code class="computeroutput"><span class="identifier">swap</span><span class="special">()</span></code></a>
+</h4></div></div></div>
+<pre class="programlisting"><span class="keyword">void</span> <span class="identifier">swap</span><span class="special">(</span> <span class="identifier">handle</span><span class="special">&lt;</span> <span class="identifier">R</span> <span class="special">&gt;</span> <span class="special">&amp;</span> <span class="identifier">other</span><span class="special">)</span>
+</pre>
+<div class="variablelist">
+<p class="title"><b></b></p>
+<dl>
+<dt><span class="term">Effects:</span></dt>
+<dd><p>
+ swapps handle
+ </p></dd>
+<dt><span class="term">Throws:</span></dt>
+<dd><p>
+ Nothing
+ </p></dd>
+</dl>
+</div>
+</div>
+</div>
+<div class="section" title="Function async()">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_task.reference.async"></a><a class="link" href="reference.html#boost_task.reference.async" title="Function async()"> Function <code class="computeroutput"><span class="identifier">async</span><span class="special">()</span></code></a>
+</h3></div></div></div>
+<div class="toc"><dl>
+<dt><span class="section"><a href="reference.html#boost_task.reference.async.async_default"> Templated
+ non-member function <code class="computeroutput"><span class="identifier">async</span><span class="special">(</span> <span class="identifier">AE</span><span class="special">,</span>
+ <span class="identifier">task</span><span class="special">&lt;</span>
+ <span class="identifier">R</span> <span class="special">&gt;)</span></code></a></span></dt>
+<dt><span class="section"><a href="reference.html#boost_task.reference.async.async_pool"> Templated non-member
+ function <code class="computeroutput"><span class="identifier">async</span><span class="special">(</span>
+ <span class="identifier">pool</span><span class="special">&lt;</span>
+ <span class="identifier">Channel</span> <span class="special">&gt;</span>
+ <span class="special">&amp;,</span> <span class="identifier">task</span><span class="special">&lt;</span> <span class="identifier">R</span> <span class="special">&gt;)</span></code></a></span></dt>
+<dt><span class="section"><a href="reference.html#boost_task.reference.async.async_pool_attr"> Templated
+ non-member function <code class="computeroutput"><span class="identifier">async</span><span class="special">(</span> <span class="identifier">pool</span><span class="special">&lt;</span> <span class="identifier">Channel</span>
+ <span class="special">&gt;</span> <span class="special">&amp;,</span>
+ <span class="identifier">task</span><span class="special">&lt;</span>
+ <span class="identifier">R</span> <span class="special">&gt;,</span>
+ <span class="identifier">Attr</span><span class="special">)</span></code></a></span></dt>
+</dl></div>
+<div class="section" title="Templated non-member function async( AE, task&lt; R &gt;)">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_task.reference.async.async_default"></a><a class="link" href="reference.html#boost_task.reference.async.async_default" title="Templated non-member function async( AE, task&lt; R &gt;)"> Templated
+ non-member function <code class="computeroutput"><span class="identifier">async</span><span class="special">(</span> <span class="identifier">AE</span><span class="special">,</span>
+ <span class="identifier">task</span><span class="special">&lt;</span>
+ <span class="identifier">R</span> <span class="special">&gt;)</span></code></a>
+</h4></div></div></div>
+<p>
+
+</p>
+<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">task</span><span class="special">/</span><span class="identifier">async</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">AE</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">R</span> <span class="special">&gt;</span>
+<span class="identifier">handle</span><span class="special">&lt;</span> <span class="identifier">R</span> <span class="special">&gt;</span> <span class="identifier">async</span><span class="special">(</span> <span class="identifier">AE</span> <span class="identifier">ae</span><span class="special">,</span> <span class="identifier">task</span><span class="special">&lt;</span> <span class="identifier">R</span> <span class="special">&gt;</span> <span class="identifier">t</span><span class="special">);</span>
+</pre>
+<p>
+ </p>
+<div class="variablelist">
+<p class="title"><b></b></p>
+<dl>
+<dt><span class="term">Effects:</span></dt>
+<dd><p>
+ executes task in an asyncrounous executer and returns a handle associated
+ with the task
+ </p></dd>
+<dt><span class="term">Throws:</span></dt>
+<dd><p>
+ Nothing
+ </p></dd>
+</dl>
+</div>
+</div>
+<div class="section" title="Templated non-member function async( pool&lt; Channel &gt; &amp;, task&lt; R &gt;)">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_task.reference.async.async_pool"></a><a class="link" href="reference.html#boost_task.reference.async.async_pool" title="Templated non-member function async( pool&lt; Channel &gt; &amp;, task&lt; R &gt;)"> Templated non-member
+ function <code class="computeroutput"><span class="identifier">async</span><span class="special">(</span>
+ <span class="identifier">pool</span><span class="special">&lt;</span>
+ <span class="identifier">Channel</span> <span class="special">&gt;</span>
+ <span class="special">&amp;,</span> <span class="identifier">task</span><span class="special">&lt;</span> <span class="identifier">R</span> <span class="special">&gt;)</span></code></a>
+</h4></div></div></div>
+<p>
+
+</p>
+<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">task</span><span class="special">/</span><span class="identifier">async</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">R</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">Channel</span> <span class="special">&gt;</span>
+<span class="identifier">handle</span><span class="special">&lt;</span> <span class="identifier">R</span> <span class="special">&gt;</span> <span class="identifier">async</span><span class="special">(</span> <span class="identifier">pool</span><span class="special">&lt;</span> <span class="identifier">Channel</span> <span class="special">&gt;</span> <span class="special">&amp;</span> <span class="identifier">ae</span><span class="special">,</span> <span class="identifier">task</span><span class="special">&lt;</span> <span class="identifier">R</span> <span class="special">&gt;</span> <span class="identifier">t</span><span class="special">);</span>
+</pre>
+<p>
+ </p>
+<div class="variablelist">
+<p class="title"><b></b></p>
+<dl>
+<dt><span class="term">Effects:</span></dt>
+<dd><p>
+ executes task in a thread-pool and returns a handle associated with
+ the task
+ </p></dd>
+<dt><span class="term">Throws:</span></dt>
+<dd><p>
+ Nothing
+ </p></dd>
+</dl>
+</div>
+</div>
+<div class="section" title="Templated non-member function async( pool&lt; Channel &gt; &amp;, task&lt; R &gt;, Attr)">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_task.reference.async.async_pool_attr"></a><a class="link" href="reference.html#boost_task.reference.async.async_pool_attr" title="Templated non-member function async( pool&lt; Channel &gt; &amp;, task&lt; R &gt;, Attr)"> Templated
+ non-member function <code class="computeroutput"><span class="identifier">async</span><span class="special">(</span> <span class="identifier">pool</span><span class="special">&lt;</span> <span class="identifier">Channel</span>
+ <span class="special">&gt;</span> <span class="special">&amp;,</span>
+ <span class="identifier">task</span><span class="special">&lt;</span>
+ <span class="identifier">R</span> <span class="special">&gt;,</span>
+ <span class="identifier">Attr</span><span class="special">)</span></code></a>
+</h4></div></div></div>
+<p>
+
+</p>
+<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">task</span><span class="special">/</span><span class="identifier">async</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">R</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">Channel</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">Attr</span> <span class="special">&gt;</span>
+<span class="identifier">handle</span><span class="special">&lt;</span> <span class="identifier">R</span> <span class="special">&gt;</span> <span class="identifier">async</span><span class="special">(</span> <span class="identifier">pool</span><span class="special">&lt;</span> <span class="identifier">Channel</span> <span class="special">&gt;</span> <span class="special">&amp;</span> <span class="identifier">ae</span><span class="special">,</span> <span class="identifier">task</span><span class="special">&lt;</span> <span class="identifier">R</span> <span class="special">&gt;</span> <span class="identifier">t</span><span class="special">,</span> <span class="identifier">Attr</span> <span class="identifier">attr</span><span class="special">);</span>
+</pre>
+<p>
+ </p>
+<div class="variablelist">
+<p class="title"><b></b></p>
+<dl>
+<dt><span class="term">Effects:</span></dt>
+<dd><p>
+ executes atrributed task in a thread-pool and returns a handle associated
+ with the task
+ </p></dd>
+<dt><span class="term">Throws:</span></dt>
+<dd><p>
+ Nothing
+ </p></dd>
+</dl>
+</div>
+</div>
+</div>
+<div class="section" title="Class own_thread">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_task.reference.own_thread"></a><a class="link" href="reference.html#boost_task.reference.own_thread" title="Class own_thread"> Class <code class="computeroutput"><span class="identifier">own_thread</span></code></a>
+</h3></div></div></div>
+<div class="toc"><dl><dt><span class="section"><a href="reference.html#boost_task.reference.own_thread.operator"> Member function
+ <code class="computeroutput"><span class="keyword">operator</span><span class="special">()(</span>
+ <span class="identifier">task</span><span class="special">&lt;</span>
+ <span class="identifier">R</span> <span class="special">&gt;</span>
+ <span class="identifier">t</span><span class="special">)</span></code></a></span></dt></dl></div>
+<p>
+
+</p>
+<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">task</span><span class="special">/</span><span class="identifier">async</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
+
+<span class="keyword">struct</span> <span class="identifier">own_thread</span>
+<span class="special">{</span>
+ <span class="keyword">template</span><span class="special">&lt;</span> <span class="keyword">typename</span> <span class="identifier">R</span> <span class="special">&gt;</span>
+ <span class="identifier">handle</span><span class="special">&lt;</span> <span class="identifier">R</span> <span class="special">&gt;</span> <span class="keyword">operator</span><span class="special">()(</span> <span class="identifier">task</span><span class="special">&lt;</span> <span class="identifier">R</span> <span class="special">&gt;</span> <span class="identifier">t</span><span class="special">);</span>
+<span class="special">};</span>
+</pre>
+<p>
+ </p>
+<div class="section" title="Member function operator()( task&lt; R &gt; t)">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_task.reference.own_thread.operator"></a><a class="link" href="reference.html#boost_task.reference.own_thread.operator" title="Member function operator()( task&lt; R &gt; t)"> Member function
+ <code class="computeroutput"><span class="keyword">operator</span><span class="special">()(</span>
+ <span class="identifier">task</span><span class="special">&lt;</span>
+ <span class="identifier">R</span> <span class="special">&gt;</span>
+ <span class="identifier">t</span><span class="special">)</span></code></a>
+</h4></div></div></div>
+<pre class="programlisting"><span class="keyword">template</span><span class="special">&lt;</span> <span class="keyword">typename</span> <span class="identifier">R</span> <span class="special">&gt;</span>
+<span class="identifier">handle</span><span class="special">&lt;</span> <span class="identifier">R</span> <span class="special">&gt;</span> <span class="keyword">operator</span><span class="special">()(</span> <span class="identifier">task</span><span class="special">&lt;</span> <span class="identifier">R</span> <span class="special">&gt;</span> <span class="identifier">t</span><span class="special">)</span>
+</pre>
+<div class="variablelist">
+<p class="title"><b></b></p>
+<dl>
+<dt><span class="term">Effects:</span></dt>
+<dd><p>
+ executes task in the current thread an returns an handle associated
+ with the task
+ </p></dd>
+<dt><span class="term">Throws:</span></dt>
+<dd><p>
+ Nothing
+ </p></dd>
+</dl>
+</div>
+</div>
+</div>
+<div class="section" title="Class new_thread">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_task.reference.new_thread"></a><a class="link" href="reference.html#boost_task.reference.new_thread" title="Class new_thread"> Class <code class="computeroutput"><span class="identifier">new_thread</span></code></a>
+</h3></div></div></div>
+<div class="toc"><dl><dt><span class="section"><a href="reference.html#boost_task.reference.new_thread.operator"> Member function
+ <code class="computeroutput"><span class="keyword">operator</span><span class="special">()(</span>
+ <span class="identifier">task</span><span class="special">&lt;</span>
+ <span class="identifier">R</span> <span class="special">&gt;</span>
+ <span class="identifier">t</span><span class="special">)</span></code></a></span></dt></dl></div>
+<p>
+
+</p>
+<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">task</span><span class="special">/</span><span class="identifier">async</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
+
+<span class="keyword">struct</span> <span class="identifier">new_thread</span>
+<span class="special">{</span>
+ <span class="keyword">template</span><span class="special">&lt;</span> <span class="keyword">typename</span> <span class="identifier">R</span> <span class="special">&gt;</span>
+ <span class="identifier">handle</span><span class="special">&lt;</span> <span class="identifier">R</span> <span class="special">&gt;</span> <span class="keyword">operator</span><span class="special">()(</span> <span class="identifier">task</span><span class="special">&lt;</span> <span class="identifier">R</span> <span class="special">&gt;</span> <span class="identifier">t</span><span class="special">);</span>
+<span class="special">};</span>
+</pre>
+<p>
+ </p>
+<div class="section" title="Member function operator()( task&lt; R &gt; t)">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_task.reference.new_thread.operator"></a><a class="link" href="reference.html#boost_task.reference.new_thread.operator" title="Member function operator()( task&lt; R &gt; t)"> Member function
+ <code class="computeroutput"><span class="keyword">operator</span><span class="special">()(</span>
+ <span class="identifier">task</span><span class="special">&lt;</span>
+ <span class="identifier">R</span> <span class="special">&gt;</span>
+ <span class="identifier">t</span><span class="special">)</span></code></a>
+</h4></div></div></div>
+<pre class="programlisting"><span class="keyword">template</span><span class="special">&lt;</span> <span class="keyword">typename</span> <span class="identifier">R</span> <span class="special">&gt;</span>
+<span class="identifier">handle</span><span class="special">&lt;</span> <span class="identifier">R</span> <span class="special">&gt;</span> <span class="keyword">operator</span><span class="special">()(</span> <span class="identifier">task</span><span class="special">&lt;</span> <span class="identifier">R</span> <span class="special">&gt;</span> <span class="identifier">t</span><span class="special">)</span>
+</pre>
+<div class="variablelist">
+<p class="title"><b></b></p>
+<dl>
+<dt><span class="term">Effects:</span></dt>
+<dd><p>
+ executes task in a new thread an returns an handle associated with
+ the task
+ </p></dd>
+<dt><span class="term">Throws:</span></dt>
+<dd><p>
+ Nothing
+ </p></dd>
+</dl>
+</div>
+</div>
+</div>
+<div class="section" title="Class template static_pool">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_task.reference.static_pool"></a><a class="link" href="reference.html#boost_task.reference.static_pool" title="Class template static_pool"> Class template <code class="computeroutput"><span class="identifier">static_pool</span></code></a>
+</h3></div></div></div>
+<div class="toc"><dl>
+<dt><span class="section"><a href="reference.html#boost_task.reference.static_pool.constructor_unbounded_channel_hw">
+ Constructor (unbounded channel)</a></span></dt>
+<dt><span class="section"><a href="reference.html#boost_task.reference.static_pool.constructor_unbounded_channel">
+ Constructor (unbounded channel)</a></span></dt>
+<dt><span class="section"><a href="reference.html#boost_task.reference.static_pool.constructor_bounded_channel_hw">
+ Constructor (bounded channel)</a></span></dt>
+<dt><span class="section"><a href="reference.html#boost_task.reference.static_pool.constructor_bounded_channel">
+ Constructor (bounded channel)</a></span></dt>
+<dt><span class="section"> Destructor</span></dt>
+<dt><span class="section"><a href="reference.html#boost_task.reference.static_pool.size"> Member function
+ <code class="computeroutput"><span class="identifier">size</span><span class="special">()</span></code></a></span></dt>
+<dt><span class="section"><a href="reference.html#boost_task.reference.static_pool.active"> Member function
+ <code class="computeroutput"><span class="identifier">active</span><span class="special">()</span></code></a></span></dt>
+<dt><span class="section"><a href="reference.html#boost_task.reference.static_pool.idle"> Member function
+ <code class="computeroutput"><span class="identifier">idle</span><span class="special">()</span></code></a></span></dt>
+<dt><span class="section"><a href="reference.html#boost_task.reference.static_pool.shutdown"> Member
+ function <code class="computeroutput"><span class="identifier">shutdown</span><span class="special">()</span></code></a></span></dt>
+<dt><span class="section"><a href="reference.html#boost_task.reference.static_pool.shutdown_now"> Member
+ function <code class="computeroutput"><span class="identifier">shutdown_now</span><span class="special">()</span></code></a></span></dt>
+<dt><span class="section"><a href="reference.html#boost_task.reference.static_pool.losed"> Member function
+ <code class="computeroutput"><span class="identifier">closed</span><span class="special">()</span></code></a></span></dt>
+<dt><span class="section"><a href="reference.html#boost_task.reference.static_pool.clear"> Member function
+ <code class="computeroutput"><span class="identifier">clear</span><span class="special">()</span></code></a></span></dt>
+<dt><span class="section"><a href="reference.html#boost_task.reference.static_pool.empty"> Member function
+ <code class="computeroutput"><span class="identifier">empty</span><span class="special">()</span></code></a></span></dt>
+<dt><span class="section"><a href="reference.html#boost_task.reference.static_pool.pending"> Member function
+ <code class="computeroutput"><span class="identifier">pending</span><span class="special">()</span></code></a></span></dt>
+<dt><span class="section"><a href="reference.html#boost_task.reference.static_pool.get_upper_bound">
+ Member function <code class="computeroutput"><span class="identifier">upper_bound</span><span class="special">()</span></code></a></span></dt>
+<dt><span class="section"><a href="reference.html#boost_task.reference.static_pool.set_upper_bound">
+ Member function <code class="computeroutput"><span class="identifier">upper_bound</span><span class="special">(</span> <span class="identifier">high_watermark</span>
+ <span class="keyword">const</span><span class="special">&amp;</span>
+ <span class="identifier">hwm</span><span class="special">)</span></code></a></span></dt>
+<dt><span class="section"><a href="reference.html#boost_task.reference.static_pool.get_lower_bound">
+ Member function <code class="computeroutput"><span class="identifier">lower_bound</span><span class="special">()</span></code></a></span></dt>
+<dt><span class="section"><a href="reference.html#boost_task.reference.static_pool.set_lower_bound">
+ Member function <code class="computeroutput"><span class="identifier">lower_bound</span><span class="special">(</span> <span class="identifier">low_watermark</span>
+ <span class="keyword">const</span><span class="special">&amp;</span>
+ <span class="identifier">lwm</span><span class="special">)</span></code></a></span></dt>
+<dt><span class="section"><a href="reference.html#boost_task.reference.static_pool.submit"> Member function
+ <code class="computeroutput"><span class="identifier">submit</span><span class="special">(</span>
+ <span class="identifier">Act</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">act</span><span class="special">)</span></code></a></span></dt>
+<dt><span class="section"><a href="reference.html#boost_task.reference.static_pool.submit_attr"> Member
+ function <code class="computeroutput"><span class="identifier">submit</span><span class="special">(</span>
+ <span class="identifier">Act</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">act</span><span class="special">,</span> <span class="identifier">Attr</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">attr</span><span class="special">)</span></code></a></span></dt>
+</dl></div>
+<p>
+
+</p>
+<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">task</span><span class="special">/</span><span class="identifier">static_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">Channel</span> <span class="special">&gt;</span>
+<span class="keyword">class</span> <span class="identifier">static_pool</span> <span class="special">:</span> <span class="keyword">private</span> <span class="identifier">noncopyable</span>
+<span class="special">{</span>
+<span class="keyword">public</span><span class="special">:</span>
+ <span class="keyword">explicit</span> <span class="identifier">pool</span><span class="special">(</span>
+ <span class="identifier">poolsize</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">psize</span><span class="special">,</span>
+ <span class="identifier">posix_time</span><span class="special">::</span><span class="identifier">time_duration</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">asleep</span> <span class="special">=</span> <span class="identifier">posix_time</span><span class="special">::</span><span class="identifier">microseconds</span><span class="special">(</span> <span class="number">10</span><span class="special">),</span>
+ <span class="identifier">scanns</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">scns</span> <span class="special">=</span> <span class="identifier">scanns</span><span class="special">(</span> <span class="number">20</span><span class="special">)</span> <span class="special">);</span>
+
+ <span class="keyword">explicit</span> <span class="identifier">pool</span><span class="special">(</span>
+ <span class="identifier">poolsize</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">psize</span><span class="special">,</span>
+ <span class="identifier">high_watermark</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">hwm</span><span class="special">,</span>
+ <span class="identifier">low_watermark</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">lwm</span><span class="special">,</span>
+ <span class="identifier">posix_time</span><span class="special">::</span><span class="identifier">time_duration</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">asleep</span> <span class="special">=</span> <span class="identifier">posix_time</span><span class="special">::</span><span class="identifier">milliseconds</span><span class="special">(</span> <span class="number">100</span><span class="special">),</span>
+ <span class="identifier">scanns</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">scns</span> <span class="special">=</span> <span class="identifier">scanns</span><span class="special">(</span> <span class="number">20</span><span class="special">)</span> <span class="special">);</span>
+
+
+ <span class="keyword">explicit</span> <span class="identifier">pool</span><span class="special">(</span>
+ <span class="identifier">posix_time</span><span class="special">::</span><span class="identifier">time_duration</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">asleep</span> <span class="special">=</span> <span class="identifier">posix_time</span><span class="special">::</span><span class="identifier">microseconds</span><span class="special">(</span> <span class="number">10</span><span class="special">),</span>
+ <span class="identifier">scanns</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">scns</span> <span class="special">=</span> <span class="identifier">scanns</span><span class="special">(</span> <span class="number">20</span><span class="special">)</span> <span class="special">);</span>
+
+ <span class="keyword">explicit</span> <span class="identifier">pool</span><span class="special">(</span>
+ <span class="identifier">high_watermark</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">hwm</span><span class="special">,</span>
+ <span class="identifier">low_watermark</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">lwm</span><span class="special">,</span>
+ <span class="identifier">posix_time</span><span class="special">::</span><span class="identifier">time_duration</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">asleep</span> <span class="special">=</span> <span class="identifier">posix_time</span><span class="special">::</span><span class="identifier">milliseconds</span><span class="special">(</span> <span class="number">100</span><span class="special">),</span>
+ <span class="identifier">scanns</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">scns</span> <span class="special">=</span> <span class="identifier">scanns</span><span class="special">(</span> <span class="number">20</span><span class="special">)</span> <span class="special">);</span>
+
+ <span class="special">~</span><span class="identifier">static_pool</span><span class="special">();</span>
+
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">size</span><span class="special">();</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">active</span><span class="special">();</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">idle</span><span class="special">();</span>
+
+ <span class="keyword">void</span> <span class="identifier">shutdown</span><span class="special">();</span>
+ <span class="keyword">void</span> <span class="identifier">shutdown_now</span><span class="special">();</span>
+
+ <span class="keyword">bool</span> <span class="identifier">closed</span><span class="special">();</span>
+ <span class="keyword">void</span> <span class="identifier">clear</span><span class="special">();</span>
+ <span class="keyword">bool</span> <span class="identifier">empty</span><span class="special">();</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">pending</span><span class="special">();</span>
+
+ <span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">upper_bound</span><span class="special">();</span>
+ <span class="keyword">void</span> <span class="identifier">upper_bound</span><span class="special">(</span> <span class="identifier">high_watermark</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">hwm</span><span class="special">);</span>
+ <span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">lower_bound</span><span class="special">();</span>
+ <span class="keyword">void</span> <span class="identifier">lower_bound</span><span class="special">(</span> <span class="identifier">low_watermark</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">lwm</span><span class="special">);</span>
+
+ <span class="keyword">template</span><span class="special">&lt;</span> <span class="keyword">typename</span> <span class="identifier">R</span> <span class="special">&gt;</span>
+ <span class="identifier">handle</span><span class="special">&lt;</span> <span class="identifier">R</span> <span class="special">&gt;</span> <span class="identifier">submit</span><span class="special">(</span> <span class="identifier">task</span><span class="special">&lt;</span> <span class="identifier">R</span> <span class="special">&gt;</span> <span class="identifier">t</span><span class="special">);</span>
+
+ <span class="keyword">template</span><span class="special">&lt;</span> <span class="keyword">typename</span> <span class="identifier">R</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">Attr</span> <span class="special">&gt;</span>
+ <span class="identifier">handle</span><span class="special">&lt;</span> <span class="identifier">R</span> <span class="special">&gt;</span> <span class="identifier">submit</span><span class="special">(</span> <span class="identifier">task</span><span class="special">&lt;</span> <span class="identifier">R</span> <span class="special">&gt;</span> <span class="identifier">t</span><span class="special">,</span> <span class="identifier">Attr</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">attr</span><span class="special">);</span>
+<span class="special">};</span>
+</pre>
+<p>
+ </p>
+<div class="section" title="Constructor (unbounded channel)">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_task.reference.static_pool.constructor_unbounded_channel_hw"></a><a class="link" href="reference.html#boost_task.reference.static_pool.constructor_unbounded_channel_hw" title="Constructor (unbounded channel)">
+ Constructor (unbounded channel)</a>
+</h4></div></div></div>
+<pre class="programlisting"><span class="keyword">explicit</span> <span class="identifier">static_pool</span><span class="special">(</span>
+ <span class="identifier">posix_time</span><span class="special">::</span><span class="identifier">time_duration</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">asleep</span> <span class="special">=</span> <span class="identifier">posix_time</span><span class="special">::</span><span class="identifier">microseconds</span><span class="special">(</span> <span class="number">10</span><span class="special">),</span>
+ <span class="identifier">scanns</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">scns</span> <span class="special">=</span> <span class="identifier">scanns</span><span class="special">(</span> <span class="number">20</span><span class="special">)</span> <span class="special">)</span>
+</pre>
+<div class="variablelist">
+<p class="title"><b></b></p>
+<dl>
+<dt><span class="term">Preconditions:</span></dt>
+<dd><p>
+ operating system provides functionality for processor pining
+ </p></dd>
+<dt><span class="term">Effects:</span></dt>
+<dd><p>
+ constructs a pool - for each processor a worker-thread is created and
+ bound to one processor - global-queue can queue an unlimited number
+ of tasks
+ </p></dd>
+<dt><span class="term">Throws:</span></dt>
+<dd><p>
+ <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">invalid_scanns</span></code>, <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">invalid_timeduration</span></code>
+ </p></dd>
+<dt><span class="term">Notes:</span></dt>
+<dd><p>
+ constructor has to be called if a unbounded-channel is used
+ </p></dd>
+</dl>
+</div>
+</div>
+<div class="section" title="Constructor (unbounded channel)">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_task.reference.static_pool.constructor_unbounded_channel"></a><a class="link" href="reference.html#boost_task.reference.static_pool.constructor_unbounded_channel" title="Constructor (unbounded channel)">
+ Constructor (unbounded channel)</a>
+</h4></div></div></div>
+<pre class="programlisting"><span class="keyword">explicit</span> <span class="identifier">static_pool</span><span class="special">(</span>
+ <span class="identifier">poolsize</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">psize</span><span class="special">,</span>
+ <span class="identifier">posix_time</span><span class="special">::</span><span class="identifier">time_duration</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">asleep</span> <span class="special">=</span> <span class="identifier">posix_time</span><span class="special">::</span><span class="identifier">microseconds</span><span class="special">(</span> <span class="number">10</span><span class="special">),</span>
+ <span class="identifier">scanns</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">scns</span> <span class="special">=</span> <span class="identifier">scanns</span><span class="special">(</span> <span class="number">20</span><span class="special">)</span> <span class="special">)</span>
+</pre>
+<div class="variablelist">
+<p class="title"><b></b></p>
+<dl>
+<dt><span class="term">Effects:</span></dt>
+<dd><p>
+ constructs a pool containing psize worker-threads - global-queue can
+ queue an unlimited number of tasks
+ </p></dd>
+<dt><span class="term">Throws:</span></dt>
+<dd><p>
+ <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">invalid_scanns</span></code>, <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">invalid_timeduration</span></code>
+ </p></dd>
+<dt><span class="term">Notes:</span></dt>
+<dd><p>
+ constructor has to be called if a unbounded-channel is used
+ </p></dd>
+</dl>
+</div>
+</div>
+<div class="section" title="Constructor (bounded channel)">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_task.reference.static_pool.constructor_bounded_channel_hw"></a><a class="link" href="reference.html#boost_task.reference.static_pool.constructor_bounded_channel_hw" title="Constructor (bounded channel)">
+ Constructor (bounded channel)</a>
+</h4></div></div></div>
+<pre class="programlisting"><span class="keyword">explicit</span> <span class="identifier">static_pool</span><span class="special">(</span>
+ <span class="identifier">high_watermark</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">hwm</span><span class="special">,</span>
+ <span class="identifier">low_watermark</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">lwm</span><span class="special">,</span>
+ <span class="identifier">posix_time</span><span class="special">::</span><span class="identifier">time_duration</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">asleep</span> <span class="special">=</span> <span class="identifier">posix_time</span><span class="special">::</span><span class="identifier">milliseconds</span><span class="special">(</span> <span class="number">100</span><span class="special">),</span>
+ <span class="identifier">scanns</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">scns</span> <span class="special">=</span> <span class="identifier">scanns</span><span class="special">(</span> <span class="number">20</span><span class="special">)</span> <span class="special">)</span>
+</pre>
+<div class="variablelist">
+<p class="title"><b></b></p>
+<dl>
+<dt><span class="term">Preconditions:</span></dt>
+<dd><p>
+ operating system provides functionality for processor pining
+ </p></dd>
+<dt><span class="term">Effects:</span></dt>
+<dd><p>
+ constructs a pool - for each processor a worker-thread is created and
+ bound to one processor - global-queue can only queue a limited number
+ of tasks
+ </p></dd>
+<dt><span class="term">Throws:</span></dt>
+<dd><p>
+ <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">invalid_scanns</span></code>, <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">invalid_timeduration</span></code>,
+ <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">invalid_watermark</span></code>
+ </p></dd>
+<dt><span class="term">Notes:</span></dt>
+<dd><p>
+ Constructor has to be called if a bounded-channel is used.
+ </p></dd>
+</dl>
+</div>
+</div>
+<div class="section" title="Constructor (bounded channel)">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_task.reference.static_pool.constructor_bounded_channel"></a><a class="link" href="reference.html#boost_task.reference.static_pool.constructor_bounded_channel" title="Constructor (bounded channel)">
+ Constructor (bounded channel)</a>
+</h4></div></div></div>
+<pre class="programlisting"><span class="keyword">explicit</span> <span class="identifier">static_pool</span><span class="special">(</span>
+ <span class="identifier">poolsize</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">psize</span><span class="special">,</span>
+ <span class="identifier">high_watermark</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">hwm</span><span class="special">,</span>
+ <span class="identifier">low_watermark</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">lwm</span><span class="special">,</span>
+ <span class="identifier">posix_time</span><span class="special">::</span><span class="identifier">time_duration</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">asleep</span> <span class="special">=</span> <span class="identifier">posix_time</span><span class="special">::</span><span class="identifier">milliseconds</span><span class="special">(</span> <span class="number">100</span><span class="special">),</span>
+ <span class="identifier">scanns</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">scns</span> <span class="special">=</span> <span class="identifier">scanns</span><span class="special">(</span> <span class="number">20</span><span class="special">)</span> <span class="special">)</span>
+</pre>
+<div class="variablelist">
+<p class="title"><b></b></p>
+<dl>
+<dt><span class="term">Effects:</span></dt>
+<dd><p>
+ constructs a pool containing psize worker-threads - global-queue can
+ only queue a limited number of tasks
+ </p></dd>
+<dt><span class="term">Throws:</span></dt>
+<dd><p>
+ <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">invalid_scanns</span></code>, <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">invalid_timeduration</span></code>,
+ <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">invalid_watermark</span></code>
+ </p></dd>
+<dt><span class="term">Notes:</span></dt>
+<dd><p>
+ constructor has to be called if a bounded-channel is used
+ </p></dd>
+</dl>
+</div>
+</div>
+<div class="section" title="Destructor">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_task.reference.static_pool.destructor"></a><a class="link" href="reference.html#boost_task.reference.static_pool.destructor" title="Destructor"> Destructor</a>
+</h4></div></div></div>
+<pre class="programlisting"><span class="special">~</span><span class="identifier">static_pool</span><span class="special">()</span>
+</pre>
+<div class="variablelist">
+<p class="title"><b></b></p>
+<dl>
+<dt><span class="term">Effects:</span></dt>
+<dd><p>
+ calls <code class="computeroutput"><span class="special">:</span><span class="identifier">shutdown</span><span class="special">()</span></code> if not already called
+ </p></dd>
+<dt><span class="term">Throws:</span></dt>
+<dd><p>
+ Nothing
+ </p></dd>
+</dl>
+</div>
+</div>
+<div class="section" title="Member function size()">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_task.reference.static_pool.size"></a><a class="link" href="reference.html#boost_task.reference.static_pool.size" title="Member function size()"> Member function
+ <code class="computeroutput"><span class="identifier">size</span><span class="special">()</span></code></a>
+</h4></div></div></div>
+<pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">size</span><span class="special">()</span>
+</pre>
+<div class="variablelist">
+<p class="title"><b></b></p>
+<dl>
+<dt><span class="term">Effects:</span></dt>
+<dd><p>
+ returns how many worker-threads are running in the pool
+ </p></dd>
+<dt><span class="term">Throws:</span></dt>
+<dd><p>
+ Nothing
+ </p></dd>
+</dl>
+</div>
+</div>
+<div class="section" title="Member function active()">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_task.reference.static_pool.active"></a><a class="link" href="reference.html#boost_task.reference.static_pool.active" title="Member function active()"> Member function
+ <code class="computeroutput"><span class="identifier">active</span><span class="special">()</span></code></a>
+</h4></div></div></div>
+<pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">active</span><span class="special">()</span>
+</pre>
+<div class="variablelist">
+<p class="title"><b></b></p>
+<dl>
+<dt><span class="term">Effects:</span></dt>
+<dd><p>
+ returns how many worker-threads are active (executing an task)
+ </p></dd>
+<dt><span class="term">Throws:</span></dt>
+<dd><p>
+ Nothing
+ </p></dd>
+</dl>
+</div>
+</div>
+<div class="section" title="Member function idle()">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_task.reference.static_pool.idle"></a><a class="link" href="reference.html#boost_task.reference.static_pool.idle" title="Member function idle()"> Member function
+ <code class="computeroutput"><span class="identifier">idle</span><span class="special">()</span></code></a>
+</h4></div></div></div>
+<pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">idle</span><span class="special">()</span>
+</pre>
+<div class="variablelist">
+<p class="title"><b></b></p>
+<dl>
+<dt><span class="term">Effects:</span></dt>
+<dd><p>
+ returns how many worker-threads are idle (not executing an task).
+ </p></dd>
+<dt><span class="term">Throws:</span></dt>
+<dd><p>
+ Nothing
+ </p></dd>
+<dt><span class="term">Notes:</span></dt>
+<dd><p>
+ The value is the difference of <code class="computeroutput"><span class="identifier">size</span><span class="special">()</span></code> and <code class="computeroutput"><span class="identifier">active</span><span class="special">()</span></code>
+ </p></dd>
+</dl>
+</div>
+</div>
+<div class="section" title="Member function shutdown()">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_task.reference.static_pool.shutdown"></a><a class="link" href="reference.html#boost_task.reference.static_pool.shutdown" title="Member function shutdown()"> Member
+ function <code class="computeroutput"><span class="identifier">shutdown</span><span class="special">()</span></code></a>
+</h4></div></div></div>
+<pre class="programlisting"><span class="keyword">void</span> <span class="identifier">shutdown</span><span class="special">()</span>
+</pre>
+<div class="variablelist">
+<p class="title"><b></b></p>
+<dl>
+<dt><span class="term">Effects:</span></dt>
+<dd><p>
+ deactivates the channel and joins all worker-threads - the pool is
+ closed
+ </p></dd>
+<dt><span class="term">Throws:</span></dt>
+<dd><p>
+ Nothing
+ </p></dd>
+<dt><span class="term">Notes:</span></dt>
+<dd><p>
+ all pending tasks are processed
+ </p></dd>
+</dl>
+</div>
+</div>
+<div class="section" title="Member function shutdown_now()">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_task.reference.static_pool.shutdown_now"></a><a class="link" href="reference.html#boost_task.reference.static_pool.shutdown_now" title="Member function shutdown_now()"> Member
+ function <code class="computeroutput"><span class="identifier">shutdown_now</span><span class="special">()</span></code></a>
+</h4></div></div></div>
+<pre class="programlisting"><span class="keyword">void</span> <span class="identifier">shutdown_now</span><span class="special">()</span>
+</pre>
+<div class="variablelist">
+<p class="title"><b></b></p>
+<dl>
+<dt><span class="term">Effects:</span></dt>
+<dd><p>
+ deactivates the channel, send interruption request to all worker-threads
+ and joins them - the pool is closed
+ </p></dd>
+<dt><span class="term">Throws:</span></dt>
+<dd><p>
+ Nothing
+ </p></dd>
+<dt><span class="term">Notes:</span></dt>
+<dd><p>
+ pending tasks are not processed but returned
+ </p></dd>
+</dl>
+</div>
+</div>
+<div class="section" title="Member function closed()">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_task.reference.static_pool.losed"></a><a class="link" href="reference.html#boost_task.reference.static_pool.losed" title="Member function closed()"> Member function
+ <code class="computeroutput"><span class="identifier">closed</span><span class="special">()</span></code></a>
+</h4></div></div></div>
+<pre class="programlisting"><span class="keyword">bool</span> <span class="identifier">closed</span><span class="special">()</span>
+</pre>
+<div class="variablelist">
+<p class="title"><b></b></p>
+<dl>
+<dt><span class="term">Effects:</span></dt>
+<dd><p>
+ queries if the pool is closed (pool is shutdown)
+ </p></dd>
+<dt><span class="term">Throws:</span></dt>
+<dd><p>
+ Nothing
+ </p></dd>
+</dl>
+</div>
+</div>
+<div class="section" title="Member function clear()">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_task.reference.static_pool.clear"></a><a class="link" href="reference.html#boost_task.reference.static_pool.clear" title="Member function clear()"> Member function
+ <code class="computeroutput"><span class="identifier">clear</span><span class="special">()</span></code></a>
+</h4></div></div></div>
+<pre class="programlisting"><span class="keyword">void</span> <span class="identifier">clear</span><span class="special">()</span>
+</pre>
+<div class="variablelist">
+<p class="title"><b></b></p>
+<dl>
+<dt><span class="term">Effects:</span></dt>
+<dd><p>
+ removes all pending tasks from the channel
+ </p></dd>
+<dt><span class="term">Throws:</span></dt>
+<dd><p>
+ Nothing
+ </p></dd>
+</dl>
+</div>
+</div>
+<div class="section" title="Member function empty()">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_task.reference.static_pool.empty"></a><a class="link" href="reference.html#boost_task.reference.static_pool.empty" title="Member function empty()"> Member function
+ <code class="computeroutput"><span class="identifier">empty</span><span class="special">()</span></code></a>
+</h4></div></div></div>
+<pre class="programlisting"><span class="keyword">bool</span> <span class="identifier">empty</span><span class="special">()</span>
+</pre>
+<div class="variablelist">
+<p class="title"><b></b></p>
+<dl>
+<dt><span class="term">Effects:</span></dt>
+<dd><p>
+ queries if the channel is empty
+ </p></dd>
+<dt><span class="term">Throws:</span></dt>
+<dd><p>
+ Nothing
+ </p></dd>
+</dl>
+</div>
+</div>
+<div class="section" title="Member function pending()">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_task.reference.static_pool.pending"></a><a class="link" href="reference.html#boost_task.reference.static_pool.pending" title="Member function pending()"> Member function
+ <code class="computeroutput"><span class="identifier">pending</span><span class="special">()</span></code></a>
+</h4></div></div></div>
+<pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">pending</span><span class="special">()</span>
+</pre>
+<div class="variablelist">
+<p class="title"><b></b></p>
+<dl>
+<dt><span class="term">Effects:</span></dt>
+<dd><p>
+ queries how many tasks are pending (still unprocessed) in the global-queue
+ (channel)
+ </p></dd>
+<dt><span class="term">Throws:</span></dt>
+<dd><p>
+ Nothing
+ </p></dd>
+</dl>
+</div>
+</div>
+<div class="section" title="Member function upper_bound()">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_task.reference.static_pool.get_upper_bound"></a><a class="link" href="reference.html#boost_task.reference.static_pool.get_upper_bound" title="Member function upper_bound()">
+ Member function <code class="computeroutput"><span class="identifier">upper_bound</span><span class="special">()</span></code></a>
+</h4></div></div></div>
+<pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">upper_bound</span><span class="special">()</span>
+</pre>
+<div class="variablelist">
+<p class="title"><b></b></p>
+<dl>
+<dt><span class="term">Preconditions:</span></dt>
+<dd><p>
+ channel is of type bounded-channel
+ </p></dd>
+<dt><span class="term">Effects:</span></dt>
+<dd><p>
+ returns the upper bound of the bounded-channel
+ </p></dd>
+<dt><span class="term">Throws:</span></dt>
+<dd><p>
+ Nothing
+ </p></dd>
+<dt><span class="term">Notes:</span></dt>
+<dd><p>
+ can only be used if a bounded-channel is used
+ </p></dd>
+</dl>
+</div>
+</div>
+<div class="section" title="Member function upper_bound( high_watermark const&amp; hwm)">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_task.reference.static_pool.set_upper_bound"></a><a class="link" href="reference.html#boost_task.reference.static_pool.set_upper_bound" title="Member function upper_bound( high_watermark const&amp; hwm)">
+ Member function <code class="computeroutput"><span class="identifier">upper_bound</span><span class="special">(</span> <span class="identifier">high_watermark</span>
+ <span class="keyword">const</span><span class="special">&amp;</span>
+ <span class="identifier">hwm</span><span class="special">)</span></code></a>
+</h4></div></div></div>
+<pre class="programlisting"><span class="keyword">void</span> <span class="identifier">upper_bound</span><span class="special">(</span> <span class="identifier">high_watermark</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">hwm</span><span class="special">)</span>
+</pre>
+<div class="variablelist">
+<p class="title"><b></b></p>
+<dl>
+<dt><span class="term">Preconditions:</span></dt>
+<dd><p>
+ channel is of type bounded-channel
+ </p></dd>
+<dt><span class="term">Effects:</span></dt>
+<dd><p>
+ sets the upper bound of the bounded-channel
+ </p></dd>
+<dt><span class="term">Postconditions:</span></dt>
+<dd><p>
+ <code class="computeroutput"><span class="keyword">this</span><span class="special">-&gt;</span><span class="identifier">upper_bound</span><span class="special">()</span>
+ <span class="special">==</span> <span class="identifier">hwm</span></code>
+ </p></dd>
+<dt><span class="term">Throws:</span></dt>
+<dd><p>
+ <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">invalid_watermark</span></code>
+ </p></dd>
+<dt><span class="term">Notes:</span></dt>
+<dd><p>
+ can only be used if a bounded-channel is used
+ </p></dd>
+</dl>
+</div>
+</div>
+<div class="section" title="Member function lower_bound()">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_task.reference.static_pool.get_lower_bound"></a><a class="link" href="reference.html#boost_task.reference.static_pool.get_lower_bound" title="Member function lower_bound()">
+ Member function <code class="computeroutput"><span class="identifier">lower_bound</span><span class="special">()</span></code></a>
+</h4></div></div></div>
+<pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">lower_bound</span><span class="special">();</span>
+</pre>
+<div class="variablelist">
+<p class="title"><b></b></p>
+<dl>
+<dt><span class="term">Preconditions:</span></dt>
+<dd><p>
+ channel is of type bounded-channel
+ </p></dd>
+<dt><span class="term">Effects:</span></dt>
+<dd><p>
+ returns the lower bound of the bounded-channel
+ </p></dd>
+<dt><span class="term">Throws:</span></dt>
+<dd><p>
+ Nothing
+ </p></dd>
+<dt><span class="term">Notes:</span></dt>
+<dd><p>
+ can only be used if a bounded-channel is used
+ </p></dd>
+</dl>
+</div>
+</div>
+<div class="section" title="Member function lower_bound( low_watermark const&amp; lwm)">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_task.reference.static_pool.set_lower_bound"></a><a class="link" href="reference.html#boost_task.reference.static_pool.set_lower_bound" title="Member function lower_bound( low_watermark const&amp; lwm)">
+ Member function <code class="computeroutput"><span class="identifier">lower_bound</span><span class="special">(</span> <span class="identifier">low_watermark</span>
+ <span class="keyword">const</span><span class="special">&amp;</span>
+ <span class="identifier">lwm</span><span class="special">)</span></code></a>
+</h4></div></div></div>
+<pre class="programlisting"><span class="keyword">void</span> <span class="identifier">lower_bound</span><span class="special">(</span> <span class="identifier">low_watermark</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">lwm</span><span class="special">)</span>
+</pre>
+<div class="variablelist">
+<p class="title"><b></b></p>
+<dl>
+<dt><span class="term">Preconditions:</span></dt>
+<dd><p>
+ channel is of type bounded-channel
+ </p></dd>
+<dt><span class="term">Effects:</span></dt>
+<dd><p>
+ sets the lower bound of the bounded-channel
+ </p></dd>
+<dt><span class="term">Postconditions:</span></dt>
+<dd><p>
+ <code class="computeroutput"><span class="keyword">this</span><span class="special">-&gt;</span><span class="identifier">lower_bound</span><span class="special">()</span>
+ <span class="special">==</span> <span class="identifier">lwm</span></code>
+ </p></dd>
+<dt><span class="term">Throws:</span></dt>
+<dd><p>
+ <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">invalid_watermark</span></code>
+ </p></dd>
+<dt><span class="term">Notes:</span></dt>
+<dd><p>
+ can only be used if a bounded-channel is used
+ </p></dd>
+</dl>
+</div>
+</div>
+<div class="section" title="Member function submit( Act const&amp; act)">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_task.reference.static_pool.submit"></a><a class="link" href="reference.html#boost_task.reference.static_pool.submit" title="Member function submit( Act const&amp; act)"> Member function
+ <code class="computeroutput"><span class="identifier">submit</span><span class="special">(</span>
+ <span class="identifier">Act</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">act</span><span class="special">)</span></code></a>
+</h4></div></div></div>
+<pre class="programlisting"><span class="keyword">template</span><span class="special">&lt;</span> <span class="keyword">typename</span> <span class="identifier">R</span> <span class="special">&gt;</span>
+<span class="identifier">handle</span><span class="special">&lt;</span> <span class="identifier">R</span> <span class="special">&gt;</span> <span class="identifier">submit</span><span class="special">(</span> <span class="identifier">task</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> <span class="identifier">t</span><span class="special">)</span>
+</pre>
+<div class="variablelist">
+<p class="title"><b></b></p>
+<dl>
+<dt><span class="term">Preconditions:</span></dt>
+<dd><p>
+ has_attribute&lt; pool &gt;::value == false &amp;&amp; ! closed()
+ </p></dd>
+<dt><span class="term">Effects:</span></dt>
+<dd><p>
+ submits an task to the pool and returns an associated handle
+ </p></dd>
+<dt><span class="term">Throws:</span></dt>
+<dd><p>
+ <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">task_rejected</span></code>
+ </p></dd>
+</dl>
+</div>
+</div>
+<div class="section" title="Member function submit( Act const&amp; act, Attr const&amp; attr)">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_task.reference.static_pool.submit_attr"></a><a class="link" href="reference.html#boost_task.reference.static_pool.submit_attr" title="Member function submit( Act const&amp; act, Attr const&amp; attr)"> Member
+ function <code class="computeroutput"><span class="identifier">submit</span><span class="special">(</span>
+ <span class="identifier">Act</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">act</span><span class="special">,</span> <span class="identifier">Attr</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">attr</span><span class="special">)</span></code></a>
+</h4></div></div></div>
+<pre class="programlisting"><span class="keyword">template</span><span class="special">&lt;</span> <span class="keyword">typename</span> <span class="identifier">R</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">Attr</span> <span class="special">&gt;</span>
+<span class="identifier">handle</span><span class="special">&lt;</span> <span class="identifier">R</span> <span class="special">&gt;</span> <span class="identifier">submit</span><span class="special">(</span> <span class="identifier">task</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> <span class="identifier">t</span><span class="special">,</span> <span class="identifier">Attr</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">attr</span><span class="special">)</span>
+</pre>
+<div class="variablelist">
+<p class="title"><b></b></p>
+<dl>
+<dt><span class="term">Preconditions:</span></dt>
+<dd><p>
+ has_attribute&lt; pool &gt;::value == true &amp;&amp; ! closed()
+ </p></dd>
+<dt><span class="term">Effects:</span></dt>
+<dd><p>
+ submits an task to the pool and returns an associated handle - task
+ is scheduled by the attribute
+ </p></dd>
+<dt><span class="term">Throws:</span></dt>
+<dd><p>
+ <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">task_rejected</span></code>
+ </p></dd>
+</dl>
+</div>
+</div>
+</div>
+<div class="section" title="Utilities">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_task.reference.utility"></a><a class="link" href="reference.html#boost_task.reference.utility" title="Utilities"> Utilities</a>
+</h3></div></div></div>
+<div class="toc"><dl>
+<dt><span class="section"><a href="reference.html#boost_task.reference.utility.reschedule_until"> Non-member
+ function <code class="computeroutput"><span class="identifier">reschedule_until</span><span class="special">()</span></code></a></span></dt>
+<dt><span class="section"><a href="reference.html#boost_task.reference.utility.get_pool"> Non-member
+ function <code class="computeroutput"><span class="identifier">get_pool</span><span class="special">()</span></code></a></span></dt>
+<dt><span class="section"><a href="reference.html#boost_task.reference.utility.runs_in_pool"> Non-member
+ function <code class="computeroutput"><span class="identifier">runs_in_pool</span><span class="special">()</span></code></a></span></dt>
+<dt><span class="section"><a href="reference.html#boost_task.reference.utility.worker_id"> Non-member
+ function <code class="computeroutput"><span class="identifier">worker_id</span><span class="special">()</span></code></a></span></dt>
+<dt><span class="section"><a href="reference.html#boost_task.reference.utility.delay"> Non-member function
+ <code class="computeroutput"><span class="identifier">delay</span><span class="special">()</span></code></a></span></dt>
+<dt><span class="section"><a href="reference.html#boost_task.reference.utility.yield"> Non-member function
+ <code class="computeroutput"><span class="identifier">yield</span><span class="special">()</span></code></a></span></dt>
+<dt><span class="section"><a href="reference.html#boost_task.reference.utility.interrupt"> Non-member
+ function <code class="computeroutput"><span class="identifier">interrupt</span><span class="special">()</span></code></a></span></dt>
+</dl></div>
+<div class="section" title="Non-member function reschedule_until()">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_task.reference.utility.reschedule_until"></a><a class="link" href="reference.html#boost_task.reference.utility.reschedule_until" title="Non-member function reschedule_until()"> Non-member
+ function <code class="computeroutput"><span class="identifier">reschedule_until</span><span class="special">()</span></code></a>
+</h4></div></div></div>
+<p>
+
+</p>
+<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">task</span><span class="special">/</span><span class="identifier">utility</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">Pred</span> <span class="special">&gt;</span>
+<span class="keyword">void</span> <span class="identifier">reschedule_until</span><span class="special">(</span> <span class="identifier">Pred</span> <span class="keyword">const</span><span class="special">&amp;)</span>
+</pre>
+<p>
+ </p>
+<div class="variablelist">
+<p class="title"><b></b></p>
+<dl>
+<dt><span class="term">Effects:</span></dt>
+<dd>
+<p>
+ reschedules current task until passed callable predicate 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" title="Non-member function get_pool()">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_task.reference.utility.get_pool"></a><a class="link" href="reference.html#boost_task.reference.utility.get_pool" title="Non-member function get_pool()"> Non-member
+ function <code class="computeroutput"><span class="identifier">get_pool</span><span class="special">()</span></code></a>
+</h4></div></div></div>
+<p>
+
+</p>
+<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">task</span><span class="special">/</span><span class="identifier">utility</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">&gt;</span>
+<span class="identifier">Pool</span> <span class="special">&amp;</span> <span class="identifier">get_pool</span><span class="special">()</span>
+</pre>
+<p>
+ </p>
+<div class="variablelist">
+<p class="title"><b></b></p>
+<dl>
+<dt><span class="term">Effects:</span></dt>
+<dd>
+<p>
+ returns reference to the thread-pool where the current worker thread
+ is executed
+ </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" title="Non-member function runs_in_pool()">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_task.reference.utility.runs_in_pool"></a><a class="link" href="reference.html#boost_task.reference.utility.runs_in_pool" title="Non-member function runs_in_pool()"> Non-member
+ function <code class="computeroutput"><span class="identifier">runs_in_pool</span><span class="special">()</span></code></a>
+</h4></div></div></div>
+<p>
+
+</p>
+<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">task</span><span class="special">/</span><span class="identifier">utility</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
+
+<span class="keyword">bool</span> <span class="identifier">runs_in_pool</span><span class="special">()</span>
+</pre>
+<p>
+ </p>
+<div class="variablelist">
+<p class="title"><b></b></p>
+<dl>
+<dt><span class="term">Effects:</span></dt>
+<dd>
+<p>
+ returns true if the current task is executed in a thread-pool
+ </p>
+<p>
+ [Throws:
+ </p>
+<p>
+ Nothing.
+ </p>
+</dd>
+<dt><span class="term">Note:</span></dt>
+<dd><p>
+ This function resides in namespace <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">this_task</span></code>.
+ </p></dd>
+</dl>
+</div>
+</div>
+<div class="section" title="Non-member function worker_id()">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_task.reference.utility.worker_id"></a><a class="link" href="reference.html#boost_task.reference.utility.worker_id" title="Non-member function worker_id()"> Non-member
+ function <code class="computeroutput"><span class="identifier">worker_id</span><span class="special">()</span></code></a>
+</h4></div></div></div>
+<p>
+
+</p>
+<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">task</span><span class="special">/</span><span class="identifier">utility</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
+
+<span class="identifier">id</span> <span class="identifier">worker_id</span><span class="special">()</span>
+</pre>
+<p>
+ </p>
+<div class="variablelist">
+<p class="title"><b></b></p>
+<dl>
+<dt><span class="term">Effects:</span></dt>
+<dd>
+<p>
+ returns returns the thread-id of the worker-thread
+ </p>
+<p>
+ [Throws:
+ </p>
+<p>
+ Nothing.
+ </p>
+</dd>
+<dt><span class="term">Note:</span></dt>
+<dd><p>
+ This function resides in namespace <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">this_task</span></code>.
+ </p></dd>
+</dl>
+</div>
+</div>
+<div class="section" title="Non-member function delay()">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_task.reference.utility.delay"></a><a class="link" href="reference.html#boost_task.reference.utility.delay" title="Non-member function delay()"> Non-member function
+ <code class="computeroutput"><span class="identifier">delay</span><span class="special">()</span></code></a>
+</h4></div></div></div>
+<p>
+
+</p>
+<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">task</span><span class="special">/</span><span class="identifier">utility</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
+
+<span class="keyword">void</span> <span class="identifier">delay</span><span class="special">(</span> <span class="identifier">system_time</span> <span class="identifier">abs_time</span><span class="special">)</span>
+
+<span class="keyword">template</span><span class="special">&lt;</span> <span class="keyword">typename</span> <span class="identifier">Duration</span> <span class="special">&gt;</span>
+<span class="keyword">void</span> <span class="identifier">delay</span><span class="special">(</span> <span class="identifier">Duration</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">rel_time</span><span class="special">)</span>
+</pre>
+<p>
+ </p>
+<div class="variablelist">
+<p class="title"><b></b></p>
+<dl>
+<dt><span class="term">Effects:</span></dt>
+<dd>
+<p>
+ delays the execution of the current task so that the worker-thread
+ can process another task in the meantime
+ </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" title="Non-member function yield()">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_task.reference.utility.yield"></a><a class="link" href="reference.html#boost_task.reference.utility.yield" title="Non-member function yield()"> Non-member function
+ <code class="computeroutput"><span class="identifier">yield</span><span class="special">()</span></code></a>
+</h4></div></div></div>
+<p>
+
+</p>
+<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">task</span><span class="special">/</span><span class="identifier">utility</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
+
+<span class="keyword">void</span> <span class="identifier">yield</span><span class="special">()</span>
+</pre>
+<p>
+ </p>
+<div class="variablelist">
+<p class="title"><b></b></p>
+<dl>
+<dt><span class="term">Effects:</span></dt>
+<dd>
+<p>
+ yields the current task so that the worker-threadcan process another
+ task in the meantime
+ </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" title="Non-member function interrupt()">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_task.reference.utility.interrupt"></a><a class="link" href="reference.html#boost_task.reference.utility.interrupt" title="Non-member function interrupt()"> Non-member
+ function <code class="computeroutput"><span class="identifier">interrupt</span><span class="special">()</span></code></a>
+</h4></div></div></div>
+<p>
+
+</p>
+<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">task</span><span class="special">/</span><span class="identifier">utility</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
+
+<span class="keyword">void</span> <span class="identifier">interrupt</span><span class="special">()</span>
+</pre>
+<p>
+ </p>
+<div class="variablelist">
+<p class="title"><b></b></p>
+<dl>
+<dt><span class="term">Effects:</span></dt>
+<dd>
+<p>
+ task can request interruption for itself
+ </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>
+<div class="section" title="Meta function has_attribute">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_task.reference.has_attribute"></a><a class="link" href="reference.html#boost_task.reference.has_attribute" title="Meta function has_attribute"> Meta function <code class="computeroutput"><span class="identifier">has_attribute</span></code></a>
+</h3></div></div></div>
+<p>
+
+</p>
+<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">task</span><span class="special">/</span><span class="identifier">meta</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">&gt;</span>
+<span class="keyword">struct</span> <span class="identifier">has_attribute</span> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">mpl</span><span class="special">::</span><span class="identifier">bool_</span><span class="special">&lt;</span>
+ <span class="identifier">is_same</span><span class="special">&lt;</span>
+ <span class="identifier">detail</span><span class="special">::</span><span class="identifier">has_priority</span><span class="special">,</span>
+ <span class="keyword">typename</span> <span class="identifier">Pool</span><span class="special">::</span><span class="identifier">scheduler_type</span><span class="special">::</span><span class="identifier">priority_tag_type</span>
+ <span class="special">&gt;::</span><span class="identifier">value</span>
+<span class="special">&gt;</span>
+<span class="special">{};</span>
+</pre>
+<p>
+ </p>
+</div>
+<div class="section" title="Meta function attribute_type">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_task.reference.attribute_type"></a><a class="link" href="reference.html#boost_task.reference.attribute_type" title="Meta function attribute_type"> Meta function
+ <code class="computeroutput"><span class="identifier">attribute_type</span></code></a>
+</h3></div></div></div>
+<p>
+
+</p>
+<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">task</span><span class="special">/</span><span class="identifier">meta</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">&gt;</span>
+<span class="keyword">struct</span> <span class="identifier">attribute_type</span>
+<span class="special">{</span>
+ <span class="keyword">typedef</span> <span class="keyword">typename</span> <span class="identifier">Pool</span><span class="special">::</span><span class="identifier">scheduler_type</span><span class="special">::</span><span class="identifier">attribute_type</span> <span class="identifier">type</span><span class="special">;</span>
+<span class="special">};</span>
+</pre>
+<p>
+ </p>
+</div>
+<div class="section" title="Class invalid_poolsize">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_task.reference.invalid_poolsize"></a><a class="link" href="reference.html#boost_task.reference.invalid_poolsize" title="Class invalid_poolsize"> Class <code class="computeroutput"><span class="identifier">invalid_poolsize</span></code></a>
+</h3></div></div></div>
+<div class="toc"><dl><dt><span class="section"><a href="reference.html#boost_task.reference.invalid_poolsize.constructor">
+ Constructor</a></span></dt></dl></div>
+<p>
+
+</p>
+<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">task</span><span class="special">/</span><span class="identifier">exceptions</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
+
+<span class="keyword">class</span> <span class="identifier">invalid_poolsize</span> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">invalid_argument</span>
+<span class="special">{</span>
+<span class="keyword">public</span><span class="special">:</span>
+ <span class="identifier">invalid_poolsize</span><span class="special">(</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">msg</span><span class="special">);</span>
+<span class="special">};</span>
+</pre>
+<p>
+ </p>
+<div class="section" title="Constructor">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_task.reference.invalid_poolsize.constructor"></a><a class="link" href="reference.html#boost_task.reference.invalid_poolsize.constructor" title="Constructor">
+ Constructor</a>
+</h4></div></div></div>
+<pre class="programlisting"><span class="identifier">invalid_poolsize</span><span class="special">(</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">msg</span><span class="special">);</span>
+</pre>
+<div class="variablelist">
+<p class="title"><b></b></p>
+<dl>
+<dt><span class="term">Effects:</span></dt>
+<dd><p>
+ Constructs a <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">invalid_poolsize</span></code>
+ instance.
+ </p></dd>
+<dt><span class="term">Throws:</span></dt>
+<dd><p>
+ Nothing
+ </p></dd>
+</dl>
+</div>
+</div>
+</div>
+<div class="section" title="Class invalid_scanns">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_task.reference.invalid_scanns"></a><a class="link" href="reference.html#boost_task.reference.invalid_scanns" title="Class invalid_scanns"> Class <code class="computeroutput"><span class="identifier">invalid_scanns</span></code></a>
+</h3></div></div></div>
+<div class="toc"><dl><dt><span class="section"> Constructor</span></dt></dl></div>
+<p>
+
+</p>
+<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">task</span><span class="special">/</span><span class="identifier">exceptions</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
+
+<span class="keyword">class</span> <span class="identifier">invalid_scanns</span> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">invalid_argument</span>
+<span class="special">{</span>
+<span class="keyword">public</span><span class="special">:</span>
+ <span class="identifier">invalid_scanns</span><span class="special">(</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">msg</span><span class="special">);</span>
+<span class="special">};</span>
+</pre>
+<p>
+ </p>
+<div class="section" title="Constructor">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_task.reference.invalid_scanns.constructor"></a><a class="link" href="reference.html#boost_task.reference.invalid_scanns.constructor" title="Constructor"> Constructor</a>
+</h4></div></div></div>
+<pre class="programlisting"><span class="identifier">invalid_scanns</span><span class="special">(</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">msg</span><span class="special">)</span>
+</pre>
+<div class="variablelist">
+<p class="title"><b></b></p>
+<dl>
+<dt><span class="term">Effects:</span></dt>
+<dd><p>
+ Constructs a <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">invalid_scanns</span></code>
+ instance.
+ </p></dd>
+<dt><span class="term">Throws:</span></dt>
+<dd><p>
+ Nothing
+ </p></dd>
+</dl>
+</div>
+</div>
+</div>
+<div class="section" title="Class invalid_timeduration">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_task.reference.invalid_timeduration"></a><a class="link" href="reference.html#boost_task.reference.invalid_timeduration" title="Class invalid_timeduration"> Class <code class="computeroutput"><span class="identifier">invalid_timeduration</span></code></a>
+</h3></div></div></div>
+<div class="toc"><dl><dt><span class="section"><a href="reference.html#boost_task.reference.invalid_timeduration.constructor">
+ Constructor</a></span></dt></dl></div>
+<p>
+
+</p>
+<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">task</span><span class="special">/</span><span class="identifier">exceptions</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
+
+<span class="keyword">class</span> <span class="identifier">invalid_timeduration</span> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">invalid_argument</span>
+<span class="special">{</span>
+<span class="keyword">public</span><span class="special">:</span>
+ <span class="identifier">invalid_timeduration</span><span class="special">(</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">msg</span><span class="special">);</span>
+<span class="special">};</span>
+</pre>
+<p>
+ </p>
+<div class="section" title="Constructor">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_task.reference.invalid_timeduration.constructor"></a><a class="link" href="reference.html#boost_task.reference.invalid_timeduration.constructor" title="Constructor">
+ Constructor</a>
+</h4></div></div></div>
+<pre class="programlisting"><span class="identifier">invalid_timeduration</span><span class="special">(</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">msg</span><span class="special">)</span>
+</pre>
+<div class="variablelist">
+<p class="title"><b></b></p>
+<dl>
+<dt><span class="term">Effects:</span></dt>
+<dd><p>
+ Constructs a <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">invalid_timeduration</span></code>
+ instance.
+ </p></dd>
+<dt><span class="term">Throws:</span></dt>
+<dd><p>
+ Nothing
+ </p></dd>
+</dl>
+</div>
+</div>
+</div>
+<div class="section" title="Class invalid_watermark">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_task.reference.invalid_watermark"></a><a class="link" href="reference.html#boost_task.reference.invalid_watermark" title="Class invalid_watermark"> Class <code class="computeroutput"><span class="identifier">invalid_watermark</span></code></a>
+</h3></div></div></div>
+<div class="toc"><dl><dt><span class="section"><a href="reference.html#boost_task.reference.invalid_watermark.constructor">
+ Constructor</a></span></dt></dl></div>
+<p>
+
+</p>
+<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">task</span><span class="special">/</span><span class="identifier">exceptions</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
+
+<span class="keyword">class</span> <span class="identifier">invalid_watermark</span> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">invalid_argument</span>
+<span class="special">{</span>
+<span class="keyword">public</span><span class="special">:</span>
+ <span class="identifier">invalid_watermark</span><span class="special">(</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">msg</span><span class="special">);</span>
+<span class="special">};</span>
+</pre>
+<p>
+ </p>
+<div class="section" title="Constructor">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_task.reference.invalid_watermark.constructor"></a><a class="link" href="reference.html#boost_task.reference.invalid_watermark.constructor" title="Constructor">
+ Constructor</a>
+</h4></div></div></div>
+<pre class="programlisting"><span class="identifier">invalid_watermark</span><span class="special">(</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">msg</span><span class="special">)</span>
+</pre>
+<div class="variablelist">
+<p class="title"><b></b></p>
+<dl>
+<dt><span class="term">Effects:</span></dt>
+<dd><p>
+ Constructs a <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">invalid_watermark</span></code>
+ instance.
+ </p></dd>
+<dt><span class="term">Throws:</span></dt>
+<dd><p>
+ Nothing
+ </p></dd>
+</dl>
+</div>
+</div>
+</div>
+<div class="section" title="Class task_rejected">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_task.reference.task_rejected"></a><a class="link" href="reference.html#boost_task.reference.task_rejected" title="Class task_rejected"> Class <code class="computeroutput"><span class="identifier">task_rejected</span></code></a>
+</h3></div></div></div>
+<div class="toc"><dl><dt><span class="section"> Constructor</span></dt></dl></div>
+<p>
+
+</p>
+<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">task</span><span class="special">/</span><span class="identifier">exceptions</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
+
+<span class="keyword">class</span> <span class="identifier">task_rejected</span> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">runtime_error</span>
+<span class="special">{</span>
+<span class="keyword">public</span><span class="special">:</span>
+ <span class="identifier">task_rejected</span><span class="special">(</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">msg</span><span class="special">);</span>
+<span class="special">};</span>
+</pre>
+<p>
+ </p>
+<div class="section" title="Constructor">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_task.reference.task_rejected.constructor"></a><a class="link" href="reference.html#boost_task.reference.task_rejected.constructor" title="Constructor"> Constructor</a>
+</h4></div></div></div>
+<pre class="programlisting"><span class="identifier">task_rejected</span><span class="special">(</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">msg</span><span class="special">)</span>
+</pre>
+<div class="variablelist">
+<p class="title"><b></b></p>
+<dl>
+<dt><span class="term">Effects:</span></dt>
+<dd><p>
+ Constructs a <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">task_rejected</span></code>
+ instance.
+ </p></dd>
+<dt><span class="term">Throws:</span></dt>
+<dd><p>
+ Nothing
+ </p></dd>
+</dl>
+</div>
+</div>
+</div>
+<div class="section" title="Class poolsize">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_task.reference.poolsize"></a><a class="link" href="reference.html#boost_task.reference.poolsize" title="Class poolsize"> Class <code class="computeroutput"><span class="identifier">poolsize</span></code></a>
+</h3></div></div></div>
+<div class="toc"><dl>
+<dt><span class="section"> Constructor</span></dt>
+<dt><span class="section"><a href="reference.html#boost_task.reference.poolsize.operator"> Member function
+ <code class="computeroutput"><span class="keyword">operator</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">()</span></code></a></span></dt>
+</dl></div>
+<p>
+
+</p>
+<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">task</span><span class="special">/</span><span class="identifier">poolsize</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
+
+<span class="keyword">class</span> <span class="identifier">poolsize</span>
+<span class="special">{</span>
+<span class="keyword">public</span><span class="special">:</span>
+ <span class="keyword">explicit</span> <span class="identifier">poolsize</span><span class="special">(</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">value</span><span class="special">);</span>
+
+ <span class="keyword">operator</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
+<span class="special">};</span>
+</pre>
+<p>
+ </p>
+<div class="section" title="Constructor">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_task.reference.poolsize.constructor"></a><a class="link" href="reference.html#boost_task.reference.poolsize.constructor" title="Constructor"> Constructor</a>
+</h4></div></div></div>
+<pre class="programlisting"><span class="keyword">explicit</span> <span class="identifier">poolsize</span><span class="special">(</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">value</span><span class="special">)</span>
+</pre>
+<div class="variablelist">
+<p class="title"><b></b></p>
+<dl>
+<dt><span class="term">Preconditions:</span></dt>
+<dd><p>
+ value &gt; 0
+ </p></dd>
+<dt><span class="term">Effects:</span></dt>
+<dd><p>
+ constructs a <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">poolsize</span></code>
+ instance
+ </p></dd>
+<dt><span class="term">Postconditions:</span></dt>
+<dd><p>
+ operator std::size_t () &gt; 0
+ </p></dd>
+<dt><span class="term">Throws:</span></dt>
+<dd><p>
+ <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">invalid_poolsize</span></code>
+ </p></dd>
+</dl>
+</div>
+</div>
+<div class="section" title="Member function operator std::size_t()">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_task.reference.poolsize.operator"></a><a class="link" href="reference.html#boost_task.reference.poolsize.operator" title="Member function operator std::size_t()"> Member function
+ <code class="computeroutput"><span class="keyword">operator</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">()</span></code></a>
+</h4></div></div></div>
+<pre class="programlisting"><span class="keyword">operator</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="special">()</span> <span class="keyword">const</span>
+</pre>
+<div class="variablelist">
+<p class="title"><b></b></p>
+<dl>
+<dt><span class="term">Effects:</span></dt>
+<dd><p>
+ returns the value
+ </p></dd>
+<dt><span class="term">Throws:</span></dt>
+<dd><p>
+ Nothing
+ </p></dd>
+</dl>
+</div>
+</div>
+</div>
+<div class="section" title="Class high_watermark">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_task.reference.high_watermark"></a><a class="link" href="reference.html#boost_task.reference.high_watermark" title="Class high_watermark"> Class <code class="computeroutput"><span class="identifier">high_watermark</span></code></a>
+</h3></div></div></div>
+<div class="toc"><dl>
+<dt><span class="section"> Constructor</span></dt>
+<dt><span class="section"><a href="reference.html#boost_task.reference.high_watermark.operator"> Member
+ function <code class="computeroutput"><span class="keyword">operator</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">()</span></code></a></span></dt>
+</dl></div>
+<p>
+
+</p>
+<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">task</span><span class="special">/</span><span class="identifier">watermark</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
+
+<span class="keyword">class</span> <span class="identifier">high_watermark</span>
+<span class="special">{</span>
+<span class="keyword">public</span><span class="special">:</span>
+ <span class="keyword">explicit</span> <span class="identifier">high_watermark</span><span class="special">(</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">value</span><span class="special">);</span>
+
+ <span class="keyword">operator</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
+<span class="special">};</span>
+</pre>
+<p>
+ </p>
+<div class="section" title="Constructor">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_task.reference.high_watermark.constructor"></a><a class="link" href="reference.html#boost_task.reference.high_watermark.constructor" title="Constructor"> Constructor</a>
+</h4></div></div></div>
+<pre class="programlisting"><span class="keyword">explicit</span> <span class="identifier">high_watermark</span><span class="special">(</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">value</span><span class="special">)</span>
+</pre>
+<div class="variablelist">
+<p class="title"><b></b></p>
+<dl>
+<dt><span class="term">Effects:</span></dt>
+<dd><p>
+ constructs a <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">tp</span><span class="special">::</span><span class="identifier">high_watermark</span></code>
+ instance
+ </p></dd>
+<dt><span class="term">Throws:</span></dt>
+<dd><p>
+ <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">invalid_watermark</span></code>
+ </p></dd>
+</dl>
+</div>
+</div>
+<div class="section" title="Member function operator std::size_t()">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_task.reference.high_watermark.operator"></a><a class="link" href="reference.html#boost_task.reference.high_watermark.operator" title="Member function operator std::size_t()"> Member
+ function <code class="computeroutput"><span class="keyword">operator</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">()</span></code></a>
+</h4></div></div></div>
+<pre class="programlisting"><span class="keyword">operator</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="special">()</span> <span class="keyword">const</span>
+</pre>
+<div class="variablelist">
+<p class="title"><b></b></p>
+<dl>
+<dt><span class="term">Effects:</span></dt>
+<dd><p>
+ returns high watermark
+ </p></dd>
+<dt><span class="term">Throws:</span></dt>
+<dd><p>
+ Nothing
+ </p></dd>
+</dl>
+</div>
+</div>
+</div>
+<div class="section" title="Class low_watermark">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_task.reference.low_watermark"></a><a class="link" href="reference.html#boost_task.reference.low_watermark" title="Class low_watermark"> Class <code class="computeroutput"><span class="identifier">low_watermark</span></code></a>
+</h3></div></div></div>
+<div class="toc"><dl>
+<dt><span class="section"> Constructor</span></dt>
+<dt><span class="section"><a href="reference.html#boost_task.reference.low_watermark.operator"> Member
+ function <code class="computeroutput"><span class="keyword">operator</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">()</span></code></a></span></dt>
+</dl></div>
+<p>
+
+</p>
+<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">task</span><span class="special">/</span><span class="identifier">watermark</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
+
+<span class="keyword">class</span> <span class="identifier">low_watermark</span>
+<span class="special">{</span>
+<span class="keyword">public</span><span class="special">:</span>
+ <span class="keyword">explicit</span> <span class="identifier">low_watermark</span><span class="special">(</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">value</span><span class="special">);</span>
+
+ <span class="keyword">operator</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
+<span class="special">};</span>
+</pre>
+<p>
+ </p>
+<div class="section" title="Constructor">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_task.reference.low_watermark.constructor"></a><a class="link" href="reference.html#boost_task.reference.low_watermark.constructor" title="Constructor"> Constructor</a>
+</h4></div></div></div>
+<pre class="programlisting"><span class="keyword">explicit</span> <span class="identifier">low_watermark</span><span class="special">(</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">value</span><span class="special">)</span>
+</pre>
+<div class="variablelist">
+<p class="title"><b></b></p>
+<dl>
+<dt><span class="term">Effects:</span></dt>
+<dd><p>
+ constructs a <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">low_watermark</span></code>
+ instance
+ </p></dd>
+<dt><span class="term">Throws:</span></dt>
+<dd><p>
+ <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">invalid_watermark</span></code>
+ </p></dd>
+</dl>
+</div>
+</div>
+<div class="section" title="Member function operator std::size_t()">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_task.reference.low_watermark.operator"></a><a class="link" href="reference.html#boost_task.reference.low_watermark.operator" title="Member function operator std::size_t()"> Member
+ function <code class="computeroutput"><span class="keyword">operator</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">()</span></code></a>
+</h4></div></div></div>
+<pre class="programlisting"><span class="keyword">operator</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="special">()</span> <span class="keyword">const</span>
+</pre>
+<div class="variablelist">
+<p class="title"><b></b></p>
+<dl>
+<dt><span class="term">Effects:</span></dt>
+<dd><p>
+ returns low watermark
+ </p></dd>
+<dt><span class="term">Throws:</span></dt>
+<dd><p>
+ Nothing
+ </p></dd>
+</dl>
+</div>
+</div>
+</div>
+<div class="section" title="Class scanns">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_task.reference.scanns"></a><a class="link" href="reference.html#boost_task.reference.scanns" title="Class scanns"> Class <code class="computeroutput"><span class="identifier">scanns</span></code></a>
+</h3></div></div></div>
+<div class="toc"><dl>
+<dt><span class="section"> Constructor</span></dt>
+<dt><span class="section"><a href="reference.html#boost_task.reference.scanns.operator"> Member function
+ <code class="computeroutput"><span class="keyword">operator</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">()</span></code></a></span></dt>
+</dl></div>
+<p>
+
+</p>
+<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">task</span><span class="special">/</span><span class="identifier">scanns</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
+
+<span class="keyword">class</span> <span class="identifier">scanns</span>
+<span class="special">{</span>
+<span class="keyword">public</span><span class="special">:</span>
+ <span class="keyword">explicit</span> <span class="identifier">scanns</span><span class="special">(</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">value</span><span class="special">);</span>
+
+ <span class="keyword">operator</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
+<span class="special">};</span>
+</pre>
+<p>
+ </p>
+<div class="section" title="Constructor">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_task.reference.scanns.constructor"></a><a class="link" href="reference.html#boost_task.reference.scanns.constructor" title="Constructor"> Constructor</a>
+</h4></div></div></div>
+<pre class="programlisting"><span class="keyword">explicit</span> <span class="identifier">scanns</span><span class="special">(</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">value</span><span class="special">)</span>
+</pre>
+<div class="variablelist">
+<p class="title"><b></b></p>
+<dl>
+<dt><span class="term">Preconditions:</span></dt>
+<dd><p>
+ value &gt; 0
+ </p></dd>
+<dt><span class="term">Effects:</span></dt>
+<dd><p>
+ constructs a <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">scanns</span></code>
+ instance
+ </p></dd>
+<dt><span class="term">Postconditions:</span></dt>
+<dd><p>
+ operator std::size_t () &gt; 0
+ </p></dd>
+<dt><span class="term">Throws:</span></dt>
+<dd><p>
+ <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">invalid_poolsize</span></code>
+ </p></dd>
+</dl>
+</div>
+</div>
+<div class="section" title="Member function operator std::size_t()">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_task.reference.scanns.operator"></a><a class="link" href="reference.html#boost_task.reference.scanns.operator" title="Member function operator std::size_t()"> Member function
+ <code class="computeroutput"><span class="keyword">operator</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">()</span></code></a>
+</h4></div></div></div>
+<pre class="programlisting"><span class="keyword">operator</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="special">()</span> <span class="keyword">const</span>
+</pre>
+<div class="variablelist">
+<p class="title"><b></b></p>
+<dl>
+<dt><span class="term">Effects:</span></dt>
+<dd><p>
+ returns the value
+ </p></dd>
+<dt><span class="term">Throws:</span></dt>
+<dd><p>
+ Nothing
+ </p></dd>
+</dl>
+</div>
+</div>
+</div>
+</div>
+<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
+<td align="left"></td>
+<td align="right"><div class="copyright-footer">Copyright © 2009 Oliver Kowalke<p>
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ </p>
+</div></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="meta_functions.html"><img src="../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="appendices.html"><img src="../../../doc/html/images/next.png" alt="Next"></a>
+</div>
+</body>
+</html>

Added: sandbox/task/libs/task/doc/html/boost_task/task.html
==============================================================================
--- (empty file)
+++ sandbox/task/libs/task/doc/html/boost_task/task.html 2009-06-01 08:13:01 EDT (Mon, 01 Jun 2009)
@@ -0,0 +1,305 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>Task</title>
+<link rel="stylesheet" href="../boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.75.0">
+<link rel="home" href="../index.html" title="Chapter 1. Boost.Task">
+<link rel="up" href="../index.html" title="Chapter 1. Boost.Task">
+<link rel="prev" href="motivation.html" title="Motivation">
+<link rel="next" href="handle.html" title="Handle">
+</head>
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<table cellpadding="2" width="100%"><tr>
+<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td>
+<td align="center">Home</td>
+<td align="center">Libraries</td>
+<td align="center">People</td>
+<td align="center">FAQ</td>
+<td align="center">More</td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="motivation.html"><img src="../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="handle.html"><img src="../../../doc/html/images/next.png" alt="Next"></a>
+</div>
+<div class="section" title="Task">
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="boost_task.task"></a><a class="link" href="task.html" title="Task"> Task</a>
+</h2></div></div></div>
+<p>
+ A task is a chunk of code that can be executed independently.
+ </p>
+<p>
+ <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">task</span></code>
+ represents a <span class="emphasis"><em>callable</em></span> (provides <code class="computeroutput"><span class="keyword">operator</span><span class="special">()()</span></code>) object containing the unit of code to
+ be execute by a <span class="emphasis"><em>asynchronous-executor</em></span>. Function <code class="computeroutput"><span class="identifier">get_future</span><span class="special">()</span></code>
+ returns a <span class="emphasis"><em>asynchronous-completion-token</em></span> allowing to wait
+ for the completion of the computation of the task, for getting the result of
+ a computation or for transfering exceptions. Each <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">task</span></code> has a unique identifier.
+ </p>
+<a name="boost_task.task.creation"></a><h4>
+<a name="id566445"></a>
+ <a class="link" href="task.html#boost_task.task.creation">Creation</a>
+ </h4>
+<p>
+ <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">make_task</span><span class="special">()</span></code> can be used to create <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">task</span></code> by passing free-functions or member-functions
+ of objects and its arguments: <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">make_task</span><span class="special">()</span></code>
+ accepts up to ten arguments per default (can be overriden by defining BOOST_TASK_MAKE_TASK_MAX_ARITY
+ with the new value).
+ </p>
+<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem">
+ create task from free-function with arguments:
+ </li></ul></div>
+<p>
+
+</p>
+<pre class="programlisting"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</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">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">make_task</span><span class="special">(</span>
+ <span class="identifier">parallel_fib</span><span class="special">,</span>
+ <span class="number">10</span><span class="special">)</span> <span class="special">);</span>
+</pre>
+<p>
+ </p>
+<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem">
+ create task from member-function with arguments:
+ </li></ul></div>
+<p>
+
+</p>
+<pre class="programlisting"><span class="keyword">struct</span> <span class="identifier">X</span>
+<span class="special">{</span>
+ <span class="keyword">void</span> <span class="identifier">f</span><span class="special">(</span> <span class="keyword">int</span> <span class="identifier">i</span><span class="special">);</span>
+<span class="special">};</span>
+
+<span class="identifier">X</span> <span class="identifier">x</span><span class="special">;</span>
+<span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</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">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">make_task</span><span class="special">(</span>
+ <span class="special">&amp;</span> <span class="identifier">X</span><span class="special">::</span><span class="identifier">f</span><span class="special">,</span>
+ <span class="identifier">x</span><span class="special">,</span>
+ <span class="number">10</span><span class="special">)</span> <span class="special">);</span>
+</pre>
+<p>
+ </p>
+<p>
+ It is possible to create <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">task</span></code> from a <span class="emphasis"><em>callable</em></span>
+ too:
+ </p>
+<p>
+
+</p>
+<pre class="programlisting"><span class="keyword">struct</span> <span class="identifier">Y</span>
+<span class="special">{</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="keyword">operator</span><span class="special">()();</span>
+<span class="special">};</span>
+
+<span class="identifier">Y</span> <span class="identifier">y</span><span class="special">;</span>
+<span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">task</span><span class="special">&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="special">&gt;</span> <span class="identifier">t</span><span class="special">(</span> <span class="identifier">y</span><span class="special">);</span>
+</pre>
+<p>
+ </p>
+<a name="boost_task.task.cooperative_task_and_interruption"></a><h4>
+<a name="id567014"></a>
+ <a class="link" href="task.html#boost_task.task.cooperative_task_and_interruption">Cooperative
+ task and interruption</a>
+ </h4>
+<p>
+ Sometimes it is desired to stop a running task if it is no longer needed. In
+ this case the thread is not killed - it stops only at well-defined points (<span class="emphasis"><em>interruption-points</em></span>)
+ its execution. In the context of task-interruption a task is known as cooperative
+ if it checks for an interruption request between two <span class="emphasis"><em>interruption-points</em></span>
+ via <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">this_thread</span><span class="special">::</span><span class="identifier">interruption_requested</span><span class="special">()</span></code>
+ <sup>[<a name="id567065" href="#ftn.id567065" class="footnote">2</a>]</sup>
+ .
+ </p>
+<p>
+ <span class="emphasis"><em>interruption-points</em></span> are:
+ </p>
+<div class="itemizedlist"><ul class="itemizedlist" type="disc">
+<li class="listitem"><code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">thread</span><span class="special">::</span><span class="identifier">join</span><span class="special">()</span></code></li>
+<li class="listitem"><code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">thread</span><span class="special">::</span><span class="identifier">timed_join</span><span class="special">()</span></code></li>
+<li class="listitem"><code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">condition_variable</span><span class="special">::</span><span class="identifier">wait</span><span class="special">()</span></code></li>
+<li class="listitem"><code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">condition_variable</span><span class="special">::</span><span class="identifier">timed_wait</span><span class="special">()</span></code></li>
+<li class="listitem"><code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">condition_variable_any</span><span class="special">::</span><span class="identifier">wait</span><span class="special">()</span></code></li>
+<li class="listitem"><code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">condition_variable_any</span><span class="special">::</span><span class="identifier">timed_wait</span><span class="special">()</span></code></li>
+<li class="listitem"><code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">thread</span><span class="special">::</span><span class="identifier">sleep</span><span class="special">()</span></code></li>
+<li class="listitem"><code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">this_thread</span><span class="special">::</span><span class="identifier">sleep</span><span class="special">()</span></code></li>
+<li class="listitem"><code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">this_thread</span><span class="special">::</span><span class="identifier">interruption_point</span><span class="special">()</span></code></li>
+</ul></div>
+<p>
+ A <span class="emphasis"><em>interruption-point</em></span> throws <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">task_interrupted</span></code> if an interruption was requested.
+ </p>
+<p>
+
+</p>
+<pre class="programlisting"><span class="keyword">long</span> <span class="identifier">cooperative</span><span class="special">(</span> <span class="keyword">long</span> <span class="identifier">n</span><span class="special">)</span>
+<span class="special">{</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">this_thread</span><span class="special">::</span><span class="identifier">interruption_point</span><span class="special">();</span> <span class="comment">// interruption point
+</span>
+ <span class="keyword">if</span> <span class="special">(</span> <span class="identifier">n</span> <span class="special">==</span> <span class="number">0</span><span class="special">)</span> <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span>
+ <span class="keyword">if</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="keyword">return</span> <span class="number">1</span><span class="special">;</span>
+ <span class="keyword">long</span> <span class="identifier">k1</span><span class="special">(</span> <span class="number">1</span><span class="special">),</span> <span class="identifier">k2</span><span class="special">(</span> <span class="number">0</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">2</span><span class="special">);</span> <span class="identifier">i</span> <span class="special">&lt;=</span> <span class="identifier">n</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span>
+ <span class="special">{</span>
+ <span class="keyword">if</span> <span class="special">(</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">this_thread</span><span class="special">::</span><span class="identifier">interruption_requested</span><span class="special">()</span> <span class="special">)</span> <span class="comment">// check if interruption was requested
+</span> <span class="keyword">return</span><span class="special">;</span>
+
+ <span class="keyword">long</span> <span class="identifier">tmp</span><span class="special">(</span> <span class="identifier">k1</span><span class="special">);</span>
+ <span class="identifier">k1</span> <span class="special">=</span> <span class="identifier">k1</span> <span class="special">+</span> <span class="identifier">k2</span><span class="special">;</span>
+ <span class="identifier">k2</span> <span class="special">=</span> <span class="identifier">tmp</span><span class="special">;</span>
+ <span class="special">}</span>
+
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">this_thread</span><span class="special">::</span><span class="identifier">interruption_point</span><span class="special">();</span> <span class="comment">// interruption point
+</span>
+ <span class="keyword">return</span> <span class="identifier">k1</span><span class="special">;</span>
+<span class="special">}</span>
+
+<span class="keyword">void</span> <span class="identifier">main</span><span class="special">()</span>
+<span class="special">{</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">handle</span><span class="special">&lt;</span> <span class="keyword">long</span> <span class="special">&gt;</span> <span class="identifier">h</span><span class="special">(</span> <span class="comment">// get handle associated with the task
+</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">async</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">new_thread</span><span class="special">(),</span> <span class="comment">// asynchronous executor
+</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">make_task</span><span class="special">(</span> <span class="comment">// task, to be executed asynchronously
+</span> <span class="identifier">cooperative</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">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">h</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">// throws boost::task::task_interrupted
+</span><span class="special">}</span>
+</pre>
+<p>
+ </p>
+<a name="boost_task.task.exceptions"></a><h4>
+<a name="id568131"></a>
+ <a class="link" href="task.html#boost_task.task.exceptions">Exceptions</a>
+ </h4>
+<p>
+ Exceptions thrown by <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">task</span></code> are transported by the <span class="emphasis"><em>asynchronous-completion-token</em></span>.
+ </p>
+<p>
+
+</p>
+<pre class="programlisting"><span class="keyword">void</span> <span class="identifier">throwing</span><span class="special">()</span>
+<span class="special">{</span>
+ <span class="special">...</span>
+ <span class="keyword">throw</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">domain_error</span><span class="special">(</span><span class="string">"domain error"</span><span class="special">);</span>
+ <span class="special">...</span>
+<span class="special">}</span>
+
+<span class="keyword">void</span> <span class="identifier">main</span><span class="special">()</span>
+<span class="special">{</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">handle</span><span class="special">&lt;</span> <span class="keyword">void</span> <span class="special">&gt;</span> <span class="identifier">h</span><span class="special">(</span> <span class="comment">// get handle associated with the task
+</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">async</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">new_thread</span><span class="special">(),</span> <span class="comment">// asynchronous executor
+</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">make_task</span><span class="special">(</span> <span class="comment">// task, to be executed asynchronously
+</span> <span class="identifier">throwing</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">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">h</span><span class="special">.</span><span class="identifier">wait</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">// throws std::domain_error
+</span><span class="special">}</span>
+</pre>
+<p>
+ </p>
+<p>
+ Exceptions rethrown by type are:
+ </p>
+<div class="itemizedlist"><ul class="itemizedlist" type="disc">
+<li class="listitem"><code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">bad_alloc</span></code></li>
+<li class="listitem"><code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">bad_cast</span></code></li>
+<li class="listitem"><code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">bad_exception</span></code></li>
+<li class="listitem"><code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">bad_typeid</span></code></li>
+<li class="listitem"><code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">domain_error</span></code></li>
+<li class="listitem"><code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">invalid_argument</span></code></li>
+<li class="listitem"><code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">ios_base</span><span class="special">::</span><span class="identifier">failure</span></code></li>
+<li class="listitem"><code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">length_error</span></code></li>
+<li class="listitem"><code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">logic_error</span></code></li>
+<li class="listitem"><code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">out_of_range</span></code></li>
+<li class="listitem"><code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">overflow_error</span></code></li>
+<li class="listitem"><code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">range_error</span></code></li>
+<li class="listitem"><code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">runtime_error</span></code></li>
+<li class="listitem"><code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">underflow_error</span></code></li>
+<li class="listitem"><code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">future_already_set</span></code></li>
+<li class="listitem"><code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">future_cancel</span></code></li>
+<li class="listitem"><code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">exception</span></code></li>
+<li class="listitem"><code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">invalid_thread_argument</span></code></li>
+<li class="listitem"><code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">lock_error</span></code></li>
+<li class="listitem"><code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">task_interrupted</span></code></li>
+<li class="listitem"><code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">broken_task</span></code></li>
+</ul></div>
+<a name="boost_task.task.parent_task"></a><h4>
+<a name="id568934"></a>
+ <a class="link" href="task.html#boost_task.task.parent_task">Parent task</a>
+ </h4>
+<p>
+ Top-level tasks have no parent. A parent task can create child tasks when it
+ creates another task by using <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">as_sub_task</span></code> as <span class="emphasis"><em>asynchronous-executor</em></span>.
+ These children are implicitly treated as <span class="emphasis"><em>sub-tasks</em></span> of
+ the larger task. It is assumed that that <span class="emphasis"><em>sub-tasks</em></span> can
+ be executed in any order because only overall operation speed matters (enabling
+ strategies for fast execution of unordered <span class="emphasis"><em>work-items</em></span>
+ as <a class="link" href="pool.html#boost_task.pool.work_stealing" title="Work-Stealing"><span class="emphasis"><em>work-stealing</em></span></a>).
+ </p>
+<p>
+
+</p>
+<pre class="programlisting"><span class="keyword">long</span> <span class="identifier">serial_fib</span><span class="special">(</span> <span class="keyword">long</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">2</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">serial_fib</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="identifier">serial_fib</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="keyword">long</span> <span class="identifier">parallel_fib</span><span class="special">(</span> <span class="keyword">long</span> <span class="identifier">n</span><span class="special">,</span> <span class="keyword">long</span> <span class="identifier">cutof</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">cutof</span><span class="special">)</span> <span class="keyword">return</span> <span class="identifier">serial_fib</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">// submit a sub-task to pool calculating fibonacci(n-1)
+</span> <span class="identifier">h1</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">async</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">as_sub_task</span><span class="special">(),</span> <span class="comment">// execute a sub-task
+</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">make_task</span><span class="special">(</span>
+ <span class="identifier">parallel_fib</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="identifier">cutof</span><span class="special">)</span> <span class="special">);</span>
+ <span class="comment">// submit a sub-task to pool calculating fibonacci(n-2)
+</span> <span class="identifier">h2</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">async</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">as_sub_task</span><span class="special">(),</span> <span class="comment">// execute a sub-task
+</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">make_task</span><span class="special">(</span>
+ <span class="identifier">parallel_fib</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="identifier">cutof</span><span class="special">)</span> <span class="special">);</span>
+ <span class="comment">// calculate fibonacci(n) from the results of both sub-tasks
+</span> <span class="keyword">return</span> <span class="identifier">h1</span><span class="special">.</span><span class="identifier">get</span><span class="special">()</span> <span class="special">+</span> <span class="identifier">h2</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">void</span> <span class="identifier">main</span><span class="special">()</span>
+<span class="special">{</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">handle</span><span class="special">&lt;</span> <span class="keyword">long</span> <span class="special">&gt;</span> <span class="identifier">h</span><span class="special">(</span> <span class="comment">// handle for fibonacci calculation
+</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">async</span><span class="special">(</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">default_pool</span><span class="special">(),</span> <span class="comment">// access the default thread-pool
+</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">make_task</span><span class="special">(</span> <span class="comment">// calculate fibonacci number 10
+</span> <span class="identifier">parallel_fib</span><span class="special">,</span> <span class="comment">// for numbers &lt; 5 do inline recursive calculation
+</span> <span class="number">10</span><span class="special">,</span>
+ <span class="number">5</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">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">h</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="special">}</span>
+</pre>
+<p>
+ </p>
+<div class="footnotes">
+<br><hr width="100" align="left">
+<div class="footnote"><p><sup>[<a name="ftn.id567065" href="#id567065" class="para">2</a>] </sup>
+ see 'Interrupt Politely',
+ Herb Sutter
+ </p></div>
+</div>
+</div>
+<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
+<td align="left"></td>
+<td align="right"><div class="copyright-footer">Copyright © 2009 Oliver Kowalke<p>
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ </p>
+</div></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="motivation.html"><img src="../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="handle.html"><img src="../../../doc/html/images/next.png" alt="Next"></a>
+</div>
+</body>
+</html>

Added: sandbox/task/libs/task/doc/html/boost_task/utilities.html
==============================================================================
--- (empty file)
+++ sandbox/task/libs/task/doc/html/boost_task/utilities.html 2009-06-01 08:13:01 EDT (Mon, 01 Jun 2009)
@@ -0,0 +1,112 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>Utilities</title>
+<link rel="stylesheet" href="../boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.75.0">
+<link rel="home" href="../index.html" title="Chapter 1. Boost.Task">
+<link rel="up" href="../index.html" title="Chapter 1. Boost.Task">
+<link rel="prev" href="as_sub_task.html" title="Execute as sub-task">
+<link rel="next" href="meta_functions.html" title="Meta functions">
+</head>
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<table cellpadding="2" width="100%"><tr>
+<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td>
+<td align="center">Home</td>
+<td align="center">Libraries</td>
+<td align="center">People</td>
+<td align="center">FAQ</td>
+<td align="center">More</td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="as_sub_task.html"><img src="../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="meta_functions.html"><img src="../../../doc/html/images/next.png" alt="Next"></a>
+</div>
+<div class="section" title="Utilities">
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="boost_task.utilities"></a><a class="link" href="utilities.html" title="Utilities"> Utilities</a>
+</h2></div></div></div>
+<p>
+ <span class="bold"><strong>Boost.Task</strong></span> provides some free-functions which
+ can be used inside a <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">task</span></code> to access some informations (like if
+ the <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">task</span></code>
+ runs in a <span class="emphasis"><em>thread-pool</em></span>).
+ </p>
+<a name="boost_task.utilities.reschedule_until"></a><h4>
+<a name="id583403"></a>
+ <a class="link" href="utilities.html#boost_task.utilities.reschedule_until">reschedule_until</a>
+ </h4>
+<p>
+ In the function <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">this_task</span><span class="special">::</span><span class="identifier">reschedule_until</span><span class="special">(</span>
+ <span class="identifier">Pred</span> <span class="keyword">const</span><span class="special">&amp;)</span></code> allows to synchronize the task with other
+ asynchronous events without blocking the <span class="emphasis"><em>worker-threads</em></span>
+ (bool Pred::operator()() must not block). The current task will be rescheduled
+ until the passed predicate becomes true.
+ </p>
+<a name="boost_task.utilities.get_pool"></a><h4>
+<a name="id583480"></a>
+ <a class="link" href="utilities.html#boost_task.utilities.get_pool">get_pool</a>
+ </h4>
+<p>
+ The pool in which the current code (<code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">task</span></code>) is executed 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_pool</span><span class="special">()</span></code>. If hte code is not executed by a <span class="emphasis"><em>worker-thread</em></span>
+ an assertion is raised.
+ </p>
+<a name="boost_task.utilities.runs_in_pool"></a><h4>
+<a name="id583569"></a>
+ <a class="link" href="utilities.html#boost_task.utilities.runs_in_pool">runs_in_pool</a>
+ </h4>
+<p>
+ In order to check if the current code is executed in a <span class="emphasis"><em>thread-pool</em></span>
+ <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">runs_in_pool</span><span class="special">()</span></code>
+ should be used.
+ </p>
+<a name="boost_task.utilities.worker_id"></a><h4>
+<a name="id583628"></a>
+ <a class="link" href="utilities.html#boost_task.utilities.worker_id">worker_id</a>
+ </h4>
+<p>
+ <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">this_task</span><span class="special">::</span><span class="identifier">worker_id</span><span class="special">()</span></code>
+ returns the <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">thread</span><span class="special">::</span><span class="identifier">id</span></code> of the <span class="emphasis"><em>worker-thread</em></span>
+ executing the current <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">task</span></code>.
+ </p>
+<a name="boost_task.utilities.delay"></a><h4>
+<a name="id583744"></a>
+ <a class="link" href="utilities.html#boost_task.utilities.delay">delay</a>
+ </h4>
+<p>
+ The execution of a <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">task</span></code>
+ can be delayed for a time-duration or until a specific time-point with <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">delay</span><span class="special">()</span></code>.
+ </p>
+<a name="boost_task.utilities.yield"></a><h4>
+<a name="id583828"></a>
+ <a class="link" href="utilities.html#boost_task.utilities.yield">yield</a>
+ </h4>
+<p>
+ If a <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">task</span></code>
+ detects that it would bould block it can yield itself with <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">yield</span><span class="special">()</span></code>
+ so that the <span class="emphasis"><em>worker-thread</em></span> can execute another <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">task</span></code> in
+ the meantime.
+ </p>
+<a name="boost_task.utilities.interrupt"></a><h4>
+<a name="id583945"></a>
+ <a class="link" href="utilities.html#boost_task.utilities.interrupt">interrupt</a>
+ </h4>
+<p>
+ A <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">task</span></code>
+ can interrupt itself 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">interrupt</span><span class="special">()</span></code>.
+ </p>
+</div>
+<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
+<td align="left"></td>
+<td align="right"><div class="copyright-footer">Copyright © 2009 Oliver Kowalke<p>
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ </p>
+</div></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="as_sub_task.html"><img src="../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="meta_functions.html"><img src="../../../doc/html/images/next.png" alt="Next"></a>
+</div>
+</body>
+</html>

Added: sandbox/task/libs/task/doc/html/boostbook.css
==============================================================================
--- (empty file)
+++ sandbox/task/libs/task/doc/html/boostbook.css 2009-06-01 08:13:01 EDT (Mon, 01 Jun 2009)
@@ -0,0 +1,594 @@
+/*=============================================================================
+ Copyright (c) 2004 Joel de Guzman
+ http://spirit.sourceforge.net/
+
+ Distributed under the Boost Software License, Version 1.0. (See accompany-
+ ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+=============================================================================*/
+
+/*=============================================================================
+ Body defaults
+=============================================================================*/
+
+ body
+ {
+ margin: 1em;
+ font-family: sans-serif;
+ }
+
+/*=============================================================================
+ Paragraphs
+=============================================================================*/
+
+ p
+ {
+ text-align: left;
+ font-size: 10pt;
+ line-height: 1.15;
+ }
+
+/*=============================================================================
+ Program listings
+=============================================================================*/
+
+ /* Code on paragraphs */
+ p tt.computeroutput
+ {
+ font-size: 9pt;
+ }
+
+ pre.synopsis
+ {
+ font-size: 90%;
+ margin: 1pc 4% 0pc 4%;
+ padding: 0.5pc 0.5pc 0.5pc 0.5pc;
+ }
+
+ .programlisting,
+ .screen
+ {
+ font-size: 9pt;
+ display: block;
+ margin: 1pc 4% 0pc 4%;
+ padding: 0.5pc 0.5pc 0.5pc 0.5pc;
+ }
+
+ /* Program listings in tables don't get borders */
+ td .programlisting,
+ td .screen
+ {
+ margin: 0pc 0pc 0pc 0pc;
+ padding: 0pc 0pc 0pc 0pc;
+ }
+
+/*=============================================================================
+ Headings
+=============================================================================*/
+
+ h1, h2, h3, h4, h5, h6
+ {
+ text-align: left;
+ margin: 1em 0em 0.5em 0em;
+ font-weight: bold;
+ }
+
+ h1 { font: 140% }
+ h2 { font: bold 140% }
+ h3 { font: bold 130% }
+ h4 { font: bold 120% }
+ h5 { font: italic 110% }
+ h6 { font: italic 100% }
+
+ /* Top page titles */
+ title,
+ h1.title,
+ h2.title
+ h3.title,
+ h4.title,
+ h5.title,
+ h6.title,
+ .refentrytitle
+ {
+ font-weight: bold;
+ margin-bottom: 1pc;
+ }
+
+ h1.title { font-size: 140% }
+ h2.title { font-size: 140% }
+ h3.title { font-size: 130% }
+ h4.title { font-size: 120% }
+ h5.title { font-size: 110% }
+ h6.title { font-size: 100% }
+
+ .section h1
+ {
+ margin: 0em 0em 0.5em 0em;
+ font-size: 140%;
+ }
+
+ .section h2 { font-size: 140% }
+ .section h3 { font-size: 130% }
+ .section h4 { font-size: 120% }
+ .section h5 { font-size: 110% }
+ .section h6 { font-size: 100% }
+
+ /* Code on titles */
+ h1 tt.computeroutput { font-size: 140% }
+ h2 tt.computeroutput { font-size: 140% }
+ h3 tt.computeroutput { font-size: 130% }
+ h4 tt.computeroutput { font-size: 120% }
+ h5 tt.computeroutput { font-size: 110% }
+ h6 tt.computeroutput { font-size: 100% }
+
+/*=============================================================================
+ Author
+=============================================================================*/
+
+ h3.author
+ {
+ font-size: 100%
+ }
+
+/*=============================================================================
+ Lists
+=============================================================================*/
+
+ li
+ {
+ font-size: 10pt;
+ line-height: 1.3;
+ }
+
+ /* Unordered lists */
+ ul
+ {
+ text-align: left;
+ }
+
+ /* Ordered lists */
+ ol
+ {
+ text-align: left;
+ }
+
+/*=============================================================================
+ Links
+=============================================================================*/
+
+ a
+ {
+ text-decoration: none; /* no underline */
+ }
+
+ a:hover
+ {
+ text-decoration: underline;
+ }
+
+/*=============================================================================
+ Spirit style navigation
+=============================================================================*/
+
+ .spirit-nav
+ {
+ text-align: right;
+ }
+
+ .spirit-nav a
+ {
+ color: white;
+ padding-left: 0.5em;
+ }
+
+ .spirit-nav img
+ {
+ border-width: 0px;
+ }
+
+/*=============================================================================
+ Copyright footer
+=============================================================================*/
+ .copyright-footer
+ {
+ text-align: right;
+ font-size: 70%;
+ }
+
+ .copyright-footer p
+ {
+ text-align: right;
+ font-size: 80%;
+ }
+
+/*=============================================================================
+ Table of contents
+=============================================================================*/
+
+ .toc
+ {
+ margin: 1pc 4% 0pc 4%;
+ padding: 0.1pc 1pc 0.1pc 1pc;
+ font-size: 80%;
+ line-height: 1.15;
+ }
+
+ .boost-toc
+ {
+ float: right;
+ padding: 0.5pc;
+ }
+
+/*=============================================================================
+ Tables
+=============================================================================*/
+
+ .table-title,
+ div.table p.title
+ {
+ margin-left: 4%;
+ padding-right: 0.5em;
+ padding-left: 0.5em;
+ }
+
+ .informaltable table,
+ .table table
+ {
+ width: 92%;
+ margin-left: 4%;
+ margin-right: 4%;
+ }
+
+ div.informaltable table,
+ div.table table
+ {
+ padding: 4px;
+ }
+
+ /* Table Cells */
+ div.informaltable table tr td,
+ div.table table tr td
+ {
+ padding: 0.5em;
+ text-align: left;
+ font-size: 9pt;
+ }
+
+ div.informaltable table tr th,
+ div.table table tr th
+ {
+ padding: 0.5em 0.5em 0.5em 0.5em;
+ border: 1pt solid white;
+ font-size: 80%;
+ }
+
+ table.simplelist
+ {
+ width: auto !important;
+ margin: 0em !important;
+ padding: 0em !important;
+ border: none !important;
+ }
+ table.simplelist td
+ {
+ margin: 0em !important;
+ padding: 0em !important;
+ text-align: left !important;
+ font-size: 9pt !important;
+ border: none !important;
+ }
+
+/*=============================================================================
+ Blurbs
+=============================================================================*/
+
+ div.note,
+ div.tip,
+ div.important,
+ div.caution,
+ div.warning,
+ p.blurb
+ {
+ font-size: 9pt; /* A little bit smaller than the main text */
+ line-height: 1.2;
+ display: block;
+ margin: 1pc 4% 0pc 4%;
+ padding: 0.5pc 0.5pc 0.5pc 0.5pc;
+ }
+
+ p.blurb img
+ {
+ padding: 1pt;
+ }
+
+/*=============================================================================
+ Variable Lists
+=============================================================================*/
+
+ div.variablelist
+ {
+ margin: 1em 0;
+ }
+
+ /* Make the terms in definition lists bold */
+ div.variablelist dl dt,
+ span.term
+ {
+ font-weight: bold;
+ font-size: 10pt;
+ }
+
+ div.variablelist table tbody tr td
+ {
+ text-align: left;
+ vertical-align: top;
+ padding: 0em 2em 0em 0em;
+ font-size: 10pt;
+ margin: 0em 0em 0.5em 0em;
+ line-height: 1;
+ }
+
+ div.variablelist dl dt
+ {
+ margin-bottom: 0.2em;
+ }
+
+ div.variablelist dl dd
+ {
+ margin: 0em 0em 0.5em 2em;
+ font-size: 10pt;
+ }
+
+ div.variablelist table tbody tr td p,
+ div.variablelist dl dd p
+ {
+ margin: 0em 0em 0.5em 0em;
+ line-height: 1;
+ }
+
+/*=============================================================================
+ Misc
+=============================================================================*/
+
+ /* Title of books and articles in bibliographies */
+ span.title
+ {
+ font-style: italic;
+ }
+
+ span.underline
+ {
+ text-decoration: underline;
+ }
+
+ span.strikethrough
+ {
+ text-decoration: line-through;
+ }
+
+ /* Copyright, Legal Notice */
+ div div.legalnotice p
+ {
+ text-align: left
+ }
+
+/*=============================================================================
+ Colors
+=============================================================================*/
+
+ @media screen
+ {
+ body {
+ background-color: #FFFFFF;
+ color: #000000;
+ }
+
+ /* Links */
+ a
+ {
+ color: #005a9c;
+ }
+
+ a:visited
+ {
+ color: #9c5a9c;
+ }
+
+ h1 a, h2 a, h3 a, h4 a, h5 a, h6 a,
+ h1 a:hover, h2 a:hover, h3 a:hover, h4 a:hover, h5 a:hover, h6 a:hover,
+ h1 a:visited, h2 a:visited, h3 a:visited, h4 a:visited, h5 a:visited, h6 a:visited
+ {
+ text-decoration: none; /* no underline */
+ color: #000000;
+ }
+
+ /* Syntax Highlighting */
+ .keyword { color: #0000AA; }
+ .identifier { color: #000000; }
+ .special { color: #707070; }
+ .preprocessor { color: #402080; }
+ .char { color: teal; }
+ .comment { color: #800000; }
+ .string { color: teal; }
+ .number { color: teal; }
+ .white_bkd { background-color: #FFFFFF; }
+ .dk_grey_bkd { background-color: #999999; }
+
+ /* Copyright, Legal Notice */
+ .copyright
+ {
+ color: #666666;
+ font-size: small;
+ }
+
+ div div.legalnotice p
+ {
+ color: #666666;
+ }
+
+ /* Program listing */
+ pre.synopsis
+ {
+ border: 1px solid #DCDCDC;
+ }
+
+ .programlisting,
+ .screen
+ {
+ border: 1px solid #DCDCDC;
+ }
+
+ td .programlisting,
+ td .screen
+ {
+ border: 0px solid #DCDCDC;
+ }
+
+ /* Blurbs */
+ div.note,
+ div.tip,
+ div.important,
+ div.caution,
+ div.warning,
+ p.blurb
+ {
+ border: 1px solid #DCDCDC;
+ }
+
+ /* Table of contents */
+ .toc
+ {
+ border: 1px solid #DCDCDC;
+ }
+
+ /* Tables */
+ div.informaltable table tr td,
+ div.table table tr td
+ {
+ border: 1px solid #DCDCDC;
+ }
+
+ div.informaltable table tr th,
+ div.table table tr th
+ {
+ background-color: #F0F0F0;
+ border: 1px solid #DCDCDC;
+ }
+
+ .copyright-footer
+ {
+ color: #8F8F8F;
+ }
+
+ /* Misc */
+ span.highlight
+ {
+ color: #00A000;
+ }
+ }
+
+ @media print
+ {
+ /* Links */
+ a
+ {
+ color: black;
+ }
+
+ a:visited
+ {
+ color: black;
+ }
+
+ .spirit-nav
+ {
+ display: none;
+ }
+
+ /* Program listing */
+ pre.synopsis
+ {
+ border: 1px solid gray;
+ }
+
+ .programlisting,
+ .screen
+ {
+ border: 1px solid gray;
+ }
+
+ td .programlisting,
+ td .screen
+ {
+ border: 0px solid #DCDCDC;
+ }
+
+ /* Table of contents */
+ .toc
+ {
+ border: 1px solid gray;
+ }
+
+ .informaltable table,
+ .table table
+ {
+ border: 1px solid gray;
+ border-collapse: collapse;
+ }
+
+ /* Tables */
+ div.informaltable table tr td,
+ div.table table tr td
+ {
+ border: 1px solid gray;
+ }
+
+ div.informaltable table tr th,
+ div.table table tr th
+ {
+ border: 1px solid gray;
+ }
+
+ table.simplelist tr td
+ {
+ border: none !important;
+ }
+
+ /* Misc */
+ span.highlight
+ {
+ font-weight: bold;
+ }
+ }
+
+/*=============================================================================
+ Images
+=============================================================================*/
+
+ span.inlinemediaobject img
+ {
+ vertical-align: middle;
+ }
+
+/*==============================================================================
+ Super and Subscript: style so that line spacing isn't effected, see
+ http://www.adobe.com/cfusion/communityengine/index.cfm?event=showdetails&productId=1&postId=5341
+==============================================================================*/
+
+sup,
+sub {
+ height: 0;
+ line-height: 1;
+ vertical-align: baseline;
+ _vertical-align: bottom;
+ position: relative;
+
+}
+
+sup {
+ bottom: 1ex;
+}
+
+sub {
+ top: .5ex;
+}
+

Added: sandbox/task/libs/task/doc/html/docutils.css
==============================================================================
--- (empty file)
+++ sandbox/task/libs/task/doc/html/docutils.css 2009-06-01 08:13:01 EDT (Mon, 01 Jun 2009)
@@ -0,0 +1,275 @@
+/*
+:Author: David Goodger
+:Contact: goodger_at_[hidden]
+:Date: $Date: 2007-11-25 19:34:32 +0000 (Sun, 25 Nov 2007) $
+:Revision: $Revision: 41371 $
+:Copyright: This stylesheet has been placed in the public domain.
+
+Default cascading style sheet for the HTML output of Docutils.
+
+See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to
+customize this style sheet.
+*/
+
+/* used to remove borders from tables and images */
+.borderless, table.borderless td, table.borderless th {
+ border: 0 }
+
+table.borderless td, table.borderless th {
+ /* Override padding for "table.docutils td" with "! important".
+ The right padding separates the table cells. */
+ padding: 0 0.5em 0 0 ! important }
+
+.first {
+ /* Override more specific margin styles with "! important". */
+ margin-top: 0 ! important }
+
+.last, .with-subtitle {
+ margin-bottom: 0 ! important }
+
+.hidden {
+ display: none }
+
+a.toc-backref {
+ text-decoration: none ;
+ color: black }
+
+blockquote.epigraph {
+ margin: 2em 5em ; }
+
+dl.docutils dd {
+ margin-bottom: 0.5em }
+
+/* Uncomment (and remove this text!) to get bold-faced definition list terms
+dl.docutils dt {
+ font-weight: bold }
+*/
+
+div.abstract {
+ margin: 2em 5em }
+
+div.abstract p.topic-title {
+ font-weight: bold ;
+ text-align: center }
+
+div.admonition, div.attention, div.caution, div.danger, div.error,
+div.hint, div.important, div.note, div.tip, div.warning {
+ margin: 2em ;
+ border: medium outset ;
+ padding: 1em }
+
+div.admonition p.admonition-title, div.hint p.admonition-title,
+div.important p.admonition-title, div.note p.admonition-title,
+div.tip p.admonition-title {
+ font-weight: bold ;
+ font-family: sans-serif }
+
+div.attention p.admonition-title, div.caution p.admonition-title,
+div.danger p.admonition-title, div.error p.admonition-title,
+div.warning p.admonition-title {
+ color: red ;
+ font-weight: bold ;
+ font-family: sans-serif }
+
+/* Uncomment (and remove this text!) to get reduced vertical space in
+ compound paragraphs.
+div.compound .compound-first, div.compound .compound-middle {
+ margin-bottom: 0.5em }
+
+div.compound .compound-last, div.compound .compound-middle {
+ margin-top: 0.5em }
+*/
+
+div.dedication {
+ margin: 2em 5em ;
+ text-align: center ;
+ font-style: italic }
+
+div.dedication p.topic-title {
+ font-weight: bold ;
+ font-style: normal }
+
+div.figure {
+ margin-left: 2em ;
+ margin-right: 2em }
+
+div.footer, div.header {
+ clear: both;
+ font-size: smaller }
+
+div.line-block {
+ display: block ;
+ margin-top: 1em ;
+ margin-bottom: 1em }
+
+div.line-block div.line-block {
+ margin-top: 0 ;
+ margin-bottom: 0 ;
+ margin-left: 1.5em }
+
+div.sidebar {
+ margin-left: 1em ;
+ border: medium outset ;
+ padding: 1em ;
+ background-color: #ffffee ;
+ width: 40% ;
+ float: right ;
+ clear: right }
+
+div.sidebar p.rubric {
+ font-family: sans-serif ;
+ font-size: medium }
+
+div.system-messages {
+ margin: 5em }
+
+div.system-messages h1 {
+ color: red }
+
+div.system-message {
+ border: medium outset ;
+ padding: 1em }
+
+div.system-message p.system-message-title {
+ color: red ;
+ font-weight: bold }
+
+div.topic {
+ margin: 2em }
+
+h1.section-subtitle, h2.section-subtitle, h3.section-subtitle,
+h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {
+ margin-top: 0.4em }
+
+h1.title {
+ text-align: center }
+
+h2.subtitle {
+ text-align: center }
+
+hr.docutils {
+ width: 75% }
+
+img.align-left {
+ clear: left }
+
+img.align-right {
+ clear: right }
+
+ol.simple, ul.simple {
+ margin-bottom: 1em }
+
+ol.arabic {
+ list-style: decimal }
+
+ol.loweralpha {
+ list-style: lower-alpha }
+
+ol.upperalpha {
+ list-style: upper-alpha }
+
+ol.lowerroman {
+ list-style: lower-roman }
+
+ol.upperroman {
+ list-style: upper-roman }
+
+p.attribution {
+ text-align: right ;
+ margin-left: 50% }
+
+p.caption {
+ font-style: italic }
+
+p.credits {
+ font-style: italic ;
+ font-size: smaller }
+
+p.label {
+ white-space: nowrap }
+
+p.rubric {
+ font-weight: bold ;
+ font-size: larger ;
+ color: maroon ;
+ text-align: center }
+
+p.sidebar-title {
+ font-family: sans-serif ;
+ font-weight: bold ;
+ font-size: larger }
+
+p.sidebar-subtitle {
+ font-family: sans-serif ;
+ font-weight: bold }
+
+p.topic-title {
+ font-weight: bold }
+
+pre.address {
+ margin-bottom: 0 ;
+ margin-top: 0 ;
+ font-family: serif ;
+ font-size: 100% }
+
+pre.literal-block, pre.doctest-block {
+ margin-left: 2em ;
+ margin-right: 2em }
+
+span.classifier {
+ font-family: sans-serif ;
+ font-style: oblique }
+
+span.classifier-delimiter {
+ font-family: sans-serif ;
+ font-weight: bold }
+
+span.interpreted {
+ font-family: sans-serif }
+
+span.option {
+ white-space: nowrap }
+
+span.pre {
+ white-space: pre }
+
+span.problematic {
+ color: red }
+
+span.section-subtitle {
+ /* font-size relative to parent (h1..h6 element) */
+ font-size: 80% }
+
+table.citation {
+ border-left: solid 1px gray;
+ margin-left: 1px }
+
+table.docinfo {
+ margin: 2em 4em }
+
+table.docutils {
+ margin-top: 0.5em ;
+ margin-bottom: 0.5em }
+
+table.footnote {
+ border-left: solid 1px black;
+ margin-left: 1px }
+
+table.docutils td, table.docutils th,
+table.docinfo td, table.docinfo th {
+ padding-left: 0.5em ;
+ padding-right: 0.5em ;
+ vertical-align: top }
+
+table.docutils th.field-name, table.docinfo th.docinfo-name {
+ font-weight: bold ;
+ text-align: left ;
+ white-space: nowrap ;
+ padding-left: 0 }
+
+h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
+h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {
+ font-size: 100% }
+
+ul.auto-toc {
+ list-style-type: none }

Added: sandbox/task/libs/task/doc/html/images/accumulators/doxygen.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_0.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_1.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_10.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_100.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_11.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_12.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_13.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_14.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_15.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_16.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_17.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_18.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_19.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_2.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_20.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_21.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_22.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_23.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_24.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_25.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_26.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_27.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_28.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_29.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_3.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_30.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_31.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_32.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_33.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_34.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_35.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_36.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_37.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_38.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_39.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_4.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_40.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_41.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_42.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_43.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_44.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_45.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_46.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_47.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_48.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_49.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_5.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_50.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_51.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_52.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_53.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_54.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_55.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_56.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_57.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_58.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_59.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_6.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_60.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_61.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_62.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_63.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_64.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_65.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_66.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_67.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_68.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_69.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_7.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_70.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_71.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_72.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_73.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_74.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_75.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_76.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_77.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_78.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_79.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_8.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_80.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_81.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_82.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_83.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_84.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_85.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_86.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_87.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_88.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_89.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_9.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_90.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_91.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_92.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_93.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_94.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_95.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_96.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_97.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_98.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/accumulators/form_99.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/alert.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/blank.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/callouts/1.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/callouts/10.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/callouts/11.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/callouts/12.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/callouts/13.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/callouts/14.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/callouts/15.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/callouts/2.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/callouts/3.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/callouts/4.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/callouts/5.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/callouts/6.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/callouts/7.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/callouts/8.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/callouts/9.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/caution.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/draft.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/home.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/important.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/next.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/next_disabled.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/note.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/prev.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/prev_disabled.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/smiley.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/tip.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/toc-blank.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/toc-minus.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/toc-plus.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/up.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/up_disabled.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/images/warning.png
==============================================================================
Binary file. No diff available.

Added: sandbox/task/libs/task/doc/html/index.html
==============================================================================
--- (empty file)
+++ sandbox/task/libs/task/doc/html/index.html 2009-06-01 08:13:01 EDT (Mon, 01 Jun 2009)
@@ -0,0 +1,278 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>Chapter 1. Boost.Task</title>
+<link rel="stylesheet" href="boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.75.0">
+<link rel="home" href="index.html" title="Chapter 1. Boost.Task">
+<link rel="next" href="boost_task/motivation.html" title="Motivation">
+</head>
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<table cellpadding="2" width="100%"><tr>
+<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../boost.png"></td>
+<td align="center">Home</td>
+<td align="center">Libraries</td>
+<td align="center">People</td>
+<td align="center">FAQ</td>
+<td align="center">More</td>
+</tr></table>
+<hr>
+<div class="spirit-nav"><a accesskey="n" href="boost_task/motivation.html"><img src="../../doc/html/images/next.png" alt="Next"></a></div>
+<div class="chapter" title="Chapter 1. Boost.Task">
+<div class="titlepage"><div>
+<div><h2 class="title">
+<a name="boost_task"></a>Chapter 1. Boost.Task</h2></div>
+<div><div class="author"><h3 class="author">
+<span class="firstname">Oliver</span> <span class="surname">Kowalke</span>
+</h3></div></div>
+<div><p class="copyright">Copyright © 2009 Oliver Kowalke</p></div>
+<div><div class="legalnotice" title="Legal Notice">
+<a name="id530548"></a><p>
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ </p>
+</div></div>
+</div></div>
+<div class="toc">
+<p><b>Table of Contents</b></p>
+<dl>
+<dt><span class="section"> Overview</span></dt>
+<dt><span class="section"> Motivation</span></dt>
+<dt><span class="section"> Task</span></dt>
+<dt><span class="section"> Handle</span></dt>
+<dt><span class="section"> Execute in own thread</span></dt>
+<dt><span class="section"> Execute in new thread</span></dt>
+<dt><span class="section"> Thread-pool</span></dt>
+<dd><dl>
+<dt><span class="section"> Static thread-pool</span></dt>
+<dt><span class="section"> Channel</span></dt>
+<dt><span class="section"> Scheduling</span></dt>
+<dt><span class="section"> Pool shutdown</span></dt>
+<dt><span class="section"> Default pool</span></dt>
+<dt><span class="section"> Processor binding</span></dt>
+<dt><span class="section"> Work-Stealing</span></dt>
+<dt><span class="section"> Fork/Join</span></dt>
+</dl></dd>
+<dt><span class="section"> Execute as sub-task</span></dt>
+<dt><span class="section"> Utilities</span></dt>
+<dt><span class="section"> Meta functions</span></dt>
+<dt><span class="section"> Reference</span></dt>
+<dd><dl>
+<dt><span class="section"> Class template task</span></dt>
+<dt><span class="section"> Class template handle</span></dt>
+<dt><span class="section"> Function async()</span></dt>
+<dt><span class="section"> Class own_thread</span></dt>
+<dt><span class="section"> Class new_thread</span></dt>
+<dt><span class="section"> Class template static_pool</span></dt>
+<dt><span class="section"> Utilities</span></dt>
+<dt><span class="section"> Meta function has_attribute</span></dt>
+<dt><span class="section"><a href="boost_task/reference.html#boost_task.reference.attribute_type"> Meta function
+ <code class="computeroutput"><span class="identifier">attribute_type</span></code></a></span></dt>
+<dt><span class="section"> Class invalid_poolsize</span></dt>
+<dt><span class="section"> Class invalid_scanns</span></dt>
+<dt><span class="section"> Class invalid_timeduration</span></dt>
+<dt><span class="section"> Class invalid_watermark</span></dt>
+<dt><span class="section"> Class task_rejected</span></dt>
+<dt><span class="section"> Class poolsize</span></dt>
+<dt><span class="section"> Class high_watermark</span></dt>
+<dt><span class="section"> Class low_watermark</span></dt>
+<dt><span class="section"> Class scanns</span></dt>
+</dl></dd>
+<dt><span class="section">Appendices</span></dt>
+<dd><dl>
+<dt><span class="section"> Appendix A: Future development</span></dt>
+<dt><span class="section"><a href="boost_task/appendices.html#boost_task.appendices.acknowledgements"> Appendix B:
+ Acknowledgments</a></span></dt>
+</dl></dd>
+</dl>
+</div>
+<div class="section" title="Overview">
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="boost_task.overview"></a><a class="link" href="index.html#boost_task.overview" title="Overview"> Overview</a>
+</h2></div></div></div>
+<p>
+ <span class="bold"><strong>Boost.Task</strong></span> provides an framework for parallel
+ execution of tasks (a task is a small unit of code that can be executed independently).
+ </p>
+<div class="itemizedlist"><ul class="itemizedlist" type="disc">
+<li class="listitem">
+<code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">task</span></code>, <span class="emphasis"><em>callable</em></span> representing
+ a fine-grained work-item:
+ <div class="itemizedlist"><ul class="itemizedlist" type="circle">
+<li class="listitem">
+<code class="computeroutput"><span class="identifier">get_id</span><span class="special">()</span></code>
+ returning an identifier
+ </li>
+<li class="listitem">
+<code class="computeroutput"><span class="keyword">operator</span><span class="special">()()</span></code>
+ to execute the fine-grained work-item
+ </li>
+<li class="listitem">
+<code class="computeroutput"><span class="identifier">get_future</span><span class="special">()</span></code>
+ providing an <span class="emphasis"><em>asynchronous-completion-token</em></span> in order
+ to pass the result (values, exceptions) back to initiator
+ </li>
+</ul></div>
+</li>
+<li class="listitem">
+<code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">handle</span></code>, <span class="emphasis"><em>asynchronous-completion-token</em></span>
+ of the asynchronously executed task:
+ <div class="itemizedlist"><ul class="itemizedlist" type="circle">
+<li class="listitem">
+<code class="computeroutput"><span class="identifier">get_id</span><span class="special">()</span></code>
+ for identifying associated task
+ </li>
+<li class="listitem">
+<code class="computeroutput"><span class="identifier">interrupt</span><span class="special">()</span></code>,
+ interrupt_and_wait() allow to cancel an cooperative task
+ </li>
+<li class="listitem">
+ interface of <span class="emphasis"><em>asynchronous-completion-token</em></span>:
+ <div class="itemizedlist"><ul class="itemizedlist" type="square">
+<li class="listitem">
+<code class="computeroutput"><span class="identifier">get</span><span class="special">()</span></code>
+ retrieve value or exception of task execution
+ </li>
+<li class="listitem">
+<code class="computeroutput"><span class="identifier">is_ready</span><span class="special">()</span></code>
+ test if task was executed
+ </li>
+<li class="listitem">
+<code class="computeroutput"><span class="identifier">wait</span><span class="special">()</span></code>,
+ <code class="computeroutput"><span class="identifier">wait_for</span><span class="special">()</span></code>
+ and <code class="computeroutput"><span class="identifier">wait_until</span><span class="special">()</span></code>
+ block until task is executed and the result is set
+ </li>
+</ul></div>
+</li>
+</ul></div>
+</li>
+<li class="listitem">
+<code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">async</span><span class="special">()</span></code>,
+ executes a task on behalf of <span class="emphasis"><em>asynchronous-executors</em></span>
+</li>
+<li class="listitem">
+<span class="emphasis"><em>asynchronous-executor</em></span> models:
+ <div class="itemizedlist"><ul class="itemizedlist" type="circle">
+<li class="listitem">
+<code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">own_thread</span></code>: executes task in current
+ thread.
+ </li>
+<li class="listitem">
+<code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">new_thread</span></code>: executes task in a newly
+ created thread (thread will be destroyed after)
+ </li>
+<li class="listitem">
+<code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">default_pool</span></code>: task gets executed by
+ a <span class="emphasis"><em>worker-thread</em></span> of the default <span class="emphasis"><em>thread-pool</em></span>
+</li>
+<li class="listitem">
+<code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">task</span><span class="special">::</span><span class="identifier">as_sub_task</span></code>: executes task in newly
+ created thread or in a pool of <span class="emphasis"><em>worker-threads</em></span> depending
+ on whether current task is already executed in a pool
+ </li>
+<li class="listitem">
+ custom pool: task gets executed by a <span class="emphasis"><em>worker-thread</em></span>
+ of a custom <span class="emphasis"><em>thread-pool</em></span>
+</li>
+</ul></div>
+</li>
+</ul></div>
+<p>
+ References
+ </p>
+<div class="itemizedlist"><ul class="itemizedlist" type="disc">
+<li class="listitem">
+ N2185: Proposed Text for Parallel Task Execution http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2185.html
+ written by Peter Dimov.
+ </li>
+<li class="listitem">
+ N2276: Thread Pools and Futures http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2276.html
+ written by Anthony Williams.
+ </li>
+<li class="listitem">
+ N2802: A plea to reconsider detach-on-destruction for thread objects http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2802.html
+ written by Hans-J. Boehm.
+ </li>
+<li class="listitem">
+'Sutter’s Mill' by
+ Herb Sutter
+ </li>
+<li class="listitem">
+ mailing list of C++ standard committee's Library Working Group
+ </li>
+</ul></div>
+<div class="note" title="Note"><table border="0" summary="Note">
+<tr>
+<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../doc/html/images/note.png"></td>
+<th align="left">Note</th>
+</tr>
+<tr><td align="left" valign="top"><p>
+ <span class="bold"><strong>Boost.Task</strong></span> uses Boost.Future from Anthony Williams (will be
+ integrated in some of the next releases of Boost.Thread).
+ </p></td></tr>
+</table></div>
+<p>
+ In order to use the classes and functions described here, you can either include
+ the specific headers specified by the descriptions of each class or function,
+ or include the master library header:
+ </p>
+<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">task</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
+</pre>
+<p>
+ which includes all the other headers in turn.
+ </p>
+<a name="boost_task.overview.tested_platforms"></a><h4>
+<a name="id563818"></a>
+ <a class="link" href="index.html#boost_task.overview.tested_platforms">Tested Platforms</a>
+ </h4>
+<p>
+ <span class="bold"><strong>Boost.Task</strong></span> has been tested on the following
+ platforms and compilers:
+ </p>
+<div class="itemizedlist"><ul class="itemizedlist" type="disc">
+<li class="listitem">
+ Debian GNU/Linux 2.6.29.2 (x86_64), GCC 4.3.3
+ </li>
+<li class="listitem">
+ Ubuntu GNU/Linux 2.6.28.11 (x86), GCC 4.3.3
+ </li>
+<li class="listitem">
+ FreeBSD 7.2 (x86), GCC 4.2.1
+ </li>
+<li class="listitem">
+ OpenSolaris 0811 (x86_64), SunCC 5.10
+ </li>
+<li class="listitem">
+ Windows XP Professional (x86), MSVC 9.0
+ </li>
+</ul></div>
+<a name="boost_task.overview.how_to_build"></a><h4>
+<a name="id563862"></a>
+ <a class="link" href="index.html#boost_task.overview.how_to_build">How to build</a>
+ </h4>
+<div class="itemizedlist"><ul class="itemizedlist" type="disc">
+<li class="listitem">
+ download the sources form boost-vault
+ (section <span class="emphasis"><em>Concurrent Programing</em></span>) or boost-sandbox
+</li>
+<li class="listitem">
+ extract the archive into the boost-source directory
+ </li>
+<li class="listitem">
+ change directory to &lt;boost-source&gt;/libs/task/build
+ </li>
+<li class="listitem">
+ call <code class="computeroutput"><span class="identifier">bjam</span> <span class="identifier">toolset</span><span class="special">=&lt;</span><span class="identifier">compiler</span><span class="special">-</span><span class="identifier">name</span><span class="special">&gt;</span></code>
+</li>
+</ul></div>
+</div>
+</div>
+<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
+<td align="left"><p><small>Last revised: June 01, 2009 at 12:11:54 GMT</small></p></td>
+<td align="right"><div class="copyright-footer"></div></td>
+</tr></table>
+<hr>
+<div class="spirit-nav"><a accesskey="n" href="boost_task/motivation.html"><img src="../../doc/html/images/next.png" alt="Next"></a></div>
+</body>
+</html>

Added: sandbox/task/libs/task/doc/html/minimal.css
==============================================================================
--- (empty file)
+++ sandbox/task/libs/task/doc/html/minimal.css 2009-06-01 08:13:01 EDT (Mon, 01 Jun 2009)
@@ -0,0 +1,29 @@
+/*
+
+ © Copyright Beman Dawes, 2007
+
+ Distributed under the Boost Software License, Version 1.0.
+ See www.boost.org/LICENSE_1_0.txt
+
+*/
+
+/*******************************************************************************
+ Body
+*******************************************************************************/
+
+body { font-family: sans-serif; margin: 1em; }
+
+/*******************************************************************************
+ Table
+*******************************************************************************/
+
+table { margin: 0.5em; }
+
+/*******************************************************************************
+ Font sizes
+*******************************************************************************/
+
+p, td, li, blockquote { font-size: 10pt; }
+pre { font-size: 9pt; }
+
+/*** end ***/
\ No newline at end of file

Added: sandbox/task/libs/task/doc/html/reference.css
==============================================================================
--- (empty file)
+++ sandbox/task/libs/task/doc/html/reference.css 2009-06-01 08:13:01 EDT (Mon, 01 Jun 2009)
@@ -0,0 +1,11 @@
+/*============================================================================
+ Copyright 2003-2004 Douglas Gregor
+ Distributed under the Boost Software License, Version 1.0. (See accompany-
+ ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+============================================================================*/
+
+PRE.synopsis {
+ background-color: #e0ffff;
+ border: thin solid blue;
+ padding: 1em
+}
\ No newline at end of file

Modified: sandbox/task/libs/task/doc/introduction.qbk
==============================================================================
--- sandbox/task/libs/task/doc/introduction.qbk (original)
+++ sandbox/task/libs/task/doc/introduction.qbk 2009-06-01 08:13:01 EDT (Mon, 01 Jun 2009)
@@ -9,20 +9,22 @@
 [section:motivation Motivation]
 
 To speed-up computer-bound work and/or increase the computation-throughput is a common motivation for parallelizing a program.
-Especially for interactive applications that have to process user input while performing some background tasks responsivness is very important.
-Parallelizing a program requires partitioning the program into smaller chunks that can run in parallel. The code can scale as the hardware
-gets better without changing the code.
+Especially for interactive applications that have to process user input while performing some background tasks responsivness iss
+very important.
+Parallelizing a program requires partitioning the program into smaller chunks that can run in parallel. The code can scale as the
+hardware gets better without changing the code.
 
 The evolution from one-core to many-core architectures and the usage of threads (of course processes fit too) support this paradigm.
 
 [note
   ["You can have multithreading on a single core machine, but you can only have parallelism on a multi core machine ... .] -- Daniel Moth
- [footnote more to read at Daniel's [@http://www.danielmoth.com/Blog/2008/11/threadingconcurrency-vs-parallelism.html [blog]]]
+ [footnote more to read at Daniel's [@http://www.danielmoth.com/Blog/2008/11/threadingconcurrency-vs-parallelism.html blog]]
 ]
 
-__boost_task__ provides a framework to utilize the available hardware and provide a way for efficient asynchronous processing of time consuming operations.
-The framework provides some link_ae[__aes__], like __new_thread__, in order to execute the task asynchronously in another execution context (__boost_task__
-uses preemptible threads for this purpose).
+__boost_task__ provides a framework to utilize the available hardware and provide a way for efficient asynchronous processing of
+time consuming operations.
+The framework provides some __aes__, like __new_thread__, in order to execute the task asynchronously in another execution
+context (__boost_task__ uses preemptible threads for this purpose).
 
 ``
         void print( std::string const& msg)
@@ -30,16 +32,16 @@
 
         void main()
         {
- boost::task::async( // dispatchs task
- boost::task::new_thread(), // asynchronous executor
- boost::task::make_task( // task, to be executed asynchronously
+ boost::task::async( // dispatchs task
+ boost::task::new_thread(), // asynchronous executor
+ boost::task::make_task( // task, to be executed asynchronously
                                 print,
                                 "Hello World!") ) );
         }
 ``
 
-In order to manage the task __assync__ returns a handle __handle__ (associated with the submitted task). It functions as a __act__ - that means it transfers
-the result of the execution back to the caller thread.
+In order to manage the task __fn_async__ returns a handle __handle__ (associated with the submitted task). It functions as a __act__ -
+that means it transfers the result of the execution back to the caller thread.
 
 ``
         std::string echo( std::string const& msg)
@@ -57,7 +59,7 @@
         }
 ``
 
-The task can also be interrupted via __handle__ if it is a so-called link_coop_task[__coop_task__].
+The task can also be interrupted via __handle__ if it is a so-called [link_task __coop_task__].
 
 ``
         void long_running( boost::posix_time::time_duration const& rel_time)
@@ -76,8 +78,9 @@
         }
 ``
 
-Beside __new_thread__ (which creates a new task for each submitted task) __boost_task__ provides link_pool[__thread_pools__] to prevent the overhead of thread creation
-and destruction for each task. __default_pool__ submitts the tasks to the default __thread_pool__ which contains a fixed number of pre-spawned __worker_threads__ (custom __thread_pools__ are supported too).
+Beside __new_thread__ (which creates a new task for each submitted task) __boost_task__ provides [link_pool __thread_pools__]
+to prevent the overhead of thread creation and destruction for each task. __default_pool__ submitts the tasks to the default
+__thread_pool__ which contains a fixed number of pre-spawned __worker_threads__ (custom __thread_pools__ are supported too).
 
 ``
         long serial_fib( long n)
@@ -124,9 +127,9 @@
 ``
 
 With function __fn_runs_in_pool__ a task can detect if it is executed inside a __thread_pool__.
-__sub_tasks__ arecreated by __as_sub_task__. Where the __sub_task__ is executed by a new thread if the parent task
-is not executed inside a __thread_pool__. In the other case the __sub_task__ is put into the local __worker_queue__
-which enables link_work_stealing[__work_stealing__] and link_forkjoin[inline execution] of tasks.
+__sub_tasks__ arecreated by __as_sub_task__. Where the __sub_task__ is executed by a new thread if the parent task is not
+executed inside a __thread_pool__. In the other case the __sub_task__ is put into the local __worker_queue__ which enables
+[link_work_stealing __work_stealing__] and [link_forkjoin inline execution] of tasks.
 
 ``
         boost::task::async(

Modified: sandbox/task/libs/task/doc/meta_functions.qbk
==============================================================================
--- sandbox/task/libs/task/doc/meta_functions.qbk (original)
+++ sandbox/task/libs/task/doc/meta_functions.qbk 2009-06-01 08:13:01 EDT (Mon, 01 Jun 2009)
@@ -8,7 +8,8 @@
 
 [section:meta_functions Meta functions]
 
-If the __thread_pool__ supports attributes (like priorities) __hase_attribute__ evaluates to `true` at compile-time (derived from boost::mpl::bool_). The type of the attribute is determined by __attribute_type__.
+If the __thread_pool__ supports attributes (like priorities) __has_attribute__ evaluates to `true` at compile-time (derived from
+boost::mpl::bool_). The type of the attribute is determined by __attribute_type__.
 
 
 ``

Modified: sandbox/task/libs/task/doc/new_thread.qbk
==============================================================================
--- sandbox/task/libs/task/doc/new_thread.qbk (original)
+++ sandbox/task/libs/task/doc/new_thread.qbk 2009-06-01 08:13:01 EDT (Mon, 01 Jun 2009)
@@ -6,13 +6,15 @@
 ]
 
 
-[section:new_thread __new_thread__]
+[section:new_thread Execute in new thread]
 
-_new_thread__ creates a new __thread__ and executes the task in this thread (asynchronous). The created thread gets joined by handle.
+__new_thread__ creates a new __thread__ and executes the task in this thread (asynchronous). The created thread gets joined by
+handle (so [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2802.html N2802] should be addressed).
+
+[caution Always store the returned __act__ in a variable because __handle__ joins the thread in its destructor (if the last
+reference gets out of scope). ]
 
-[caution Always store the returned __act__ in a variable because __handle__ joins the thread in its destructor (if the last reference gets out of scope). ]
 
-The topic of [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2802.html N2802] should be addressed.
 
 ``
         long fibonacci( long n)
@@ -42,18 +44,19 @@
 ``
 
 
-In the example below both `a_function` and `another_function` are executed synchron (see link_own_thread[__own_thread__] for synchronous execution)!
+In the example below both `a_function()` and `another_function()` are executed synchron (see [link_own_thread __own_thread__]
+for synchronous execution)!
 
 ``
- boost::task::async(
- boost::task::new_thread(),
- boost::task::make_task(
- a_function) ) );
-
- boost::task::async(
- boost::task::new_thread(),
- boost::task::make_task(
- another_function) ) );
+ boost::task::async(
+ boost::task::new_thread(),
+ boost::task::make_task(
+ a_function) ) );
+
+ boost::task::async(
+ boost::task::new_thread(),
+ boost::task::make_task(
+ another_function) ) );
 ``
 
 [endsect]

Modified: sandbox/task/libs/task/doc/overview.qbk
==============================================================================
--- sandbox/task/libs/task/doc/overview.qbk (original)
+++ sandbox/task/libs/task/doc/overview.qbk 2009-06-01 08:13:01 EDT (Mon, 01 Jun 2009)
@@ -16,14 +16,14 @@
         * __fn_get_future__ providing an __act__ in order to pass the result (values, exceptions) back to initiator
 
 * __handle__, __act__ of the asynchronously executed task:
- * __fn_get_id__ for identifying associated __task__
- * __fn_interrupt__, interrupt_and_wait() allow to cancel an coop_task_link[cooperative task]
+ * __fn_get_id__ for identifying associated task
+ * __fn_interrupt__, interrupt_and_wait() allow to cancel an cooperative task
         * interface of __act__:
                 * __fn_get__ retrieve value or exception of task execution
                 * __fn_is_ready__ test if task was executed
- * __fn_wait__, wait_for() and wait_until() block until task is executed and the result is set
+ * __fn_wait__, __fn_wait_for__ and __fn_wait_until__ block until task is executed and the result is set
 
-* __async__, executes a task on behalf of __aes__
+* __fn_async__, executes a task on behalf of __aes__
 
 * __ae__ models:
         * __own_thread__: executes task in current thread.
@@ -41,11 +41,11 @@
 
 * N2802: A plea to reconsider detach-on-destruction for thread objects [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2802.html] written by Hans-J. Boehm.
 
-* mailing list of C++ standard committee's Library Working Group
-
 * [@http://herbsutter.wordpress.com 'Sutter’s Mill'] by Herb Sutter
 
-[note __boost_task__ uses __boost_future__ from Anthony Williams (will be integrated in some of the next releases of __boost__thread__).]
+* mailing list of C++ standard committee's Library Working Group
+
+[note __boost_task__ uses __boost_future__ from Anthony Williams (will be integrated in some of the next releases of __boost_thread__).]
 
 In order to use the classes and functions described here, you can either include the specific headers specified by the descriptions of each class or function,
 or include the master library header:
@@ -56,21 +56,23 @@
 
 
 [heading Tested Platforms]
+
 __boost_task__ has been tested on the following platforms and compilers:
 
 * Debian GNU/Linux 2.6.29.2 (x86_64), GCC 4.3.3
 * Ubuntu GNU/Linux 2.6.28.11 (x86), GCC 4.3.3
-* FreeBSD 7.2 (x86), GCC 4.2.1 (requires static boost libs for tests)
+* FreeBSD 7.2 (x86), GCC 4.2.1
 * OpenSolaris 0811 (x86_64), SunCC 5.10
 * Windows XP Professional (x86), MSVC 9.0
 
 
 [heading How to build]
-* define environment variable BOOST_BUILD_PATH pointing to the source directory of __boost__
-* extract archive of __boost_task__
-* call bjam in the directory of __boost_task__
 
+* download the sources form [@http://www.boostpro.com/vault/index.php boost-vault] (section ['Concurrent Programing]) or
+[@https://svn.boost.org/svn/boost/sandbox/task/ boost-sandbox]
+* extract the archive into the boost-source directory
+* change directory to <boost-source>/libs/task/build
+* call `bjam toolset=<compiler-name>`
 
-[include introduction.qbk]
 
 [endsect]

Modified: sandbox/task/libs/task/doc/own_thread.qbk
==============================================================================
--- sandbox/task/libs/task/doc/own_thread.qbk (original)
+++ sandbox/task/libs/task/doc/own_thread.qbk 2009-06-01 08:13:01 EDT (Mon, 01 Jun 2009)
@@ -6,7 +6,7 @@
 ]
 
 
-[section:own_thread __own_thread__]
+[section:own_thread Execute in own thread]
 
 __own_thread__ executes the task in the current thread (synchronous execution - concerns of [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2802.html N2802] do not aply).
 

Modified: sandbox/task/libs/task/doc/pool.qbk
==============================================================================
--- sandbox/task/libs/task/doc/pool.qbk (original)
+++ sandbox/task/libs/task/doc/pool.qbk 2009-06-01 08:13:01 EDT (Mon, 01 Jun 2009)
@@ -6,9 +6,11 @@
 ]
 
 
-[section:pool Thread pool]
+[section:pool Thread-pool]
 
-Instead of creating a new thread and quickly throwing it away after the task is done, the overhead related to thread creation and destruction can be avoided by running the __work_items__ on a __thread_pool__ (reusing an existing __worker__thread__ instead).
+Instead of creating a new thread and quickly throwing it away after the task is done, the overhead related to thread
+creation and destruction can be avoided by running the __work_items__ on a __thread_pool__ (reusing an existing
+__worker_thread__ instead).
 
 A __thread_pool__ maintains a queue (or queues) of __work_items__ to be done, and a pool of __worker_threads__ which execute __work_items__ from the queue(s).
 
@@ -57,8 +59,8 @@
 ``
 .
 
-[important __tasks__ should not be too small (performance overhead dominates) and avoid blocking
-__tasks__[footnote see [@http://www.ddj.com/go-parallel/article/showArticle.jhtml?articleID=216500409
+[important Tasks should not be too small (performance overhead dominates) and avoid blocking
+tasks[footnote see [@http://www.ddj.com/go-parallel/article/showArticle.jhtml?articleID=216500409
 'Use Thread Pools Correctly'], Herb Sutter].]
 
 [include static_pool.qbk]

Modified: sandbox/task/libs/task/doc/processor_binding.qbk
==============================================================================
--- sandbox/task/libs/task/doc/processor_binding.qbk (original)
+++ sandbox/task/libs/task/doc/processor_binding.qbk 2009-06-01 08:13:01 EDT (Mon, 01 Jun 2009)
@@ -18,7 +18,7 @@
 
 The constructor takes additional arguments for the link_work_stealing[work-stealing algorithm] and link_channel[high-] and link_channel[low-watermark] too.
 
-[note __boost_task__ does only provide this feature for Windows, Linux, AIX, HP-UX and Solaris.]
+[note __boost_task__ does provide this feature only for Windows, Linux, AIX, HP-UX and Solaris.]
 
 
 [endsect]

Modified: sandbox/task/libs/task/doc/ref_async.qbk
==============================================================================
--- sandbox/task/libs/task/doc/ref_async.qbk (original)
+++ sandbox/task/libs/task/doc/ref_async.qbk 2009-06-01 08:13:01 EDT (Mon, 01 Jun 2009)
@@ -6,7 +6,7 @@
 ]
 
 
-[section::async Function `async()`]
+[section:async Function `async()`]
 
 [section:async_default Templated non-member function `async( AE, task< R >)`]
 

Modified: sandbox/task/libs/task/doc/ref_task.qbk
==============================================================================
--- sandbox/task/libs/task/doc/ref_task.qbk (original)
+++ sandbox/task/libs/task/doc/ref_task.qbk 2009-06-01 08:13:01 EDT (Mon, 01 Jun 2009)
@@ -72,7 +72,7 @@
 [endsect]
 
 
-[section:operator() Member function `operator()()`]
+[section:operator Member function `operator()()`]
 
         void operator()()
 

Modified: sandbox/task/libs/task/doc/scheduler.qbk
==============================================================================
--- sandbox/task/libs/task/doc/scheduler.qbk (original)
+++ sandbox/task/libs/task/doc/scheduler.qbk 2009-06-01 08:13:01 EDT (Mon, 01 Jun 2009)
@@ -8,7 +8,7 @@
 
 [section:scheduling Scheduling]
 
-The scheduling policy determines how __tasks__ are scheduled inside the __channel__.
+The scheduling policy determines how tasks are scheduled inside the __channel__.
 
 
 [heading fifo]
@@ -37,8 +37,9 @@
                 3); // priority is 3
 ``
 
-In this example the __tasks__ get scheduled by the assigned integer (third argument of __fn_async__). The __task__ with the lowest priority
-gets scheduled first (taken by a __worker_thread__). The ordering can be changed by the second argument of __priority__ (the default is `std::less< Attr >`).
+In this example the tasks get scheduled by the assigned integer (third argument of __fn_async__). The __task__ with the
+lowest priority gets scheduled first (taken by a __worker_thread__). The ordering can be changed by the second argument
+of __priority__ (the default is `std::less< Attr >`).
 
 ``
         boost::task::static_pool<
@@ -51,18 +52,11 @@
 
 [heading smart]
 
-Each inserted __task__ is associated with an attribute. The scheduler gets an put- and take-policy
-as template arguments. The corresponding policy gets applied for each insertion and removal.
+Each inserted __task__ is associated with an attribute. The scheduler gets an put- and take-policy as template arguments.
+The corresponding policy gets applied for each insertion and removal.
 
-__boost_task__ provides __replace_oldest__ as put- policy and __take_oldest__ as take-policy.
-Both policies allow the replacement of older (pending) __tasks__ in the scheduler by new ones.
-
- // creates a pool with unbounded channel
- // tasks are processed depending on the associated attributed
- // oldest tasks with the same attributed pending in the channel
- // will be replaced by the new task
- // this example would execute add( 1, 2) and add( 5, 6)
- // add( 2, 3) is removed (if pending when add( 5, 6) is submitted)
+__boost_task__ provides __replace_oldest__ as put- policy and __take_oldest__ as take-policy. Both policies allow the
+replacement of older (pending) tasks in the scheduler by new ones.
 
 ``
         long fibonacci_fn( long n)

Modified: sandbox/task/libs/task/doc/shutdown.qbk
==============================================================================
--- sandbox/task/libs/task/doc/shutdown.qbk (original)
+++ sandbox/task/libs/task/doc/shutdown.qbk 2009-06-01 08:13:01 EDT (Mon, 01 Jun 2009)
@@ -8,14 +8,14 @@
 
 [section:pool_shutdown Pool shutdown]
 
-__boost_task__ allows to shutdown a __thread_pool__ explicitly via functions __fn_shutdown__ and __fn_shutdown_now__.
-The destructor of the pool calls __fn_shutdown__ if not already done so that all __worker_threads__ are joined and the topic of
+__boost_task__ allows to shutdown a __thread_pool__ explicitly via functions __fn_shutdown__ and __fn_shutdown_now__. The
+destructor of the pool calls __fn_shutdown__ if not already done so that all __worker_threads__ are joined and the topic of
 [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2802.html N2802] should be addressed.
 
 [heading Shutdown]
 
-If __fn_shutdown__ is called - the the pool is set the closed state and all __worker_threads__ are joined until all pending __tasks__ are processed.
-No futher __tasks__ can be submitted.
+If __fn_shutdown__ is called - the the pool is set the closed state and all __worker_threads__ are joined until all pending tasks are processed.
+No futher tasks can be submitted.
 
 [note The deconstructor calls __fn_shutdown__ if the pool was not shutdown yet.]
 
@@ -67,7 +67,7 @@
 
 [heading Shutdown immediatly]
 
-The function __fn_shutdown_now__ closes the pool, interrupts and then joins all __worker_threads__. Pending __tasks__ are unprocessed.
+The function __fn_shutdown_now__ closes the pool, interrupts and then joins all __worker_threads__. Pending tasks are unprocessed.
 
 
 ``

Modified: sandbox/task/libs/task/doc/static_pool.qbk
==============================================================================
--- sandbox/task/libs/task/doc/static_pool.qbk (original)
+++ sandbox/task/libs/task/doc/static_pool.qbk 2009-06-01 08:13:01 EDT (Mon, 01 Jun 2009)
@@ -6,7 +6,7 @@
 ]
 
 
-[section:static_pool __static_pool__]
+[section:static_pool Static thread-pool]
 
 __boost_task__ provides __static_pool__ - which contains an fixed set of pre-forked __worker_threads__ (the size of the pool doesn't change during its lifetime).
 
@@ -24,17 +24,18 @@
 
 
 The first argument of the constructor specifies how many __worker_threads__ the pool will contain. The second
-and third argument are used by the link_work_stealing[__work_stealing__] algorithm.
+and third argument are used by the [link_work_stealing __work_stealing__] algorithm.
 
-[note If __bounded_channel__ is used as queuing policy the constructor has two additional arguments (link_channel[hight- and lower-watermark]). ]
+[note If __bounded_channel__ is used as queuing policy the constructor has two additional arguments . ]
 
-__static_pool__ provides functionality to check the status of the pool - __fn_closed__ returns true when the pool was shutdown and __fn_active__ as well as __fn__idle__ returning how many __worker_threads__
-are active (executing a task) or idle. The size of the pool can be accessed over __fn_size__.
+__static_pool__ provides functionality to check the status of the pool - __fn_closed__ returns true when the pool was
+shutdown and __fn_active__ as well as __fn_idle__ returning how many __worker_threads__ are active (executing a task) or idle.
+The size of the pool can be accessed over __fn_size__.
 
-For infomational pruposes __fn_empty__ and __fn_pending__ can be used in order to know if the global task-queue is empty or how many __tasks__ are waiting for execution.
-__fn_clear__ removes all __tasks__ from the global-queue.
+For infomational pruposes __fn_empty__ and __fn_pending__ can be used in order to know if the global task-queue is empty or
+how many tasks are waiting for execution. With __fn_clear__ all tasks are removed from the global-queue.
 
-[note __fn_pending__ does not count __tasks__ in the local-queues of the __worker_threads__.]
+[note __fn_pending__ does not count tasks in the local-queues of the __worker_threads__.]
 
 
 [endsect]

Modified: sandbox/task/libs/task/doc/task.qbk
==============================================================================
--- sandbox/task/libs/task/doc/task.qbk (original)
+++ sandbox/task/libs/task/doc/task.qbk 2009-06-01 08:13:01 EDT (Mon, 01 Jun 2009)
@@ -10,14 +10,16 @@
 
 A task is a chunk of code that can be executed independently.
 
-__task__ represents a __callable__ (provides __fn_operator__) object containing the unit of code to be execute by a link_ae[__ae__]. Function __fn_get_future__ returns a link_act[__act__] allowing to wait for the completion of the computation of the task, for getting the result of a computation or for transfering exceptions.
-Each __task__ has a unique identifier
+__task__ represents a __callable__ (provides __fn_operator__) object containing the unit of code to be execute by a __ae__.
+Function __fn_get_future__ returns a __act__ allowing to wait for the completion of the computation of the task, for
+getting the result of a computation or for transfering exceptions. Each __task__ has a unique identifier.
 
 
-[heading:create Creation]
+[heading Creation]
 
-__fn_make_task__ can be used to create __task__ by passing free-functions or member-functions of objects and its arguments: __fn_make_task__ accepts up to ten
-arguments per default (can be overriden by defining BOOST_TASK_MAKE_TASK_MAX_ARITY with the new value).
+__fn_make_task__ can be used to create __task__ by passing free-functions or member-functions of objects and its arguments:
+__fn_make_task__ accepts up to ten arguments per default (can be overriden by defining BOOST_TASK_MAKE_TASK_MAX_ARITY with
+the new value).
 
 * create task from free-function with arguments:
 
@@ -57,15 +59,15 @@
 ``
 
 
-[heading:cooperative Cooperative task amd interruption]
+[heading Cooperative task and interruption]
 
-Sometimes it is desired to stop a running task if it is no longer needed. In this case the thread is not killed -
-it stops only at well-defined points (__interruption__points__) its execution.
-In the context of task-interruption a task is known as cooperative if it checks for an interruption request between
-two __interruption__points__ via __fn__interruption_requested__
-[footnote see [@http://www.ddj.com/architect/207100682 'Interrupt Politely'], Herb Sutter].
+Sometimes it is desired to stop a running task if it is no longer needed. In this case the thread is not killed - it stops
+only at well-defined points (__interruption_points__) its execution.
+In the context of task-interruption a task is known as cooperative if it checks for an interruption request between two
+__interruption_points__ via __fn_interruption_requested__ [footnote see [@http://www.ddj.com/architect/207100682
+'Interrupt Politely'], Herb Sutter].
 
-__interruption__points__ are:
+__interruption_points__ are:
 
 * `boost::thread::join()`
 * `boost::thread::timed_join()`
@@ -77,7 +79,7 @@
 * `boost::this_thread::sleep()`
 * `boost::this_thread::interruption_point()`
 
-A __interruption__point__ throws __task_interrupted__ if an interruption was requested.
+A __interruption_point__ throws __task_interrupted__ if an interruption was requested.
 
 ``
         long cooperative( long n)
@@ -115,7 +117,7 @@
 ``
 
 
-[heading:exceptions Exceptions]
+[heading Exceptions]
 
 Exceptions thrown by __task__ are transported by the __act__.
 
@@ -163,10 +165,10 @@
 * `boost::broken_task`
 
 
-[heading:parent Parent-tasks]
+[heading Parent task]
 
 Top-level tasks have no parent. A parent task can create child tasks when it creates another task by using __as_sub_task__ as __ae__. These children are implicitly treated as __sub_tasks__ of the larger task. It is assumed that that __sub_tasks__ can be executed in any order because only overall operation
-speed matters (enabling strategies for fast execution of unordered __work_items__ as link_work_stealing[__work_stealing__]).
+speed matters (enabling strategies for fast execution of unordered __work_items__ as [link_work_stealing __work_stealing__]).
 
 ``
         long serial_fib( long n)

Modified: sandbox/task/libs/task/doc/todo.qbk
==============================================================================
--- sandbox/task/libs/task/doc/todo.qbk (original)
+++ sandbox/task/libs/task/doc/todo.qbk 2009-06-01 08:13:01 EDT (Mon, 01 Jun 2009)
@@ -6,38 +6,46 @@
 ]
 
 
-[section:todo Appendix C: Future development]
+[section:todo Appendix A: Future development]
 
 [heading Dynamic thread-pool]
 
-* __dynamic_pool__ adds or removes __worker_threads__ from the __thread_pool__ depending on the work-load (undersubscription/oversubscription).
+* __dynamic_pool__ adds or removes __worker_threads__ from the __thread_pool__ depending on the work-load (undersubscription/
+oversubscription).
 
 
 [heading Communication and synchronisation abstractions]
 
-* Event variable: A event variable is a bivalued variable (up/down) on which a task can wait for an event to be set or reset. The calling task will be suspended until the state of the event variable is that required by the caller.
+* [*Event variable]: A event variable is a bivalued variable (up/down) on which a task can wait for an event to be set or reset. The
+calling task will be suspended until the state of the event variable is that required by the caller.
 
-* Buffer: A bounded/unbounded buffer is shared between several tasks. The data must be placed in, and retrieved from, the buffer under mutual exclusion.
-Condition synchronisation is required because a calling task attempting to place data into the buffer. When the buffer is full, the task must be suspended until there is space int the buffer.
-Also a retrieving task must be suspended when the buffer is empty. The data, once read, is destroyed.
+* [*Buffer]: A bounded/unbounded buffer is shared between several tasks. The data must be placed in, and retrieved from, the buffer
+under mutual exclusion. Condition synchronisation is required because a calling task attempting to place data into the buffer. When
+the buffer is full, the task must be suspended until there is space int the buffer. Also a retrieving task must be suspended when
+the buffer is empty. The data, once read, is destroyed.
 
-* Multicast: The data is sent to a specific group of tasks and all tasks in the group should receive the data. Only when all tasks have received one item of data then another item is allowed to be transmitted.
+* [*Multicast]: The data is sent to a specific group of tasks and all tasks in the group should receive the data. Only when all tasks
+have received one item of data then another item is allowed to be transmitted.
 
-* Rendezvous: A rendezvous uses direct naming and synchronous communication between tasks. One task that executes its command first will be delayed until the other tasks is ready to rendezvous.
+* [*Rendezvous]: A rendezvous uses direct naming and synchronous communication between tasks. One task that executes its command first
+will be delayed until the other tasks is ready to rendezvous.
 
-* Protected resource: A protected resource is a passive entity that controls access to the internal states (to the controled real resources).
+* [*Protected resource]: A protected resource is a passive entity that controls access to the internal states (to the controled real
+resources).
 
-* Task groups: A task group defines a graph of interdependent tasks that can mostly be run in parallel. The tasks in the group have dependencies or communicate with each other.
+* [*Task groups]: A task group defines a graph of interdependent tasks that can mostly be run in parallel. The tasks in the group have
+dependencies or communicate with each other.
 
 
-[heading Support of explicit processor bindig]
+[heading Interdepended task]
 
-* __aes__ related to a __thread_pool__ (like __default__pool__) could support explicit processor binding.
+* With special support of concurrence and synchronisation abstractions interdepended tasks work in __thread_pools__ (using context
+switching/fibers).
 
 
-[heading Interdepended task]
+[heading Support of explicit processor bindig]
 
-* With special support of concurrence and synchronisation abstractions interdepended tasks work in __thread_pools__ (using context switching/fibers).
+* __aes__ related to a __thread_pool__ (like __default_pool__) could support explicit processor binding.
 
 
 [heading Optimizations]

Modified: sandbox/task/libs/task/doc/utilities.qbk
==============================================================================
--- sandbox/task/libs/task/doc/utilities.qbk (original)
+++ sandbox/task/libs/task/doc/utilities.qbk 2009-06-01 08:13:01 EDT (Mon, 01 Jun 2009)
@@ -14,15 +14,15 @@
 
 [heading reschedule_until]
 
-In the function `boost::this_task::reschedule_until( Pred const&)` allows to synchronize the task with other
-asynchronous events without blocking the __worker_threads__ (bool Pred::operator()() must not block).
-The current task will be rescheduled until the passed predicate becomes true.
+In the function `boost::this_task::reschedule_until( Pred const&)` allows to synchronize the task with other asynchronous events
+without blocking the __worker_threads__ (bool Pred::operator()() must not block). The current task will be rescheduled until the
+passed predicate becomes true.
 
 
 [heading get_pool]
 
-The pool in which the current code (__task__) is executed can be accessed via __fn_get_pool__. If hte code is not executed by
-a __worker_thread__ an assertion is raised.
+The pool in which the current code (__task__) is executed can be accessed via __fn_get_pool__. If hte code is not executed by a
+__worker_thread__ an assertion is raised.
 
 
 [heading runs_in_pool]

Modified: sandbox/task/libs/task/doc/work_stealing.qbk
==============================================================================
--- sandbox/task/libs/task/doc/work_stealing.qbk (original)
+++ sandbox/task/libs/task/doc/work_stealing.qbk 2009-06-01 08:13:01 EDT (Mon, 01 Jun 2009)
@@ -8,43 +8,44 @@
 
 [section:work_stealing Work-Stealing]
 
-The most important aspect of __work_stealing__ is that it enables fast enqueue and dequeue in the typical case, often requiring no synchronization at all. This virtually eliminates a large part of the overhead
-of QUWI, when working with child tasks. We still do need to allocate memory for the Task itself, and for the work-stealing queue, but like the improvements to the FIFO queue these data structures have been
-optimized for good GC performance. Parent tasks are fast; child tasks are much faster.
+Traditional __thread_pools__ do not scale because they use a single global-queue protected by a global-lock. The frequency at which
+__worker_threads__ aquire the global-lock becomes a limiting factor for the throughput if:
 
-Traditional __thread_pools__ do not scale because they use a single global-queue protected by a global-lock. The frequency at which __worker_threads__ aquire the global-lock becomes
-a limiting factor for the throughput if:
-
-* the __tasks__ become smaller
+* the tasks become smaller
 
 * more processors are added
 
 
-A __work_stealing__ algorithm can be used to solve this problem. It uses a special kind of queue which has two ends, and allows lock-free pushes and pops from the ['private end]
-(accessed by the __worker_thread__ owning the queue), but requires synchronization from the ['public end] (accessed by the other __worker_threads__). Synchronization is necessary
-when the queue is sufficiently small that private and public operations could conflict.
-
-The pool contains one global-queue (__bounded_channel__ or __unbounded_channel__) protected by a global-lock and each __worker_thread__ has its own private local worker-queue.
-If work is enqueued by a __worker_thread__ the __action__ is stored in the worker queue. If the work is enqueued by a application thread it goes into the global queue. When
-__worker_threads__ are looking for work, they have following search order:
+A __work_stealing__ algorithm can be used to solve this problem. It uses a special kind of queue which has two ends, and allows
+lock-free pushes and pops from the ['private end] (accessed by the __worker_thread__ owning the queue), but requires synchronization
+from the ['public end] (accessed by the other __worker_threads__). Synchronization is necessary when the queue is sufficiently small
+that private and public operations could conflict.
+
+The pool contains one global-queue (__bounded_channel__ or __unbounded_channel__) protected by a global-lock and each __worker_thread__
+has its own private local worker-queue. If work is enqueued by a __worker_thread__ the __task__ is stored in the worker queue. If the
+work is enqueued by a application thread it goes into the global queue. When __worker_threads__ are looking for work, they have
+following search order:
 
-* look into the private worker-queue - __tasks__ can be dequeued without locks
+* look into the private worker-queue - tasks can be dequeued without locks
 
 * look in the global-queue - locks are used for synchronization
 
-* check other worker-queues ('stealing' __tasks__ from private worker queues of other __worker_threads__) - requires locks
+* check other worker-queues ('stealing' tasks from private worker queues of other __worker_threads__) - requires locks
 
 
-For a lot of recursively queued __tasks__ (so called __sub_tasks__), the use of a worker-queue per thread substantially reduces the synchronization necessary to complete the work. There are also fewer
-cache effects due to sharing of the global-queue information.
+For a lot of recursively queued tasks (so called __sub_tasks__), the use of a worker-queue per thread substantially reduces the
+synchronization necessary to complete the work. There are also fewer cache effects due to sharing of the global-queue information.
 
-Operations on the private worker queue are executed in LIFO order and operations on worker queues of other __worker_threads__ in FIFO order (steals).
+Operations on the private worker queue are executed in LIFO order and operations on worker queues of other __worker_threads__ in
+FIFO order (steals).
 
-* There are chances that memory is still hot in the cache, if the __tasks__ are pushed in LIFO order into the private worker queue.
+* There are chances that memory is still hot in the cache, if the tasks are pushed in LIFO order into the private worker queue.
 
-* If a __worker_thread__ steals work in FIFO order, increases the chances that a larger 'chunk' of work will be stolen (the need for other steals will be possibly reduced).
- Because the __sub_tasks__ are stored in LIFO order, the oldest items are closer to the ['public end] of the queue (forming a tree). Stealing such an older __task__ also steals
- a (probably) larger subtree of __tasks__ unfolded if the stolen work item get executed. Since a __sub_task__ is just part of a larger __task__, we don’t need to worry about execution order.
+* If a __worker_thread__ steals work in FIFO order, increases the chances that a larger 'chunk' of work will be stolen (the need
+for other steals will be possibly reduced). Because the __sub_tasks__ are stored in LIFO order, the oldest items are closer to the
+['public end] of the queue (forming a tree). Stealing such an older __task__ also steals a (probably) larger subtree of tasks
+unfolded if the stolen work item get executed. Since a __sub_task__ is just part of a larger __task__, we don’t need to worry about
+execution order.
 
 
 [endsect]


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