Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > ba6e5e1a033bd8535c43a771ce407926 > files > 255

lib64cxx-gtk-utils2.2-devel-2.2.3-2.mga4.x86_64.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.4"/>
<title>c++-gtk-utils: Cgu::Thread::TaskManager Class Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">c++-gtk-utils
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.4 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="annotated.html"><span>Class&#160;List</span></a></li>
      <li><a href="classes.html"><span>Class&#160;Index</span></a></li>
      <li><a href="hierarchy.html"><span>Class&#160;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&#160;Members</span></a></li>
    </ul>
  </div>
<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="namespaceCgu.html">Cgu</a></li><li class="navelem"><a class="el" href="namespaceCgu_1_1Thread.html">Thread</a></li><li class="navelem"><a class="el" href="classCgu_1_1Thread_1_1TaskManager.html">TaskManager</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#nested-classes">Classes</a> &#124;
<a href="#pub-types">Public Types</a> &#124;
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="classCgu_1_1Thread_1_1TaskManager-members.html">List of all members</a>  </div>
  <div class="headertitle">
<div class="title">Cgu::Thread::TaskManager Class Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p>A thread-pool class for managing tasks in multi-threaded programs.  
 <a href="classCgu_1_1Thread_1_1TaskManager.html#details">More...</a></p>

<p><code>#include &lt;<a class="el" href="task__manager_8h_source.html">c++-gtk-utils/task_manager.h</a>&gt;</code></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="nested-classes"></a>
Classes</h2></td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">class &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCgu_1_1Thread_1_1TaskManager_1_1IncHandle.html">IncHandle</a></td></tr>
<tr class="memdesc:"><td class="mdescLeft">&#160;</td><td class="mdescRight">A scoped handle for exception safe incrementing of the maximum number of threads that a <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> object will run.  <a href="classCgu_1_1Thread_1_1TaskManager_1_1IncHandle.html#details">More...</a><br/></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-types"></a>
Public Types</h2></td></tr>
<tr class="memitem:a59de02521dda7778da29462c6d41fc7b"><td class="memItemLeft" align="right" valign="top">enum &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a59de02521dda7778da29462c6d41fc7b">StopMode</a> { <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a59de02521dda7778da29462c6d41fc7ba47b71b9315a0d8ecc2941701bfb0e281">wait_for_running</a>, 
<a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a59de02521dda7778da29462c6d41fc7ba35a4e1e7bfe28bc85a044956369695f1">wait_for_all</a>
 }</td></tr>
<tr class="separator:a59de02521dda7778da29462c6d41fc7b"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:ad91848481798c638210a0527a7608121"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#ad91848481798c638210a0527a7608121">TaskManager</a> (const <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html">TaskManager</a> &amp;)=delete</td></tr>
<tr class="separator:ad91848481798c638210a0527a7608121"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a15186bab37f22c8c72cea5f582f27efe"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classCgu_1_1Thread_1_1TaskManager.html">TaskManager</a> &amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a15186bab37f22c8c72cea5f582f27efe">operator=</a> (const <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html">TaskManager</a> &amp;)=delete</td></tr>
<tr class="separator:a15186bab37f22c8c72cea5f582f27efe"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a84f6a3ccb91012f4d2faaf968744a819"><td class="memItemLeft" align="right" valign="top">unsigned int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a84f6a3ccb91012f4d2faaf968744a819">get_max_threads</a> () const </td></tr>
<tr class="separator:a84f6a3ccb91012f4d2faaf968744a819"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:acd4031c041c0a32e6435e6ab3783bb3d"><td class="memItemLeft" align="right" valign="top">unsigned int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#acd4031c041c0a32e6435e6ab3783bb3d">get_min_threads</a> () const </td></tr>
<tr class="separator:acd4031c041c0a32e6435e6ab3783bb3d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a66d6c80cef1ff5c6a9973c3c934fe04d"><td class="memItemLeft" align="right" valign="top">unsigned int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a66d6c80cef1ff5c6a9973c3c934fe04d">get_used_threads</a> () const </td></tr>
<tr class="separator:a66d6c80cef1ff5c6a9973c3c934fe04d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af0222421e7d28608d3133c907c9e7498"><td class="memItemLeft" align="right" valign="top">unsigned int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#af0222421e7d28608d3133c907c9e7498">get_tasks</a> () const </td></tr>
<tr class="separator:af0222421e7d28608d3133c907c9e7498"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aa5b0225d7acd9c5b6e2f8de39bc711e3"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#aa5b0225d7acd9c5b6e2f8de39bc711e3">set_max_threads</a> (unsigned int max)</td></tr>
<tr class="separator:aa5b0225d7acd9c5b6e2f8de39bc711e3"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ad47297562ee0c838da1242335745d31b"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#ad47297562ee0c838da1242335745d31b">change_max_threads</a> (int delta)</td></tr>
<tr class="separator:ad47297562ee0c838da1242335745d31b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a0a53c8cd0e5c55607252f689b64bdd3d"><td class="memItemLeft" align="right" valign="top">unsigned int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a0a53c8cd0e5c55607252f689b64bdd3d">get_idle_time</a> () const </td></tr>
<tr class="separator:a0a53c8cd0e5c55607252f689b64bdd3d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ae4d3d2a1c68e58bbc51037a970194ec4"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#ae4d3d2a1c68e58bbc51037a970194ec4">set_idle_time</a> (unsigned int idle)</td></tr>
<tr class="separator:ae4d3d2a1c68e58bbc51037a970194ec4"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a6f8ecca4db902ef74c9ca60308cb5c4f"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a6f8ecca4db902ef74c9ca60308cb5c4f">get_blocking</a> () const </td></tr>
<tr class="separator:a6f8ecca4db902ef74c9ca60308cb5c4f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ae4530426fed068208df577ca8eea669f"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#ae4530426fed068208df577ca8eea669f">set_blocking</a> (bool blocking)</td></tr>
<tr class="separator:ae4530426fed068208df577ca8eea669f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a57b9f166750852902d20e4dcda69efd0"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a59de02521dda7778da29462c6d41fc7b">StopMode</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a57b9f166750852902d20e4dcda69efd0">get_stop_mode</a> () const </td></tr>
<tr class="separator:a57b9f166750852902d20e4dcda69efd0"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a410ccc3699dee4e297fd74e1aad7e72d"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a410ccc3699dee4e297fd74e1aad7e72d">set_stop_mode</a> (<a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a59de02521dda7778da29462c6d41fc7b">StopMode</a> mode)</td></tr>
<tr class="separator:a410ccc3699dee4e297fd74e1aad7e72d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ae61908c1fb1973f7ce66ab6ae308fe02"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#ae61908c1fb1973f7ce66ab6ae308fe02">stop_all</a> ()</td></tr>
<tr class="separator:ae61908c1fb1973f7ce66ab6ae308fe02"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a81f7c8af3295d92c0e19d7f9498a4078"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a81f7c8af3295d92c0e19d7f9498a4078">add_task</a> (const <a class="el" href="namespaceCgu_1_1Callback.html#ab0fdf0ebb22f2a7cc813657f6d90a94d">Callback::Callback</a> *task)</td></tr>
<tr class="separator:a81f7c8af3295d92c0e19d7f9498a4078"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ac5e226b3a2d6ec05bceeeadb21afd34e"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#ac5e226b3a2d6ec05bceeeadb21afd34e">add_task</a> (std::unique_ptr&lt; const <a class="el" href="namespaceCgu_1_1Callback.html#ab0fdf0ebb22f2a7cc813657f6d90a94d">Callback::Callback</a> &gt; task, std::unique_ptr&lt; const <a class="el" href="namespaceCgu_1_1Callback.html#ab0fdf0ebb22f2a7cc813657f6d90a94d">Callback::Callback</a> &gt; fail)</td></tr>
<tr class="separator:ac5e226b3a2d6ec05bceeeadb21afd34e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a880e5b950eacc1debb44e5bab896a157"><td class="memTemplParams" colspan="2">template&lt;class Task , class  = typename std::enable_if&lt;!std::is_convertible&lt;typename std::remove_reference&lt;Task&gt;::type,	    							 const Callback::Callback*&gt;::value&gt;::type&gt; </td></tr>
<tr class="memitem:a880e5b950eacc1debb44e5bab896a157"><td class="memTemplItemLeft" align="right" valign="top">void&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a880e5b950eacc1debb44e5bab896a157">add_task</a> (Task &amp;&amp;task)</td></tr>
<tr class="separator:a880e5b950eacc1debb44e5bab896a157"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a46e6937dad229a7e48b635735715535f"><td class="memTemplParams" colspan="2">template&lt;class Task , class Fail , class  = typename std::enable_if&lt;!std::is_convertible&lt;Task, std::unique_ptr&lt;const Callback::Callback&gt;&gt;::value	    				    &amp;&amp; !std::is_convertible&lt;Fail, std::unique_ptr&lt;const Callback::Callback&gt;&gt;::value&gt;::type&gt; </td></tr>
<tr class="memitem:a46e6937dad229a7e48b635735715535f"><td class="memTemplItemLeft" align="right" valign="top">void&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a46e6937dad229a7e48b635735715535f">add_task</a> (Task &amp;&amp;task, Fail &amp;&amp;fail)</td></tr>
<tr class="separator:a46e6937dad229a7e48b635735715535f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a2ac8ae63abc1a6b433f40e861d39ca33"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a2ac8ae63abc1a6b433f40e861d39ca33">is_error</a> () const </td></tr>
<tr class="separator:a2ac8ae63abc1a6b433f40e861d39ca33"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a50dfd5cfa77b1e6b4645c4bd46ce7dd0"><td class="memTemplParams" colspan="2">template&lt;class Ret , class... Params, class... Args, class T &gt; </td></tr>
<tr class="memitem:a50dfd5cfa77b1e6b4645c4bd46ce7dd0"><td class="memTemplItemLeft" align="right" valign="top"><a class="el" href="classCgu_1_1SharedLockPtr.html">Cgu::SharedLockPtr</a><br class="typebreak"/>
&lt; <a class="el" href="classCgu_1_1AsyncResult.html">Cgu::AsyncResult</a>&lt; Ret &gt; &gt;&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a50dfd5cfa77b1e6b4645c4bd46ce7dd0">make_task_result</a> (T &amp;t, Ret(T::*func)(Params...), Args &amp;&amp;...args)</td></tr>
<tr class="separator:a50dfd5cfa77b1e6b4645c4bd46ce7dd0"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:abe374ca418bbe53e6c5228ecc1b6a3ac"><td class="memTemplParams" colspan="2">template&lt;class Ret , class... Params, class... Args, class T &gt; </td></tr>
<tr class="memitem:abe374ca418bbe53e6c5228ecc1b6a3ac"><td class="memTemplItemLeft" align="right" valign="top">void&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#abe374ca418bbe53e6c5228ecc1b6a3ac">make_task_when_full</a> (std::unique_ptr&lt; const <a class="el" href="classCgu_1_1Callback_1_1CallbackArg.html">Cgu::Callback::CallbackArg</a>&lt; const Ret &amp; &gt;&gt; when, <a class="el" href="classCgu_1_1Releaser.html">Cgu::Releaser</a> *when_releaser, std::unique_ptr&lt; const <a class="el" href="namespaceCgu_1_1Callback.html#ab0fdf0ebb22f2a7cc813657f6d90a94d">Cgu::Callback::Callback</a> &gt; fail, <a class="el" href="classCgu_1_1Releaser.html">Cgu::Releaser</a> *fail_releaser, gint priority, GMainContext *context, T &amp;t, Ret(T::*func)(Params...), Args &amp;&amp;...args)</td></tr>
<tr class="separator:abe374ca418bbe53e6c5228ecc1b6a3ac"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a7a013fd7b21096fa76e39cbe5475d31b"><td class="memTemplParams" colspan="2">template&lt;class Ret , class... Params, class... Args, class T &gt; </td></tr>
<tr class="memitem:a7a013fd7b21096fa76e39cbe5475d31b"><td class="memTemplItemLeft" align="right" valign="top">void&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a7a013fd7b21096fa76e39cbe5475d31b">make_task_when</a> (std::unique_ptr&lt; const <a class="el" href="classCgu_1_1Callback_1_1CallbackArg.html">Cgu::Callback::CallbackArg</a>&lt; const Ret &amp; &gt;&gt; when, GMainContext *context, T &amp;t, Ret(T::*func)(Params...), Args &amp;&amp;...args)</td></tr>
<tr class="separator:a7a013fd7b21096fa76e39cbe5475d31b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a1e8f15778414096e0baa024a30e3445f"><td class="memTemplParams" colspan="2">template&lt;class Ret , class... Params, class... Args, class T &gt; </td></tr>
<tr class="memitem:a1e8f15778414096e0baa024a30e3445f"><td class="memTemplItemLeft" align="right" valign="top"><a class="el" href="classCgu_1_1SharedLockPtr.html">Cgu::SharedLockPtr</a><br class="typebreak"/>
&lt; <a class="el" href="classCgu_1_1AsyncResult.html">Cgu::AsyncResult</a>&lt; Ret &gt; &gt;&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a1e8f15778414096e0baa024a30e3445f">make_task_result</a> (const T &amp;t, Ret(T::*func)(Params...) const, Args &amp;&amp;...args)</td></tr>
<tr class="separator:a1e8f15778414096e0baa024a30e3445f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aa1b4550cfd9edfac22fb85d51ab1037a"><td class="memTemplParams" colspan="2">template&lt;class Ret , class... Params, class... Args, class T &gt; </td></tr>
<tr class="memitem:aa1b4550cfd9edfac22fb85d51ab1037a"><td class="memTemplItemLeft" align="right" valign="top">void&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#aa1b4550cfd9edfac22fb85d51ab1037a">make_task_when_full</a> (std::unique_ptr&lt; const <a class="el" href="classCgu_1_1Callback_1_1CallbackArg.html">Cgu::Callback::CallbackArg</a>&lt; const Ret &amp; &gt;&gt; when, <a class="el" href="classCgu_1_1Releaser.html">Cgu::Releaser</a> *when_releaser, std::unique_ptr&lt; const <a class="el" href="namespaceCgu_1_1Callback.html#ab0fdf0ebb22f2a7cc813657f6d90a94d">Cgu::Callback::Callback</a> &gt; fail, <a class="el" href="classCgu_1_1Releaser.html">Cgu::Releaser</a> *fail_releaser, gint priority, GMainContext *context, const T &amp;t, Ret(T::*func)(Params...) const, Args &amp;&amp;...args)</td></tr>
<tr class="separator:aa1b4550cfd9edfac22fb85d51ab1037a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a6bde1cd838159ded5a432d5753997242"><td class="memTemplParams" colspan="2">template&lt;class Ret , class... Params, class... Args, class T &gt; </td></tr>
<tr class="memitem:a6bde1cd838159ded5a432d5753997242"><td class="memTemplItemLeft" align="right" valign="top">void&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a6bde1cd838159ded5a432d5753997242">make_task_when</a> (std::unique_ptr&lt; const <a class="el" href="classCgu_1_1Callback_1_1CallbackArg.html">Cgu::Callback::CallbackArg</a>&lt; const Ret &amp; &gt;&gt; when, GMainContext *context, const T &amp;t, Ret(T::*func)(Params...) const, Args &amp;&amp;...args)</td></tr>
<tr class="separator:a6bde1cd838159ded5a432d5753997242"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a5e8ffae7635f0265fb6874d583e87890"><td class="memTemplParams" colspan="2">template&lt;class Ret , class... Params, class... Args&gt; </td></tr>
<tr class="memitem:a5e8ffae7635f0265fb6874d583e87890"><td class="memTemplItemLeft" align="right" valign="top"><a class="el" href="classCgu_1_1SharedLockPtr.html">Cgu::SharedLockPtr</a><br class="typebreak"/>
&lt; <a class="el" href="classCgu_1_1AsyncResult.html">Cgu::AsyncResult</a>&lt; Ret &gt; &gt;&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a5e8ffae7635f0265fb6874d583e87890">make_task_result</a> (Ret(*func)(Params...), Args &amp;&amp;...args)</td></tr>
<tr class="separator:a5e8ffae7635f0265fb6874d583e87890"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aa919ec0a43b078b12a1b2d04028c3bdb"><td class="memTemplParams" colspan="2">template&lt;class Ret , class... Params, class... Args&gt; </td></tr>
<tr class="memitem:aa919ec0a43b078b12a1b2d04028c3bdb"><td class="memTemplItemLeft" align="right" valign="top">void&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#aa919ec0a43b078b12a1b2d04028c3bdb">make_task_when_full</a> (std::unique_ptr&lt; const <a class="el" href="classCgu_1_1Callback_1_1CallbackArg.html">Cgu::Callback::CallbackArg</a>&lt; const Ret &amp; &gt;&gt; when, <a class="el" href="classCgu_1_1Releaser.html">Cgu::Releaser</a> *when_releaser, std::unique_ptr&lt; const <a class="el" href="namespaceCgu_1_1Callback.html#ab0fdf0ebb22f2a7cc813657f6d90a94d">Cgu::Callback::Callback</a> &gt; fail, <a class="el" href="classCgu_1_1Releaser.html">Cgu::Releaser</a> *fail_releaser, gint priority, GMainContext *context, Ret(*func)(Params...), Args &amp;&amp;...args)</td></tr>
<tr class="separator:aa919ec0a43b078b12a1b2d04028c3bdb"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a397a8391bd656fd9d7c115866c474475"><td class="memTemplParams" colspan="2">template&lt;class Ret , class... Params, class... Args&gt; </td></tr>
<tr class="memitem:a397a8391bd656fd9d7c115866c474475"><td class="memTemplItemLeft" align="right" valign="top">void&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a397a8391bd656fd9d7c115866c474475">make_task_when</a> (std::unique_ptr&lt; const <a class="el" href="classCgu_1_1Callback_1_1CallbackArg.html">Cgu::Callback::CallbackArg</a>&lt; const Ret &amp; &gt;&gt; when, GMainContext *context, Ret(*func)(Params...), Args &amp;&amp;...args)</td></tr>
<tr class="separator:a397a8391bd656fd9d7c115866c474475"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:acc60f7fa8af2062cb2200eb3fead0fac"><td class="memTemplParams" colspan="2">template&lt;class Ret , class Func &gt; </td></tr>
<tr class="memitem:acc60f7fa8af2062cb2200eb3fead0fac"><td class="memTemplItemLeft" align="right" valign="top"><a class="el" href="classCgu_1_1SharedLockPtr.html">Cgu::SharedLockPtr</a><br class="typebreak"/>
&lt; <a class="el" href="classCgu_1_1AsyncResult.html">Cgu::AsyncResult</a>&lt; Ret &gt; &gt;&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#acc60f7fa8af2062cb2200eb3fead0fac">make_task_result</a> (Func &amp;&amp;f)</td></tr>
<tr class="separator:acc60f7fa8af2062cb2200eb3fead0fac"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a242d56aceb8ce247a9d033915b7d9401"><td class="memTemplParams" colspan="2">template&lt;class Ret , class Func &gt; </td></tr>
<tr class="memitem:a242d56aceb8ce247a9d033915b7d9401"><td class="memTemplItemLeft" align="right" valign="top">void&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a242d56aceb8ce247a9d033915b7d9401">make_task_when_full</a> (std::unique_ptr&lt; const <a class="el" href="classCgu_1_1Callback_1_1CallbackArg.html">Cgu::Callback::CallbackArg</a>&lt; const Ret &amp; &gt;&gt; when, <a class="el" href="classCgu_1_1Releaser.html">Cgu::Releaser</a> *when_releaser, std::unique_ptr&lt; const <a class="el" href="namespaceCgu_1_1Callback.html#ab0fdf0ebb22f2a7cc813657f6d90a94d">Cgu::Callback::Callback</a> &gt; fail, <a class="el" href="classCgu_1_1Releaser.html">Cgu::Releaser</a> *fail_releaser, gint priority, GMainContext *context, Func &amp;&amp;func)</td></tr>
<tr class="separator:a242d56aceb8ce247a9d033915b7d9401"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a7af7bc37424d6072cd374e840eb90fec"><td class="memTemplParams" colspan="2">template&lt;class When , class Fail , class Func , class  = typename std::enable_if&lt;!std::is_convertible&lt;When, std::unique_ptr&lt;const Callback::CallbackArg&lt;const typename std::result_of&lt;Func()&gt;::type&amp;&gt;&gt;&gt;::value  	    				    &amp;&amp; !std::is_convertible&lt;Fail, std::unique_ptr&lt;const Callback::Callback&gt;&gt;::value&gt;::type&gt; </td></tr>
<tr class="memitem:a7af7bc37424d6072cd374e840eb90fec"><td class="memTemplItemLeft" align="right" valign="top">void&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a7af7bc37424d6072cd374e840eb90fec">make_task_when_full</a> (When &amp;&amp;when, <a class="el" href="classCgu_1_1Releaser.html">Cgu::Releaser</a> *when_releaser, Fail &amp;&amp;fail, <a class="el" href="classCgu_1_1Releaser.html">Cgu::Releaser</a> *fail_releaser, gint priority, GMainContext *context, Func &amp;&amp;func)</td></tr>
<tr class="separator:a7af7bc37424d6072cd374e840eb90fec"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af7d7406d487e71d3954b295c4bd2518d"><td class="memTemplParams" colspan="2">template&lt;class Ret , class Func &gt; </td></tr>
<tr class="memitem:af7d7406d487e71d3954b295c4bd2518d"><td class="memTemplItemLeft" align="right" valign="top">void&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#af7d7406d487e71d3954b295c4bd2518d">make_task_when</a> (std::unique_ptr&lt; const <a class="el" href="classCgu_1_1Callback_1_1CallbackArg.html">Cgu::Callback::CallbackArg</a>&lt; const Ret &amp; &gt;&gt; when, GMainContext *context, Func &amp;&amp;f)</td></tr>
<tr class="separator:af7d7406d487e71d3954b295c4bd2518d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a5ebba2ecf246b24c3406aa60585ae523"><td class="memTemplParams" colspan="2">template&lt;class When , class Func , class  = typename std::enable_if&lt;!std::is_convertible&lt;When, std::unique_ptr&lt;const Callback::CallbackArg&lt;const typename std::result_of&lt;Func()&gt;::type&amp;&gt;&gt;&gt;::value&gt;::type&gt; </td></tr>
<tr class="memitem:a5ebba2ecf246b24c3406aa60585ae523"><td class="memTemplItemLeft" align="right" valign="top">void&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a5ebba2ecf246b24c3406aa60585ae523">make_task_when</a> (When &amp;&amp;when, GMainContext *context, Func &amp;&amp;func)</td></tr>
<tr class="separator:a5ebba2ecf246b24c3406aa60585ae523"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a8ebf8f3fb5d9622d5369005c9dd7a14b"><td class="memTemplParams" colspan="2">template&lt;class Ret , class Func &gt; </td></tr>
<tr class="memitem:a8ebf8f3fb5d9622d5369005c9dd7a14b"><td class="memTemplItemLeft" align="right" valign="top">void&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a8ebf8f3fb5d9622d5369005c9dd7a14b">make_task_compose</a> (Func &amp;&amp;f, GMainContext *context, std::unique_ptr&lt; const <a class="el" href="classCgu_1_1Callback_1_1CallbackArg.html">Cgu::Callback::CallbackArg</a>&lt; const Ret &amp; &gt;&gt; when)</td></tr>
<tr class="separator:a8ebf8f3fb5d9622d5369005c9dd7a14b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a4846175781716487569bb632dd69cef1"><td class="memTemplParams" colspan="2">template&lt;class Func , class When , class  = typename std::enable_if&lt;!std::is_convertible&lt;When, std::unique_ptr&lt;const Callback::CallbackArg&lt;const typename std::result_of&lt;Func()&gt;::type&amp;&gt;&gt;&gt;::value&gt;::type&gt; </td></tr>
<tr class="memitem:a4846175781716487569bb632dd69cef1"><td class="memTemplItemLeft" align="right" valign="top">void&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a4846175781716487569bb632dd69cef1">make_task_compose</a> (Func &amp;&amp;func, GMainContext *context, When &amp;&amp;when)</td></tr>
<tr class="separator:a4846175781716487569bb632dd69cef1"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a35b136845550d876aa9e6d0283c7ee48"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a35b136845550d876aa9e6d0283c7ee48">TaskManager</a> (unsigned int max=8, unsigned int min=0, unsigned int idle=10000, bool blocking=true, <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a59de02521dda7778da29462c6d41fc7b">StopMode</a> mode=<a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a59de02521dda7778da29462c6d41fc7ba35a4e1e7bfe28bc85a044956369695f1">TaskManager::wait_for_all</a>)</td></tr>
<tr class="separator:a35b136845550d876aa9e6d0283c7ee48"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a6166504700635802b42be065be21aacc"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a6166504700635802b42be065be21aacc">~TaskManager</a> ()</td></tr>
<tr class="separator:a6166504700635802b42be065be21aacc"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>A thread-pool class for managing tasks in multi-threaded programs. </p>
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="classCgu_1_1Thread_1_1Future.html" title="A class representing a pthread thread which will provide a value. ">Cgu::Thread::Future</a> <a class="el" href="classCgu_1_1AsyncResult.html" title="A thread-safe asynchronous result class. ">Cgu::AsyncResult</a> <a class="el" href="classCgu_1_1AsyncQueueDispatch.html" title="A thread-safe asynchronous queue with a blocking pop() method. ">Cgu::AsyncQueueDispatch</a> <a class="el" href="namespaceCgu_1_1Callback.html#ab8a459b25b1dba52fd43015c694bab1d">Cgu::Callback::post()</a> <a class="el" href="classCgu_1_1Thread_1_1TaskManager_1_1IncHandle.html" title="A scoped handle for exception safe incrementing of the maximum number of threads that a TaskManager o...">Cgu::Thread::TaskManager::IncHandle</a> <a class="el" href="namespaceCgu_1_1Thread.html#a984bbff1392b7e173a8b3ad081e542c2">Cgu::Thread::parallel_for_each()</a> <a class="el" href="namespaceCgu_1_1Thread.html#a7a920c9b1ec2ee80e0c798204f1a5553">Cgu::Thread::parallel_for_each_partial()</a> <a class="el" href="namespaceCgu_1_1Thread.html#a497aa47446b79c87f1a404e11151a942">Cgu::Thread::parallel_transform()</a> <a class="el" href="namespaceCgu_1_1Thread.html#ad03d1d6f6b0718a0b63a850b05fae623">Cgu::Thread::parallel_transform_partial()</a></dd></dl>
<p><a class="el" href="classCgu_1_1Thread_1_1Future.html" title="A class representing a pthread thread which will provide a value. ">Cgu::Thread::Future</a> operates on the principle of there being one worker thread per task. In some cases however, it may be better to have a limited pool of worker threads executing a larger number of tasks. This class implements this approach via a thread pool.</p>
<p>One common approach for thread pools of this kind is to set the maximum number of threads to the number of cores, or some number less than the number of cores, available on the local machine. How that can be determined is system specific (on linux it can be obtained by, for example, counting the 'processor' fields in /proc/cpuinfo or by using sysconf with the glibc extension for _SC_NPROCESSORS_ONLN). From version 2.36, glib has a g_get_num_processors() function. From gcc-4.7, C++11's std::thread::hardware_concurrency() static member function is also available.</p>
<p>The most general way of creating a new task is to call <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a81f7c8af3295d92c0e19d7f9498a4078">TaskManager::add_task()</a> with a callable object (such as a lambda expression or the return value of std::bind) which returns void, although <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a81f7c8af3295d92c0e19d7f9498a4078">add_task()</a> will also take a <a class="el" href="namespaceCgu_1_1Callback.html#ab0fdf0ebb22f2a7cc813657f6d90a94d">Callback::Callback</a> object. Where the task needs to provide a result, two approaches can be adopted. First, the task callback can have a <a class="el" href="classCgu_1_1AsyncResult.html" title="A thread-safe asynchronous result class. ">Cgu::AsyncResult</a> object held by <a class="el" href="classCgu_1_1SharedLockPtr.html" title="This is a smart pointer for managing the lifetime of objects allocated on freestore, with a thread safe reference count. ">Cgu::SharedLockPtr</a> (or by std::shared_ptr having a thread safe reference count) bound to it. Alternatively, a task can provide a result asynchronously to a glib main loop by calling <a class="el" href="namespaceCgu_1_1Callback.html#ab8a459b25b1dba52fd43015c694bab1d">Cgu::Callback::post()</a> when it is ready to do so. The <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a50dfd5cfa77b1e6b4645c4bd46ce7dd0">TaskManager::make_task_result()</a>, <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a7a013fd7b21096fa76e39cbe5475d31b">TaskManager::make_task_when()</a>, <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#abe374ca418bbe53e6c5228ecc1b6a3ac">TaskManager::make_task_when_full()</a> and <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a8ebf8f3fb5d9622d5369005c9dd7a14b">TaskManager::make_task_compose()</a> convenience wrapper methods are provided which will set this up for you (including constructing appropriate task callbacks). This would normally be done by passing one of those functions a callable object which returns a value, such as a lambda expression or the return value of std::bind. Tasks can add other tasks, enabling the composition of an arbitrary number of tasks to obtain a final result.</p>
<p>Overloads of <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a50dfd5cfa77b1e6b4645c4bd46ce7dd0">TaskManager::make_task_result()</a>, <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a7a013fd7b21096fa76e39cbe5475d31b">TaskManager::make_task_when()</a> and <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#abe374ca418bbe53e6c5228ecc1b6a3ac">TaskManager::make_task_when_full()</a> (but not <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a8ebf8f3fb5d9622d5369005c9dd7a14b">TaskManager::make_task_compose()</a>) also exist which take a function pointer (or an object reference and member function pointer) to a function which returns a value, with bound arguments, but these are deprecated in the 2.2 series of the library as they offer little advantage over using std::bind. (Although deprecated, there is no plan to remove these functions as they are there and they work - the deprecation is in effect guidance.) These deprecated functions can take up to three bound arguments in the case of a non-static member function, and four bound arguments in the case of any other function. In the case of a non-static member function, the referenced object whose member function is to be called must remain in existence until the task has completed. The target function passed by pointer (or member function pointer) can take a reference to const argument, as a copy of the object to be passed to the argument is taken to avoid dangling references, but it cannot take a reference to non-const argument.</p>
<p>Copying of the return value of the target function or callable object represented by the task may take place when using <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a50dfd5cfa77b1e6b4645c4bd46ce7dd0">TaskManager::make_task_result()</a>, <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a7a013fd7b21096fa76e39cbe5475d31b">TaskManager::make_task_when()</a>, <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#abe374ca418bbe53e6c5228ecc1b6a3ac">TaskManager::make_task_when_full()</a> and <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a8ebf8f3fb5d9622d5369005c9dd7a14b">TaskManager::make_task_compose()</a>. When a task completes, the return value will be stored, either in a <a class="el" href="classCgu_1_1AsyncResult.html" title="A thread-safe asynchronous result class. ">Cgu::AsyncResult</a> object (if <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a50dfd5cfa77b1e6b4645c4bd46ce7dd0">TaskManager::make_task_result()</a> is called) or for the purposes of executing the 'when' callback in a glib main loop (if <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a7a013fd7b21096fa76e39cbe5475d31b">TaskManager::make_task_when()</a>, <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#abe374ca418bbe53e6c5228ecc1b6a3ac">TaskManager::make_task_when_full()</a> or <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a8ebf8f3fb5d9622d5369005c9dd7a14b">TaskManager::make_task_compose()</a> are called). This storage will therefore cause the return value type's assignment operator or copy constructor to be called once unless that type has a move assignment operator or move constructor, in which case a move operation will be made where possible. Note that a 'when' callback takes the stored return value by reference to const and so without any additional copying upon the 'when' callback being executed in the main loop.</p>
<p><a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> objects do not provide thread cancellation. <a class="el" href="classCgu_1_1Thread_1_1Thread.html" title="A class representing a pthread thread. ">Thread</a> cancellation is incompatible with the task-centred thread pool model. If task cancellation is wanted, use a <a class="el" href="classCgu_1_1Thread_1_1Future.html" title="A class representing a pthread thread which will provide a value. ">Cgu::Thread::Future</a> (or <a class="el" href="classCgu_1_1Thread_1_1Thread.html" title="A class representing a pthread thread. ">Cgu::Thread::Thread</a> or <a class="el" href="classCgu_1_1Thread_1_1JoinableHandle.html" title="A class wrapping a Thread::Thread object representing a joinable thread. ">Cgu::Thread::JoinableHandle</a>) object instead, and have a dedicated thread for the cancelable task.</p>
<p>If glib &lt; 2.32 is installed, g_thread_init() must be called before any <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> objects are constructed, which in turn means that with glib &lt; 2.32 <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> objects may not be constructed as static objects in global namespace (that is, before g_thread_init() has been called in the program).</p>
<p>Any exceptions which propagate from a task will be consumed to protect the <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> object, and to detect whether this has happened there is a version of the <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a81f7c8af3295d92c0e19d7f9498a4078">TaskManager::add_task()</a> method which takes a second argument comprising a 'fail' callback. If an exception propagates from the 'fail' callback that is also consumed and a g_critical() message issued. <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#abe374ca418bbe53e6c5228ecc1b6a3ac">TaskManager::make_task_when_full()</a> also provides for a 'fail' callback.</p>
<p>Tasks can be aborted by throwing <a class="el" href="classCgu_1_1Thread_1_1Exit.html" title="A class which can be thrown to terminate the throwing thread. ">Cgu::Thread::Exit</a> (as well as any other exception). Where a task is managed by a <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> object, throwing <a class="el" href="classCgu_1_1Thread_1_1Exit.html" title="A class which can be thrown to terminate the throwing thread. ">Cgu::Thread::Exit</a> will only terminate the task and not the thread on which it is running (and will cause the 'fail' callback to be executed, if there is one).</p>
<p>Any 'fail' callback passed to <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a81f7c8af3295d92c0e19d7f9498a4078">TaskManager::add_task()</a> or <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#abe374ca418bbe53e6c5228ecc1b6a3ac">TaskManager::make_task_when_full()</a> must be fully bound. Whilst a task can pass error status to the 'fail' callback via shared data bound to both the task and the 'fail' callback (held by, say, a <a class="el" href="classCgu_1_1SharedLockPtr.html" title="This is a smart pointer for managing the lifetime of objects allocated on freestore, with a thread safe reference count. ">SharedLockPtr</a> object), or a global error stack, 'fail' callbacks are generally best reserved for use with entirely unexpected exceptions, where the most reasonable course is to perform some orderly logging and shutdown. For handlable exceptions, in an asynchronous environment the best course is often to catch them and deal with them in the task itself and (where <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#abe374ca418bbe53e6c5228ecc1b6a3ac">TaskManager::make_task_when_full()</a>, <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a7a013fd7b21096fa76e39cbe5475d31b">TaskManager::make_task_when()</a> or <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a8ebf8f3fb5d9622d5369005c9dd7a14b">TaskManager::make_task_compose()</a> is employed) return a value of the task function's return type indicating no result.</p>
<p><a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> objects have no copy constructor or copy assignment operator, as copying them would have no obvious semantic meaning. Whilst swapping or moving <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> objects would be meaningful, this is not implemented either because it would require an additional internal lock to be thread safe, and the circumstances in which moving or swapping would be useful are limited. Where a move option is wanted, a <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> object can be constructed on free store and held by std::unique_ptr.</p>
<p>Here is a compilable example of the calculator class referred to in the documentation on the <a class="el" href="classCgu_1_1AsyncResult.html" title="A thread-safe asynchronous result class. ">AsyncResult</a> but which uses a <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> object so that the calculator class can run more than one thread to service its calculations, using <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a50dfd5cfa77b1e6b4645c4bd46ce7dd0">TaskManager::make_task_result()</a>:</p>
<div class="fragment"><div class="line"><span class="preprocessor">#include &lt;vector&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;numeric&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;ostream&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;iostream&gt;</span></div>
<div class="line"></div>
<div class="line"><span class="preprocessor">#include &lt;glib.h&gt;</span></div>
<div class="line"></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="task__manager_8h.html">c++-gtk-utils/task_manager.h</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="async__result_8h.html" title="This file provides a thread-safe asynchronous result class. ">c++-gtk-utils/async_result.h</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="shared__ptr_8h.html">c++-gtk-utils/shared_ptr.h</a>&gt;</span></div>
<div class="line"></div>
<div class="line"><span class="keyword">using namespace </span>Cgu;</div>
<div class="line"></div>
<div class="line"><span class="keyword">class </span>Calcs {</div>
<div class="line">  <a class="code" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">Thread::TaskManager</a> tm;</div>
<div class="line"><span class="keyword">public</span>:</div>
<div class="line">  <a class="code" href="classCgu_1_1SharedLockPtr.html" title="This is a smart pointer for managing the lifetime of objects allocated on freestore, with a thread safe reference count. ">SharedLockPtr&lt;AsyncResult&lt;double&gt;</a>&gt; mean(<span class="keyword">const</span> std::vector&lt;double&gt;&amp; nums) {</div>
<div class="line">    <span class="keywordflow">return</span> tm.make_task_result([=]() -&gt; <span class="keywordtype">double</span> {</div>
<div class="line">        <span class="keywordflow">if</span> (nums.empty()) <span class="keywordflow">return</span> 0.0;</div>
<div class="line">        <span class="keywordflow">return</span> std::accumulate(nums.begin(), nums.end(), 0.0)/nums.size();</div>
<div class="line">      });</div>
<div class="line">  }</div>
<div class="line"></div>
<div class="line">  <span class="comment">// ... other calculation methods here</span></div>
<div class="line">};</div>
<div class="line"></div>
<div class="line"><span class="keywordtype">int</span> main () {</div>
<div class="line"></div>
<div class="line">  g_thread_init(0);</div>
<div class="line">  Calcs calcs;</div>
<div class="line">  <span class="keyword">auto</span> res1 = calcs.mean({1, 2, 8, 0});</div>
<div class="line">  <span class="keyword">auto</span> res2 = calcs.mean({101, 53.7, 87, 1.2});</div>
<div class="line"></div>
<div class="line">  <span class="comment">// ... do something else</span></div>
<div class="line">  std::cout &lt;&lt; res1-&gt;get() &lt;&lt; std::endl;</div>
<div class="line">  std::cout &lt;&lt; res2-&gt;get() &lt;&lt; std::endl;</div>
<div class="line"></div>
<div class="line">}</div>
</div><!-- fragment --><p>Here is a reimplementation, using <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a7a013fd7b21096fa76e39cbe5475d31b">TaskManager::make_task_when()</a>, of the example using a get_primes() function given in the documentation for <a class="el" href="classCgu_1_1Thread_1_1Future.html" title="A class representing a pthread thread which will provide a value. ">Cgu::Thread::Future</a>: </p>
<div class="fragment"><div class="line">std::vector&lt;long&gt; get_primes(<span class="keywordtype">int</span> n); <span class="comment">// calculates the first n primes</span></div>
<div class="line"></div>
<div class="line"><span class="comment">// get the first 1,000 primes</span></div>
<div class="line"><span class="keyword">using namespace </span>Cgu;</div>
<div class="line"></div>
<div class="line"><a class="code" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">Thread::TaskManager</a> tm;</div>
<div class="line">tm.<a class="code" href="classCgu_1_1Thread_1_1TaskManager.html#a7a013fd7b21096fa76e39cbe5475d31b">make_task_when</a>([] (<span class="keyword">const</span> std::vector&lt;long&gt;&amp; result) {</div>
<div class="line">                    <span class="keywordflow">for</span> (<span class="keyword">const</span> <span class="keyword">auto</span>&amp; elt: result) {std::cout &lt;&lt; elt &lt;&lt; std::endl;}</div>
<div class="line">                  },</div>
<div class="line">                  0,                    <span class="comment">// default main loop context</span></div>
<div class="line">                  [] () {<span class="keywordflow">return</span> get_primes(1,000);});</div>
</div><!-- fragment --><p>Where a task running on a <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> object is to block, the <a class="el" href="classCgu_1_1Thread_1_1TaskManager_1_1IncHandle.html" title="A scoped handle for exception safe incrementing of the maximum number of threads that a TaskManager o...">TaskManager::IncHandle</a> scoped handle class can be used to increment the maximum number of threads running on the object's thread pool temporarily while blocking takes place, so as to enable another thread to keep a core active. This can be useful where a task is to 'join' on another task when composing tasks. Here is a compilable example:</p>
<div class="fragment"><div class="line"><span class="preprocessor">#include &lt;iostream&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;ostream&gt;</span></div>
<div class="line"></div>
<div class="line"><span class="preprocessor">#include &lt;glib.h&gt;</span></div>
<div class="line"></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="task__manager_8h.html">c++-gtk-utils/task_manager.h</a>&gt;</span></div>
<div class="line"></div>
<div class="line"><span class="keyword">using namespace </span>Cgu;</div>
<div class="line"></div>
<div class="line"><span class="comment">// simulate a blocking operation, say from a server, with g_usleep()</span></div>
<div class="line"><span class="keywordtype">int</span> mult(<span class="keywordtype">int</span> x, <span class="keywordtype">int</span> y) {</div>
<div class="line">  g_usleep(100000);</div>
<div class="line">  <span class="keywordflow">return</span> x * y;</div>
<div class="line">}</div>
<div class="line"></div>
<div class="line"><span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span>* argv[]) {</div>
<div class="line"></div>
<div class="line">  g_thread_init(0);</div>
<div class="line">  <a class="code" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">Thread::TaskManager</a> tm{1}; <span class="comment">// only one core available unless blocking!</span></div>
<div class="line">  GMainLoop* loop = g_main_loop_new(0, <span class="keyword">true</span>);</div>
<div class="line"></div>
<div class="line">  tm.make_task_when(</div>
<div class="line">    [loop] (<span class="keyword">const</span> <span class="keywordtype">int</span>&amp; res) {</div>
<div class="line">      std::cout &lt;&lt; res &lt;&lt; std::endl;</div>
<div class="line">      g_main_loop_quit(loop);</div>
<div class="line">    },</div>
<div class="line">    0, <span class="comment">// default main loop</span></div>
<div class="line">    [&amp;tm] () -&gt; <span class="keywordtype">int</span> {</div>
<div class="line">      <span class="comment">// this task multiplies &#39;a&#39; by 2 and &#39;b&#39; by 3, and adds the products </span></div>
<div class="line">      <span class="keywordtype">int</span> a = 10;</div>
<div class="line">      <span class="keywordtype">int</span> b = 12;</div>
<div class="line"></div>
<div class="line">      <span class="comment">// increment maximum thread count before launching sub-task and</span></div>
<div class="line">      <span class="comment">// then blocking</span></div>
<div class="line">      <a class="code" href="classCgu_1_1Thread_1_1TaskManager_1_1IncHandle.html" title="A scoped handle for exception safe incrementing of the maximum number of threads that a TaskManager o...">Thread::TaskManager::IncHandle</a> h{tm};</div>
<div class="line">      <span class="comment">// start a sub-task</span></div>
<div class="line">      <span class="keyword">auto</span> sub = tm.make_task_result([a, &amp;tm] () -&gt; <span class="keywordtype">int</span> {</div>
<div class="line">        <span class="comment">// increment maximum thread count again before blocking in</span></div>
<div class="line">        <span class="comment">// this task (pretend that some other task in the program</span></div>
<div class="line">        <span class="comment">// may also want to run while both the parent task and this</span></div>
<div class="line">        <span class="comment">// task block on mult())</span></div>
<div class="line">        <a class="code" href="classCgu_1_1Thread_1_1TaskManager_1_1IncHandle.html" title="A scoped handle for exception safe incrementing of the maximum number of threads that a TaskManager o...">Thread::TaskManager::IncHandle</a> h{tm};</div>
<div class="line">        <span class="keywordflow">return</span> mult(a, 2);</div>
<div class="line">      });</div>
<div class="line"></div>
<div class="line">      <span class="keywordtype">int</span> res = mult(b, 3)</div>
<div class="line">      return sub-&gt;get() + res;</div>
<div class="line">    }</div>
<div class="line">  );</div>
<div class="line"></div>
<div class="line">  g_main_loop_run(loop);</div>
<div class="line">}</div>
</div><!-- fragment --> </div><h2 class="groupheader">Member Enumeration Documentation</h2>
<a class="anchor" id="a59de02521dda7778da29462c6d41fc7b"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">enum <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a59de02521dda7778da29462c6d41fc7b">Cgu::Thread::TaskManager::StopMode</a></td>
        </tr>
      </table>
</div><div class="memdoc">
<table class="fieldtable">
<tr><th colspan="2">Enumerator</th></tr><tr><td class="fieldname"><em><a class="anchor" id="a59de02521dda7778da29462c6d41fc7ba47b71b9315a0d8ecc2941701bfb0e281"></a>wait_for_running</em>&nbsp;</td><td class="fielddoc">
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="a59de02521dda7778da29462c6d41fc7ba35a4e1e7bfe28bc85a044956369695f1"></a>wait_for_all</em>&nbsp;</td><td class="fielddoc">
</td></tr>
</table>

</div>
</div>
<h2 class="groupheader">Constructor &amp; Destructor Documentation</h2>
<a class="anchor" id="ad91848481798c638210a0527a7608121"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">Cgu::Thread::TaskManager::TaskManager </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html">TaskManager</a> &amp;&#160;</td>
          <td class="paramname">)</td><td></td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">delete</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>This class cannot be copied. The copy constructor is deleted. </p>

</div>
</div>
<a class="anchor" id="a35b136845550d876aa9e6d0283c7ee48"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">Cgu::Thread::TaskManager::TaskManager </td>
          <td>(</td>
          <td class="paramtype">unsigned int&#160;</td>
          <td class="paramname"><em>max</em> = <code>8</code>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">unsigned int&#160;</td>
          <td class="paramname"><em>min</em> = <code>0</code>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">unsigned int&#160;</td>
          <td class="paramname"><em>idle</em> = <code>10000</code>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bool&#160;</td>
          <td class="paramname"><em>blocking</em> = <code>true</code>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a59de02521dda7778da29462c6d41fc7b">StopMode</a>&#160;</td>
          <td class="paramname"><em>mode</em> = <code><a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a59de02521dda7778da29462c6d41fc7ba35a4e1e7bfe28bc85a044956369695f1">TaskManager::wait_for_all</a></code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>If the specified minimum number of threads is greater than 0, this constructor will start the required minimum number of threads. If glib &lt; 2.32 is installed, g_thread_init() must be called before any <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> objects are constructed </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">max</td><td>The maximum number of threads which the <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> object will run in the thread pool. If the value passed as this argument is less than the value passed as 'min', the maximum number of threads will be set to 'min'. A value of 0 is not valid, and if this is passed the number will be set to the greater of 1 and 'min'. </td></tr>
    <tr><td class="paramname">min</td><td>The minimum number of threads which the <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> object will run in the thread pool. </td></tr>
    <tr><td class="paramname">idle</td><td>The length of time in milliseconds that threads greater in number than 'min' and not executing any tasks will remain in existence. The default is 10000 (10 seconds). </td></tr>
    <tr><td class="paramname">blocking</td><td>If true, calls to <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#ae61908c1fb1973f7ce66ab6ae308fe02">stop_all()</a> and the destructor will not return until the tasks remaining to be executed have finished (what is meant by "the tasks remaining to be executed" depends on the StopMode setting, for which see the documentation on the <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#ae61908c1fb1973f7ce66ab6ae308fe02">stop_all()</a> method). If false, <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#ae61908c1fb1973f7ce66ab6ae308fe02">stop_all()</a> and the destructor will return straight away (which in terms of the <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> class implementation is safe for the reasons explained in the documentation on the destructor). </td></tr>
    <tr><td class="paramname">mode</td><td>The StopMode setting (either <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a59de02521dda7778da29462c6d41fc7ba47b71b9315a0d8ecc2941701bfb0e281">Cgu::Thread::TaskManager::wait_for_running</a> or <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a59de02521dda7778da29462c6d41fc7ba35a4e1e7bfe28bc85a044956369695f1">Cgu::Thread::TaskManager::wait_for_all</a>) executed when running <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#ae61908c1fb1973f7ce66ab6ae308fe02">stop_all()</a> or when the destructor is called. See the documentation on <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#ae61908c1fb1973f7ce66ab6ae308fe02">stop_all()</a> for an explanation of the setting. </td></tr>
  </table>
  </dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname">std::bad_alloc</td><td>This exception might be thrown if memory is exhausted and the system throws in that case. </td></tr>
    <tr><td class="paramname"><a class="el" href="structCgu_1_1Thread_1_1TaskError.html">Cgu::Thread::TaskError</a></td><td>This exception will be thrown if starting the specified minimum number of threads fails. </td></tr>
    <tr><td class="paramname"><a class="el" href="structCgu_1_1Thread_1_1MutexError.html">Cgu::Thread::MutexError</a></td><td>This exception might be thrown if initialisation of the contained mutex fails. (It is often not worth checking for this, as it means either memory is exhausted or pthread has run out of other resources to create new mutexes.) </td></tr>
    <tr><td class="paramname"><a class="el" href="structCgu_1_1Thread_1_1CondError.html">Cgu::Thread::CondError</a></td><td>This exception might be thrown if initialisation of the contained condition variable fails. (It is often not worth checking for this, as it means either memory is exhausted or pthread has run out of other resources to create new condition variables.)</td></tr>
  </table>
  </dd>
</dl>
<p>Since 2.0.12 </p>

</div>
</div>
<a class="anchor" id="a6166504700635802b42be065be21aacc"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">Cgu::Thread::TaskManager::~TaskManager </td>
          <td>(</td>
          <td class="paramname">)</td><td></td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>The destructor will call <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#ae61908c1fb1973f7ce66ab6ae308fe02">stop_all()</a>, unless that method has previously been called explicitly without throwing std::bad_alloc. If the blocking setting is true, the destructor will not return until the tasks remaining to be executed have finished (what is meant by "the tasks remaining to be executed" depends on the StopMode setting, for which see the documentation on the <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#ae61908c1fb1973f7ce66ab6ae308fe02">stop_all()</a> method.) If the blocking setting is false, the destructor will return straight away: this is safe, because <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a>'s internals for running tasks have been implemented using reference counting and will not be deleted until all threads running on the <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> object have finished, although the remaining tasks should not attempt to call any of <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a>'s methods once the <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> object itself has been destroyed.</p>
<p>The destructor is thread safe (any thread can destroy a <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> object) unless the blocking setting is true, in which case no task running on the <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> object may destroy the <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> object. Subject to that, it is not an error for a thread to destroy a <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> object and so invoke this destructor while another thread is already blocking in (if the blocking setting is true) or already out of (if the blocking setting is false) a call to <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#ae61908c1fb1973f7ce66ab6ae308fe02">stop_all()</a> and remaining tasks are executing: if blocking, both calls (to <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#ae61908c1fb1973f7ce66ab6ae308fe02">stop_all()</a> and to this destructor) would safely block together. Any given thread can similarly safely follow a non-blocking call to <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#ae61908c1fb1973f7ce66ab6ae308fe02">stop_all()</a> by a non-blocking call to this destructor even though remaining tasks are executing. However, it is an error for a thread to call <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#ae61908c1fb1973f7ce66ab6ae308fe02">stop_all()</a> after another thread has begun destruction of the <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> object (that is, after this destructor has been entered): there would then be an unresolvable race with the destructor.</p>
<p>The destructor will not throw.</p>
<p>If <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#ae61908c1fb1973f7ce66ab6ae308fe02">stop_all()</a> has not previously been called explicitly and throws std::bad_alloc() when called in this destructor, the exception will be caught and consumed, but then the destructor will not block even if the blocking setting is true, and if the minimum number of threads is not 0 some threads might remain running during the entire program duration (albeit safely). Where the throwing of std::bad_alloc is a meaningful event (usually it isn't) and needs to be guarded against, call <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#ae61908c1fb1973f7ce66ab6ae308fe02">stop_all()</a> explicitly before this destructor is entered, or use a minimum thread value of 0 and allow for the case of the destructor not blocking.</p>
<p>Since 2.0.12 </p>

</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a class="anchor" id="a81f7c8af3295d92c0e19d7f9498a4078"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void Cgu::Thread::TaskManager::add_task </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="namespaceCgu_1_1Callback.html#ab0fdf0ebb22f2a7cc813657f6d90a94d">Callback::Callback</a> *&#160;</td>
          <td class="paramname"><em>task</em>)</td><td></td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>This method adds a new task. If one or more threads in the pool are currently blocking and waiting for a task, then the task will begin executing immediately in one of the threads. If not, and the value returned by <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a66d6c80cef1ff5c6a9973c3c934fe04d">get_used_threads()</a> is less than the value returned by <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a84f6a3ccb91012f4d2faaf968744a819">get_max_threads()</a>, a new thread will start and the task will execute immediately in the new thread. Otherwise, the task will be queued for execution as soon as a thread becomes available. Tasks will be executed in the order in which they are added to the ThreadManager object. This method is thread safe (any thread may call it, including any task running on the <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> object).</p>
<p>A task may terminate itself prematurely by throwing <a class="el" href="classCgu_1_1Thread_1_1Exit.html" title="A class which can be thrown to terminate the throwing thread. ">Cgu::Thread::Exit</a>. In addition, the implementation of <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> will consume any other exception escaping from the task callback and safely terminate the task concerned in order to protect the integrity of the <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> object. Where detecting any of these outcomes is important (usually it won't be), the two argument version of this method is available so that a 'fail' callback can be executed in these circumstances.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">task</td><td>A callback representing the new task, as constructed by the <a class="el" href="namespaceCgu_1_1Callback.html#ab0b54bd51f4ff2c80e5b593dc962be13">Callback::lambda()</a>, <a class="el" href="namespaceCgu_1_1Callback.html#a3e32d4f4961c618aa7e03bda00f398b8">Callback::make()</a> or <a class="el" href="namespaceCgu_1_1Callback.html#a94b122ac99f423928320240fd48d571b">Callback::make_ref()</a> factory functions. Ownership is taken of this callback, and it will be disposed of when it has been finished with. If an exception propagates from the task, the exception will be consumed and (if the thrown object's type is not <a class="el" href="classCgu_1_1Thread_1_1Exit.html" title="A class which can be thrown to terminate the throwing thread. ">Cgu::Thread::Exit</a>) a g_critical() warning will be issued. The destructors of any bound arguments in the callback must not throw. </td></tr>
  </table>
  </dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname">std::bad_alloc</td><td>This exception will be thrown if memory is exhausted and the system throws in that case. (On systems with over-commit/lazy-commit combined with virtual memory (swap), it is rarely useful to check for memory exhaustion). If this exception is thrown, the task will not start and the 'task' callback will be disposed of. </td></tr>
    <tr><td class="paramname"><a class="el" href="structCgu_1_1Thread_1_1TaskError.html">Cgu::Thread::TaskError</a></td><td>This exception will be thrown if <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#ae61908c1fb1973f7ce66ab6ae308fe02">stop_all()</a> has previously been called. It will also be thrown if <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a2ac8ae63abc1a6b433f40e861d39ca33">is_error()</a> would return true because this class's internal thread pool loop implementation has thrown std::bad_alloc, or a thread has failed to start correctly. (On systems with over-commit/lazy-commit combined with virtual memory (swap), it is rarely useful to check for memory exhaustion, but there may be some specialized cases where the return value of <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a2ac8ae63abc1a6b433f40e861d39ca33">is_error()</a> is useful.) If this exception is thrown, the task will not start and the 'task' callback will be disposed of.</td></tr>
  </table>
  </dd>
</dl>
<p>Since 2.0.12 </p>

</div>
</div>
<a class="anchor" id="ac5e226b3a2d6ec05bceeeadb21afd34e"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void Cgu::Thread::TaskManager::add_task </td>
          <td>(</td>
          <td class="paramtype">std::unique_ptr&lt; const <a class="el" href="namespaceCgu_1_1Callback.html#ab0fdf0ebb22f2a7cc813657f6d90a94d">Callback::Callback</a> &gt;&#160;</td>
          <td class="paramname"><em>task</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">std::unique_ptr&lt; const <a class="el" href="namespaceCgu_1_1Callback.html#ab0fdf0ebb22f2a7cc813657f6d90a94d">Callback::Callback</a> &gt;&#160;</td>
          <td class="paramname"><em>fail</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>This method adds a new task. If one or more threads in the pool are currently blocking and waiting for a task, then the task will begin executing immediately in one of the threads. If not, and the value returned by <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a66d6c80cef1ff5c6a9973c3c934fe04d">get_used_threads()</a> is less than the value returned by <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a84f6a3ccb91012f4d2faaf968744a819">get_max_threads()</a>, a new thread will start and the task will execute immediately in the new thread. Otherwise, the task will be queued for execution as soon as a thread becomes available. Tasks will be executed in the order in which they are added to the ThreadManager object. This method is thread safe (any thread may call it, including any task running on the <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> object).</p>
<p>A task may terminate itself prematurely by throwing <a class="el" href="classCgu_1_1Thread_1_1Exit.html" title="A class which can be thrown to terminate the throwing thread. ">Cgu::Thread::Exit</a>. In addition, the implementation of <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> will consume any other exception escaping from the task callback and safely terminate the task concerned in order to protect the integrity of the <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> object. Where detecting any of these outcomes is important (usually it won't be), a callback can be passed to the 'fail' argument which will execute if, and only if, either <a class="el" href="classCgu_1_1Thread_1_1Exit.html" title="A class which can be thrown to terminate the throwing thread. ">Cgu::Thread::Exit</a> is thrown or some other exception has propagated from the task. This 'fail' callback is different from the 'fail' callback of <a class="el" href="classCgu_1_1Thread_1_1Future.html" title="A class representing a pthread thread which will provide a value. ">Cgu::Thread::Future</a> objects (programming for many tasks to a lesser number of threads requires different approaches from programming for one thread per task), and it executes in the task thread rather than executing in a glib main loop (however, the 'fail' callback can of course call <a class="el" href="namespaceCgu_1_1Callback.html#ab8a459b25b1dba52fd43015c694bab1d">Cgu::Callback::post()</a> to execute another callback in a main loop, if that is what is wanted).</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">task</td><td>A callback representing the new task, as constructed by the <a class="el" href="namespaceCgu_1_1Callback.html#ab0b54bd51f4ff2c80e5b593dc962be13">Callback::lambda()</a>, <a class="el" href="namespaceCgu_1_1Callback.html#a3e32d4f4961c618aa7e03bda00f398b8">Callback::make()</a> or <a class="el" href="namespaceCgu_1_1Callback.html#a94b122ac99f423928320240fd48d571b">Callback::make_ref()</a> factory functions. If an exception propagates from the task, the exception will be consumed and the 'fail' callback will execute. </td></tr>
    <tr><td class="paramname">fail</td><td>A callback (as constructed by the <a class="el" href="namespaceCgu_1_1Callback.html#ab0b54bd51f4ff2c80e5b593dc962be13">Callback::lambda()</a>, <a class="el" href="namespaceCgu_1_1Callback.html#a3e32d4f4961c618aa7e03bda00f398b8">Callback::make()</a> or <a class="el" href="namespaceCgu_1_1Callback.html#a94b122ac99f423928320240fd48d571b">Callback::make_ref()</a> factory functions) which will be executed if the function or callable object executed by the 'task' callback exits by throwing <a class="el" href="classCgu_1_1Thread_1_1Exit.html" title="A class which can be thrown to terminate the throwing thread. ">Thread::Exit</a> or some other exception. If an exception propagates from the 'fail' callback, this will be consumed to protect the <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> object, and a g_critical() warning will be issued. </td></tr>
  </table>
  </dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname">std::bad_alloc</td><td>This exception will be thrown if memory is exhausted and the system throws in that case. (On systems with over-commit/lazy-commit combined with virtual memory (swap), it is rarely useful to check for memory exhaustion). If this exception is thrown, the task will not start (which also means that the 'fail' callback will not execute). </td></tr>
    <tr><td class="paramname"><a class="el" href="structCgu_1_1Thread_1_1TaskError.html">Cgu::Thread::TaskError</a></td><td>This exception will be thrown if <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#ae61908c1fb1973f7ce66ab6ae308fe02">stop_all()</a> has previously been called. It will also be thrown if <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a2ac8ae63abc1a6b433f40e861d39ca33">is_error()</a> would return true because this class's internal thread pool loop implementation has thrown std::bad_alloc, or a thread has failed to start correctly. (On systems with over-commit/lazy-commit combined with virtual memory (swap), it is rarely useful to check for memory exhaustion, but there may be some specialized cases where the return value of <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a2ac8ae63abc1a6b433f40e861d39ca33">is_error()</a> is useful.) If this exception is thrown, the task will not start (which also means that the 'fail' callback will not execute).</td></tr>
  </table>
  </dd>
</dl>
<p>Since 2.0.12 </p>

</div>
</div>
<a class="anchor" id="a880e5b950eacc1debb44e5bab896a157"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class Task , class  = typename std::enable_if&lt;!std::is_convertible&lt;typename std::remove_reference&lt;Task&gt;::type,	    							 const Callback::Callback*&gt;::value&gt;::type&gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void Cgu::Thread::TaskManager::add_task </td>
          <td>(</td>
          <td class="paramtype">Task &amp;&amp;&#160;</td>
          <td class="paramname"><em>task</em>)</td><td></td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>This method adds a new task. If one or more threads in the pool are currently blocking and waiting for a task, then the task will begin executing immediately in one of the threads. If not, and the value returned by <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a66d6c80cef1ff5c6a9973c3c934fe04d">get_used_threads()</a> is less than the value returned by <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a84f6a3ccb91012f4d2faaf968744a819">get_max_threads()</a>, a new thread will start and the task will execute immediately in the new thread. Otherwise, the task will be queued for execution as soon as a thread becomes available. Tasks will be executed in the order in which they are added to the ThreadManager object. This method is thread safe (any thread may call it, including any task running on the <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> object).</p>
<p>A task may terminate itself prematurely by throwing <a class="el" href="classCgu_1_1Thread_1_1Exit.html" title="A class which can be thrown to terminate the throwing thread. ">Cgu::Thread::Exit</a>. In addition, the implementation of <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> will consume any other exception escaping from the task callback and safely terminate the task concerned in order to protect the integrity of the <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> object. Where detecting any of these outcomes is important (usually it won't be), the two argument version of this method is available so that a 'fail' callback can be executed in these circumstances.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">task</td><td>A callable object representing the new task, such as formed by a lambda expression or the result of std::bind. It must be fully bound (that is, it must take no arguments when called). If an exception propagates from the task, the exception will be consumed and (if the thrown object's type is not <a class="el" href="classCgu_1_1Thread_1_1Exit.html" title="A class which can be thrown to terminate the throwing thread. ">Cgu::Thread::Exit</a>) a g_critical() warning will be issued. The destructors of any bound values must not throw. </td></tr>
  </table>
  </dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname">std::bad_alloc</td><td>This exception will be thrown if memory is exhausted and the system throws in that case. (On systems with over-commit/lazy-commit combined with virtual memory (swap), it is rarely useful to check for memory exhaustion). If this exception is thrown, the task will not start. </td></tr>
    <tr><td class="paramname"><a class="el" href="structCgu_1_1Thread_1_1TaskError.html">Cgu::Thread::TaskError</a></td><td>This exception will be thrown if <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#ae61908c1fb1973f7ce66ab6ae308fe02">stop_all()</a> has previously been called. It will also be thrown if <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a2ac8ae63abc1a6b433f40e861d39ca33">is_error()</a> would return true because this class's internal thread pool loop implementation has thrown std::bad_alloc, or a thread has failed to start correctly. (On systems with over-commit/lazy-commit combined with virtual memory (swap), it is rarely useful to check for memory exhaustion, but there may be some specialized cases where the return value of <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a2ac8ae63abc1a6b433f40e861d39ca33">is_error()</a> is useful.) If this exception is thrown, the task will not start. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section note"><dt>Note</dt><dd>An exception might also be thrown if the copy or move constructor of the callable object throws. If such an exception is thrown, the task will not start.</dd></dl>
<p>Since 2.1.0 </p>

</div>
</div>
<a class="anchor" id="a46e6937dad229a7e48b635735715535f"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class Task , class Fail , class  = typename std::enable_if&lt;!std::is_convertible&lt;Task, std::unique_ptr&lt;const Callback::Callback&gt;&gt;::value	    				    &amp;&amp; !std::is_convertible&lt;Fail, std::unique_ptr&lt;const Callback::Callback&gt;&gt;::value&gt;::type&gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void Cgu::Thread::TaskManager::add_task </td>
          <td>(</td>
          <td class="paramtype">Task &amp;&amp;&#160;</td>
          <td class="paramname"><em>task</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">Fail &amp;&amp;&#160;</td>
          <td class="paramname"><em>fail</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>This method adds a new task. If one or more threads in the pool are currently blocking and waiting for a task, then the task will begin executing immediately in one of the threads. If not, and the value returned by <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a66d6c80cef1ff5c6a9973c3c934fe04d">get_used_threads()</a> is less than the value returned by <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a84f6a3ccb91012f4d2faaf968744a819">get_max_threads()</a>, a new thread will start and the task will execute immediately in the new thread. Otherwise, the task will be queued for execution as soon as a thread becomes available. Tasks will be executed in the order in which they are added to the ThreadManager object. This method is thread safe (any thread may call it, including any task running on the <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> object).</p>
<p>A task may terminate itself prematurely by throwing <a class="el" href="classCgu_1_1Thread_1_1Exit.html" title="A class which can be thrown to terminate the throwing thread. ">Cgu::Thread::Exit</a>. In addition, the implementation of <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> will consume any other exception escaping from the task callback and safely terminate the task concerned in order to protect the integrity of the <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> object. Where detecting any of these outcomes is important (usually it won't be), a callback can be passed to the 'fail' argument which will execute if, and only if, either <a class="el" href="classCgu_1_1Thread_1_1Exit.html" title="A class which can be thrown to terminate the throwing thread. ">Cgu::Thread::Exit</a> is thrown or some other exception has propagated from the task. This 'fail' callback is different from the 'fail' callback of <a class="el" href="classCgu_1_1Thread_1_1Future.html" title="A class representing a pthread thread which will provide a value. ">Cgu::Thread::Future</a> objects (programming for many tasks to a lesser number of threads requires different approaches from programming for one thread per task), and it executes in the task thread rather than executing in a glib main loop (however, the 'fail' callback can of course call <a class="el" href="namespaceCgu_1_1Callback.html#ab8a459b25b1dba52fd43015c694bab1d">Cgu::Callback::post()</a> to execute another callback in a main loop, if that is what is wanted).</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">task</td><td>A callable object representing the new task, such as formed by a lambda expression or the result of std::bind. It must be fully bound (that is, it must take no arguments when called). The destructors of any bound values must not throw. If an exception propagates from the task, the exception will be consumed and the 'fail' callback will execute. </td></tr>
    <tr><td class="paramname">fail</td><td>A callable object (such as formed by a lambda expression or the result of std::bind) which will be executed if the callable object represented by the 'task' callback exits by throwing <a class="el" href="classCgu_1_1Thread_1_1Exit.html" title="A class which can be thrown to terminate the throwing thread. ">Thread::Exit</a> or some other exception. It must be fully bound (that is, it must take no arguments when called). The destructors of any bound values must not throw. If an exception propagates from the 'fail' callback, this will be consumed to protect the <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> object, and a g_critical() warning will be issued. </td></tr>
  </table>
  </dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname">std::bad_alloc</td><td>This exception will be thrown if memory is exhausted and the system throws in that case. (On systems with over-commit/lazy-commit combined with virtual memory (swap), it is rarely useful to check for memory exhaustion). If this exception is thrown, the task will not start (which also means that the 'fail' callback will not execute). </td></tr>
    <tr><td class="paramname"><a class="el" href="structCgu_1_1Thread_1_1TaskError.html">Cgu::Thread::TaskError</a></td><td>This exception will be thrown if <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#ae61908c1fb1973f7ce66ab6ae308fe02">stop_all()</a> has previously been called. It will also be thrown if <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a2ac8ae63abc1a6b433f40e861d39ca33">is_error()</a> would return true because this class's internal thread pool loop implementation has thrown std::bad_alloc, or a thread has failed to start correctly. (On systems with over-commit/lazy-commit combined with virtual memory (swap), it is rarely useful to check for memory exhaustion, but there may be some specialized cases where the return value of <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a2ac8ae63abc1a6b433f40e861d39ca33">is_error()</a> is useful.) If this exception is thrown, the task will not start (which also means that the 'fail' callback will not execute). </td></tr>
  </table>
  </dd>
</dl>
<dl class="section note"><dt>Note</dt><dd>An exception might also be thrown if the copy or move constructor of the 'task' or 'fail' callable objects throws. If such an exception is thrown, the task will not start (which also means that the 'fail' callback will not execute)</dd></dl>
<p>Since 2.1.0 </p>

</div>
</div>
<a class="anchor" id="ad47297562ee0c838da1242335745d31b"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void Cgu::Thread::TaskManager::change_max_threads </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>delta</em>)</td><td></td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>This will increase, or if 'delta' is negative reduce, the maximum number of threads which the <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> object will currently run in the thread pool by the value of 'delta'. The purpose of this is to enable a task to increment the maximum thread number where it is about to enter a call which may block for some time, with a view to decrementing it later when it has finished making blocking calls, so as to enable another thread to keep a core active. If 'delta' is negative and results in a max_threads value of less than the current number of running threads, the number of threads actually running will only be reduced as tasks complete, or as idle timeouts expire. This method does nothing if <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#ae61908c1fb1973f7ce66ab6ae308fe02">stop_all()</a> has previously been called. This method is thread safe. Since version 2.2.1, the scoped handle class <a class="el" href="classCgu_1_1Thread_1_1TaskManager_1_1IncHandle.html" title="A scoped handle for exception safe incrementing of the maximum number of threads that a TaskManager o...">TaskManager::IncHandle</a> is available which calls this method. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">delta</td><td>The change (positive or negative) to the maximum number of threads which the <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> object will currently run in the thread pool. This method will not set the maximum value of threads to a value less than that returned by <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#acd4031c041c0a32e6435e6ab3783bb3d">get_min_threads()</a>, nor to a value less than 1. </td></tr>
  </table>
  </dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname">std::bad_alloc</td><td>If this call is passed a positive value and tasks are currently queued for execution, a new thread or threads will be started for the queued tasks, so this exception may be thrown on starting a new thread if memory is exhausted and the system throws in that case. (On systems with over-commit/lazy-commit combined with virtual memory (swap), it is rarely useful to check for memory exhaustion). </td></tr>
    <tr><td class="paramname"><a class="el" href="structCgu_1_1Thread_1_1TaskError.html">Cgu::Thread::TaskError</a></td><td>If this call is passed a positive value and tasks are currently queued for execution, a new thread or threads will be started for the queued tasks, so this exception may be thrown on starting a new thread if it fails to start correctly (this would mean that memory is exhausted, the pthread thread limit has been reached or pthread has run out of other resources to start new threads).</td></tr>
  </table>
  </dd>
</dl>
<p>Since 2.0.14 </p>

</div>
</div>
<a class="anchor" id="a6f8ecca4db902ef74c9ca60308cb5c4f"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool Cgu::Thread::TaskManager::get_blocking </td>
          <td>(</td>
          <td class="paramname">)</td><td></td>
          <td> const</td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Gets the current blocking setting, which determines whether calls to <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#ae61908c1fb1973f7ce66ab6ae308fe02">stop_all()</a> and the destructor will block waiting for all remaining tasks to complete. This value is established initially by the 'blocking' argument passed to the <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> constructor and can subequently be changed by calling <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#ae4530426fed068208df577ca8eea669f">set_blocking()</a>. This method will not throw and is thread safe. </p>
<dl class="section return"><dt>Returns</dt><dd>The current blocking setting.</dd></dl>
<p>Since 2.0.12 </p>

</div>
</div>
<a class="anchor" id="a0a53c8cd0e5c55607252f689b64bdd3d"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">unsigned int Cgu::Thread::TaskManager::get_idle_time </td>
          <td>(</td>
          <td class="paramname">)</td><td></td>
          <td> const</td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Gets the length of time in milliseconds that threads greater in number than the minimum and not executing any tasks will remain in existence waiting for new tasks. This value is established initially by the 'idle' argument passed to the <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> constructor and can subequently be changed by calling <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#ae4d3d2a1c68e58bbc51037a970194ec4">set_idle_time()</a>. The default value is 10000 (10 seconds). This method will not throw and is thread safe. </p>
<dl class="section return"><dt>Returns</dt><dd>The idle time in milliseconds.</dd></dl>
<p>Since 2.0.12 </p>

</div>
</div>
<a class="anchor" id="a84f6a3ccb91012f4d2faaf968744a819"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">unsigned int Cgu::Thread::TaskManager::get_max_threads </td>
          <td>(</td>
          <td class="paramname">)</td><td></td>
          <td> const</td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Gets the maximum number of threads which the <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> object is currently set to run in the thread pool. This value is established initially by the 'max' argument passed to the <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> constructor and can subequently be changed by calling <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#aa5b0225d7acd9c5b6e2f8de39bc711e3">set_max_threads()</a> or <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#ad47297562ee0c838da1242335745d31b">change_max_threads()</a>. The default value is</p>
<ol type="1">
<li>This method will not throw and is thread safe. However, if a blocking task might use the <a class="el" href="classCgu_1_1Thread_1_1TaskManager_1_1IncHandle.html" title="A scoped handle for exception safe incrementing of the maximum number of threads that a TaskManager o...">TaskManager::IncHandle</a> class (or increase and then decrease the number by hand by calling <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#ad47297562ee0c838da1242335745d31b">change_max_threads()</a>), this method will not usually be of any particular value. <dl class="section return"><dt>Returns</dt><dd>The maximum number of threads.</dd></dl>
Since 2.0.12 </li>
</ol>

</div>
</div>
<a class="anchor" id="acd4031c041c0a32e6435e6ab3783bb3d"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">unsigned int Cgu::Thread::TaskManager::get_min_threads </td>
          <td>(</td>
          <td class="paramname">)</td><td></td>
          <td> const</td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Gets the minimum number of threads which the <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> object will run in the thread pool (these threads will last until <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#ae61908c1fb1973f7ce66ab6ae308fe02">stop_all()</a> is called or the <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> object is destroyed). This value is established by the 'min' argument passed to the <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> constructor and cannot subequently be changed. The default is 0. This method will not throw and is thread safe. </p>
<dl class="section return"><dt>Returns</dt><dd>The minimum number of threads.</dd></dl>
<p>Since 2.0.12 </p>

</div>
</div>
<a class="anchor" id="a57b9f166750852902d20e4dcda69efd0"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a59de02521dda7778da29462c6d41fc7b">StopMode</a> Cgu::Thread::TaskManager::get_stop_mode </td>
          <td>(</td>
          <td class="paramname">)</td><td></td>
          <td> const</td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Gets the current StopMode setting (either <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a59de02521dda7778da29462c6d41fc7ba47b71b9315a0d8ecc2941701bfb0e281">Cgu::Thread::TaskManager::wait_for_running</a> or <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a59de02521dda7778da29462c6d41fc7ba35a4e1e7bfe28bc85a044956369695f1">Cgu::Thread::TaskManager::wait_for_all</a>) executed when running <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#ae61908c1fb1973f7ce66ab6ae308fe02">stop_all()</a> or when the destructor is called. See the documentation on <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#ae61908c1fb1973f7ce66ab6ae308fe02">stop_all()</a> for an explanation of the setting. This value is established initially by the 'mode' argument passed to the <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> constructor and can subequently be changed by calling <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a410ccc3699dee4e297fd74e1aad7e72d">set_stop_mode()</a>. This method will not throw and is thread safe. </p>
<dl class="section return"><dt>Returns</dt><dd>The current StopMode setting.</dd></dl>
<p>Since 2.0.12 </p>

</div>
</div>
<a class="anchor" id="af0222421e7d28608d3133c907c9e7498"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">unsigned int Cgu::Thread::TaskManager::get_tasks </td>
          <td>(</td>
          <td class="paramname">)</td><td></td>
          <td> const</td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Gets the number of tasks which the <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> object is at present either running in the thread pool or has queued for execution. This value will be less than the number returned by <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a66d6c80cef1ff5c6a9973c3c934fe04d">get_used_threads()</a> if threads in the thread pool are currently waiting to receive tasks for execution. This method will not throw and is thread safe. </p>
<dl class="section return"><dt>Returns</dt><dd>The number of tasks either running or queued for execution.</dd></dl>
<p>Since 2.0.12 </p>

</div>
</div>
<a class="anchor" id="a66d6c80cef1ff5c6a9973c3c934fe04d"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">unsigned int Cgu::Thread::TaskManager::get_used_threads </td>
          <td>(</td>
          <td class="paramname">)</td><td></td>
          <td> const</td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Gets the number of threads which the <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> object is currently running in the thread pool, including those blocking waiting for a task. This value could be greater than the number returned by <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a84f6a3ccb91012f4d2faaf968744a819">get_max_threads()</a> if <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#ad47297562ee0c838da1242335745d31b">change_max_threads()</a> has recently been called with a negative number but not enough tasks have since completed to reduce the number of running threads to the new value set. This method will not throw and is thread safe. </p>
<dl class="section return"><dt>Returns</dt><dd>The number of threads running in the thread pool, including those blocking waiting for a task.</dd></dl>
<p>Since 2.0.12 </p>

</div>
</div>
<a class="anchor" id="a2ac8ae63abc1a6b433f40e861d39ca33"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool Cgu::Thread::TaskManager::is_error </td>
          <td>(</td>
          <td class="paramname">)</td><td></td>
          <td> const</td>
        </tr>
      </table>
</div><div class="memdoc">
<p>This will return true if a thread required by the thread pool has failed to start correctly because of memory exhaustion or because pthread has run out of other resources to start new threads, or because an internal operation has thrown std::bad_alloc. (On systems with over-commit/lazy-commit combined with virtual memory (swap), it is rarely useful to check for memory exhaustion, and even more so where glib is used, as that terminates a program if memory cannot be obtained from the operating system, but there may be some specialized cases where the return value of this method is useful - this class does not use any glib functions which might cause such termination.) This method will not throw and is thread safe.</p>
<p>Since 2.0.12 </p>

</div>
</div>
<a class="anchor" id="a8ebf8f3fb5d9622d5369005c9dd7a14b"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class Ret , class Func &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void Cgu::Thread::TaskManager::make_task_compose </td>
          <td>(</td>
          <td class="paramtype">Func &amp;&amp;&#160;</td>
          <td class="paramname"><em>f</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">GMainContext *&#160;</td>
          <td class="paramname"><em>context</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">std::unique_ptr&lt; const <a class="el" href="classCgu_1_1Callback_1_1CallbackArg.html">Cgu::Callback::CallbackArg</a>&lt; const Ret &amp; &gt;&gt;&#160;</td>
          <td class="paramname"><em>when</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>This is an abbreviated version of <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#abe374ca418bbe53e6c5228ecc1b6a3ac">make_task_when_full()</a>, which is for use when it is known that the callable object passed to this method does not throw, and the user is not interested in std::bad_alloc and does not need a <a class="el" href="classCgu_1_1Releaser.html" title="A class used for tracking EmitterArg and SafeEmitterArg connections. ">Cgu::Releaser</a> object for the 'when' callback (which is likely to cover the majority of uses, particularly when composing tasks using glib because glib terminates the program if it is unable to obtain memory).</p>
<p>This method does the same as the version of <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a7a013fd7b21096fa76e39cbe5475d31b">make_task_when()</a> taking a callable object, except that this method takes that object as its first argument and the 'when' callback as its last argument in order to aid task composition, and in particular so tasks compose in user code in a visually ordered manner.</p>
<p>More particularly, like <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#abe374ca418bbe53e6c5228ecc1b6a3ac">make_task_when_full()</a>, this method is a wrapper which will take a callable object which returns a value, and constructs a <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> task which will execute that object by calling <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a81f7c8af3295d92c0e19d7f9498a4078">add_task()</a> with an appropriate callback object, and causes the 'when' callback passed as an argument to this method to be executed by a glib main loop if and when the task finishes correctly - the 'when' callback is passed the callable object's return value when it is invoked. It is thread safe (any thread may call this method, including another task running on the <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> object). Apart from the absence of a 'one thread per task' model, this method therefore provides a similar interface to the one provided by <a class="el" href="classCgu_1_1Thread_1_1Future.html" title="A class representing a pthread thread which will provide a value. ">Cgu::Thread::Future</a>. See the documentation on <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a81f7c8af3295d92c0e19d7f9498a4078">add_task()</a> for further information about how task execution works.</p>
<p>The 'when' callback will execute with G_PRIORITY_DEFAULT priority in the main loop.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">f</td><td>The callable object to be executed as a task, such as formed by a lambda expression or the result of std::bind. It should return a value (it cannot return void). It must be fully bound (that is, it must take no arguments when called). If an exception propagates from the task, the exception will be consumed and (if the thrown object's type is not <a class="el" href="classCgu_1_1Thread_1_1Exit.html" title="A class which can be thrown to terminate the throwing thread. ">Cgu::Thread::Exit</a>) a g_critical() warning will be issued. </td></tr>
    <tr><td class="paramname">context</td><td>The glib main context of the main loop in which the 'when' callback is to be executed. A value 0/NULL/nullptr will cause the callback to be executed in the main program loop. </td></tr>
    <tr><td class="paramname">when</td><td>A callback which will be executed if and when the callable object passed to this method finishes correctly. The callback is passed that object's return value when it is invoked. If an exception propagates from the 'when' callback, this will be consumed and a g_critical() warning will be issued. The callback will execute in the glib main loop whose GMainContext object is passed to the 'context' argument of this method. </td></tr>
  </table>
  </dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname">std::bad_alloc</td><td>This exception will be thrown if memory is exhausted and the system throws in that case. (On systems with over-commit/lazy-commit combined with virtual memory (swap), it is rarely useful to check for memory exhaustion). If this exception is thrown, the task will not start (which also means that the 'when' callback will not execute). </td></tr>
    <tr><td class="paramname"><a class="el" href="structCgu_1_1Thread_1_1TaskError.html">Cgu::Thread::TaskError</a></td><td>This exception will be thrown if <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#ae61908c1fb1973f7ce66ab6ae308fe02">stop_all()</a> has previously been called. It will also be thrown if <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a2ac8ae63abc1a6b433f40e861d39ca33">is_error()</a> would return true because this class's internal thread pool loop implementation has thrown std::bad_alloc, or a thread has failed to start correctly. (On systems with over-commit/lazy-commit combined with virtual memory (swap), it is rarely useful to check for memory exhaustion, but there may be some specialized cases where the return value of <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a2ac8ae63abc1a6b433f40e861d39ca33">is_error()</a> is useful.) If this exception is thrown, the task will not start (which also means that the 'when' callback will not execute). </td></tr>
  </table>
  </dd>
</dl>
<dl class="section note"><dt>Note</dt><dd>1. This method will also throw if the copy or move constructor of the callable object throws. If such an exception is thrown, the task will not start (which also means that the 'when' callback will not execute). </dd>
<dd>
2. If the callable object passed as an argument has both const and non-const operator()() methods, the non-const version will be called even if the callable object passed is a const object.</dd></dl>
<p>Since 2.0.14 </p>

</div>
</div>
<a class="anchor" id="a4846175781716487569bb632dd69cef1"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class Func , class When , class  = typename std::enable_if&lt;!std::is_convertible&lt;When, std::unique_ptr&lt;const Callback::CallbackArg&lt;const typename std::result_of&lt;Func()&gt;::type&amp;&gt;&gt;&gt;::value&gt;::type&gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void Cgu::Thread::TaskManager::make_task_compose </td>
          <td>(</td>
          <td class="paramtype">Func &amp;&amp;&#160;</td>
          <td class="paramname"><em>func</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">GMainContext *&#160;</td>
          <td class="paramname"><em>context</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">When &amp;&amp;&#160;</td>
          <td class="paramname"><em>when</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>This is an abbreviated version of <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#abe374ca418bbe53e6c5228ecc1b6a3ac">make_task_when_full()</a>, which is for use when it is known that the callable object passed to the 'func' argument of this method does not throw, and the user is not interested in std::bad_alloc and does not need a <a class="el" href="classCgu_1_1Releaser.html" title="A class used for tracking EmitterArg and SafeEmitterArg connections. ">Cgu::Releaser</a> object for the 'when' callback (which is likely to cover the majority of uses, particularly when composing tasks using glib because glib terminates the program if it is unable to obtain memory).</p>
<p>This method does the same as <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a7a013fd7b21096fa76e39cbe5475d31b">make_task_when()</a>, except that this method takes the callable object to be executed as a task as its first argument and the 'when' callback as its last argument in order to aid task composition, and in particular so tasks compose in user code in a visually ordered manner.</p>
<p>More particularly, like <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#abe374ca418bbe53e6c5228ecc1b6a3ac">make_task_when_full()</a>, this method is a wrapper which takes a callable object which returns a value as its 'func' argument, and constructs a <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> task which will execute that object by calling <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a81f7c8af3295d92c0e19d7f9498a4078">add_task()</a> with an appropriate callback object, and causes the 'when' callback passed as an argument to this method to be executed by a glib main loop if and when the task finishes correctly - the 'when' callback is passed the return value of the 'func' argument when it is invoked. It is thread safe (any thread may call this method, including another task running on the <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> object). Apart from the absence of a 'one thread per task' model, this method therefore provides a similar interface to the one provided by <a class="el" href="classCgu_1_1Thread_1_1Future.html" title="A class representing a pthread thread which will provide a value. ">Cgu::Thread::Future</a>. See the documentation on <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a81f7c8af3295d92c0e19d7f9498a4078">add_task()</a> for further information about how task execution works.</p>
<p>The 'when' callback will execute with G_PRIORITY_DEFAULT priority in the main loop.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">func</td><td>The callable object to be executed as a task, such as formed by a lambda expression or the result of std::bind. It should return a value (it cannot return void). It must be fully bound (that is, it must take no arguments when called). If an exception propagates from the task, the exception will be consumed and (if the thrown object's type is not <a class="el" href="classCgu_1_1Thread_1_1Exit.html" title="A class which can be thrown to terminate the throwing thread. ">Cgu::Thread::Exit</a>) a g_critical() warning will be issued. </td></tr>
    <tr><td class="paramname">context</td><td>The glib main context of the main loop in which the 'when' callback is to be executed. A value 0/NULL/nullptr will cause the callback to be executed in the main program loop. </td></tr>
    <tr><td class="paramname">when</td><td>A callable object (such as formed by a lambda expression or the result of std::bind) which will be executed if and when the 'func' object passed to this method finishes correctly. The 'when' callback is passed that objects's return value when invoked, and should take a single unbound argument, namely a reference to const of the type of that return value. If an exception propagates from the 'when' callback, this will be consumed and a g_critical() warning will be issued. The callback will execute in the glib main loop whose GMainContext object is passed to the 'context' argument of this method. </td></tr>
  </table>
  </dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname">std::bad_alloc</td><td>This exception will be thrown if memory is exhausted and the system throws in that case. (On systems with over-commit/lazy-commit combined with virtual memory (swap), it is rarely useful to check for memory exhaustion). If this exception is thrown, the task will not start (which also means that the 'when' callback will not execute). </td></tr>
    <tr><td class="paramname"><a class="el" href="structCgu_1_1Thread_1_1TaskError.html">Cgu::Thread::TaskError</a></td><td>This exception will be thrown if <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#ae61908c1fb1973f7ce66ab6ae308fe02">stop_all()</a> has previously been called. It will also be thrown if <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a2ac8ae63abc1a6b433f40e861d39ca33">is_error()</a> would return true because this class's internal thread pool loop implementation has thrown std::bad_alloc, or a thread has failed to start correctly. (On systems with over-commit/lazy-commit combined with virtual memory (swap), it is rarely useful to check for memory exhaustion, but there may be some specialized cases where the return value of <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a2ac8ae63abc1a6b433f40e861d39ca33">is_error()</a> is useful.) If this exception is thrown, the task will not start (which also means that the 'when' callback will not execute). </td></tr>
  </table>
  </dd>
</dl>
<dl class="section note"><dt>Note</dt><dd>1. This method will also throw if the copy or move constructor of the 'func' or 'when' callable objects throws. If such an exception is thrown, the task will not start (which also means that the 'when' callback will not execute). </dd>
<dd>
2. If any of the callable objects passed to this method have both const and non-const operator()() methods, the non-const version will be called even if the callable object passed is a const object.</dd></dl>
<p>Since 2.1.0 </p>

</div>
</div>
<a class="anchor" id="a50dfd5cfa77b1e6b4645c4bd46ce7dd0"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class Ret , class... Params, class... Args, class T &gt; </div>
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classCgu_1_1SharedLockPtr.html">Cgu::SharedLockPtr</a>&lt;<a class="el" href="classCgu_1_1AsyncResult.html">Cgu::AsyncResult</a>&lt;Ret&gt; &gt; Cgu::Thread::TaskManager::make_task_result </td>
          <td>(</td>
          <td class="paramtype">T &amp;&#160;</td>
          <td class="paramname"><em>t</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">Ret(T::*)(Params...)&#160;</td>
          <td class="paramname"><em>func</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">Args &amp;&amp;...&#160;</td>
          <td class="paramname"><em>args</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<dl class="deprecated"><dt><b><a class="el" href="deprecated.html#_deprecated000017">Deprecated:</a></b></dt><dd></dd></dl>
<p>DEPRECATED. Use the versions of <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a50dfd5cfa77b1e6b4645c4bd46ce7dd0">make_task_result()</a> which take callable objects.</p>
<p>This is a wrapper which will take a member function pointer to a member function which returns a value, together with arguments, and constructs a <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> task which will execute that function by calling <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a81f7c8af3295d92c0e19d7f9498a4078">add_task()</a> with an appropriate callback object, and returns a <a class="el" href="classCgu_1_1AsyncResult.html" title="A thread-safe asynchronous result class. ">Cgu::AsyncResult</a> object (held by <a class="el" href="classCgu_1_1SharedLockPtr.html" title="This is a smart pointer for managing the lifetime of objects allocated on freestore, with a thread safe reference count. ">Cgu::SharedLockPtr</a>) which will provide the value that the function returns. It is thread safe (any thread may call this method, including another task running on the <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> object). Apart from the absence of a 'one thread per task' model, this method therefore provides a similar interface to the one provided by <a class="el" href="classCgu_1_1Thread_1_1Future.html" title="A class representing a pthread thread which will provide a value. ">Cgu::Thread::Future</a>. See the documentation on <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a81f7c8af3295d92c0e19d7f9498a4078">add_task()</a> for further information about how task execution works.</p>
<p>This method can take up to three bound arguments for the target member function.</p>
<p>If the function passed to this method exits by throwing <a class="el" href="classCgu_1_1Thread_1_1Exit.html" title="A class which can be thrown to terminate the throwing thread. ">Thread::Exit</a> or some other exception, then the exception will be consumed and the returned <a class="el" href="classCgu_1_1AsyncResult.html" title="A thread-safe asynchronous result class. ">Cgu::AsyncResult</a> object's get() method will unblock and its get_error() method will return -1.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">t</td><td>The object whose member function passed to this method is to execute as a task. </td></tr>
    <tr><td class="paramname">func</td><td>The member function to be executed as a task. </td></tr>
    <tr><td class="paramname">args</td><td>The arguments to be passed to that member function. </td></tr>
  </table>
  </dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname">std::bad_alloc</td><td>This exception will be thrown if memory is exhausted and the system throws in that case. (On systems with over-commit/lazy-commit combined with virtual memory (swap), it is rarely useful to check for memory exhaustion). If this exception is thrown, the task will not start. </td></tr>
    <tr><td class="paramname"><a class="el" href="structCgu_1_1Thread_1_1TaskError.html">Cgu::Thread::TaskError</a></td><td>This exception will be thrown if <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#ae61908c1fb1973f7ce66ab6ae308fe02">stop_all()</a> has previously been called. It will also be thrown if <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a2ac8ae63abc1a6b433f40e861d39ca33">is_error()</a> would return true because this class's internal thread pool loop implementation has thrown std::bad_alloc, or a thread has failed to start correctly. (On systems with over-commit/lazy-commit combined with virtual memory (swap), it is rarely useful to check for memory exhaustion, but there may be some specialized cases where the return value of <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a2ac8ae63abc1a6b433f40e861d39ca33">is_error()</a> is useful.) If this exception is thrown, the task will not start. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section note"><dt>Note</dt><dd>This method will also throw if the copy or move constructor of a bound argument throws. If such an exception is thrown, the task will not start.</dd></dl>
<p>Since 2.0.13 </p>

</div>
</div>
<a class="anchor" id="a1e8f15778414096e0baa024a30e3445f"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class Ret , class... Params, class... Args, class T &gt; </div>
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classCgu_1_1SharedLockPtr.html">Cgu::SharedLockPtr</a>&lt;<a class="el" href="classCgu_1_1AsyncResult.html">Cgu::AsyncResult</a>&lt;Ret&gt; &gt; Cgu::Thread::TaskManager::make_task_result </td>
          <td>(</td>
          <td class="paramtype">const T &amp;&#160;</td>
          <td class="paramname"><em>t</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">Ret(T::*)(Params...) const&#160;</td>
          <td class="paramname"><em>func</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">Args &amp;&amp;...&#160;</td>
          <td class="paramname"><em>args</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<dl class="deprecated"><dt><b><a class="el" href="deprecated.html#_deprecated000020">Deprecated:</a></b></dt><dd></dd></dl>
<p>DEPRECATED. Use the versions of <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a50dfd5cfa77b1e6b4645c4bd46ce7dd0">make_task_result()</a> which take callable objects.</p>
<p>This is a wrapper which will take a member function pointer to a member function which returns a value, together with arguments, and constructs a <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> task which will execute that function by calling <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a81f7c8af3295d92c0e19d7f9498a4078">add_task()</a> with an appropriate callback object, and returns a <a class="el" href="classCgu_1_1AsyncResult.html" title="A thread-safe asynchronous result class. ">Cgu::AsyncResult</a> object (held by <a class="el" href="classCgu_1_1SharedLockPtr.html" title="This is a smart pointer for managing the lifetime of objects allocated on freestore, with a thread safe reference count. ">Cgu::SharedLockPtr</a>) which will provide the value that the function returns. It is thread safe (any thread may call this method, including another task running on the <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> object). Apart from the absence of a 'one thread per task' model, this method therefore provides a similar interface to the one provided by <a class="el" href="classCgu_1_1Thread_1_1Future.html" title="A class representing a pthread thread which will provide a value. ">Cgu::Thread::Future</a>. See the documentation on <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a81f7c8af3295d92c0e19d7f9498a4078">add_task()</a> for further information about how task execution works.</p>
<p>This method can take up to three bound arguments for the target member function.</p>
<p>If the function passed to this method exits by throwing <a class="el" href="classCgu_1_1Thread_1_1Exit.html" title="A class which can be thrown to terminate the throwing thread. ">Thread::Exit</a> or some other exception, then the exception will be consumed and the returned <a class="el" href="classCgu_1_1AsyncResult.html" title="A thread-safe asynchronous result class. ">Cgu::AsyncResult</a> object's get() method will unblock and its get_error() method will return -1.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">t</td><td>The object whose member function passed to this method is to execute as a task. </td></tr>
    <tr><td class="paramname">func</td><td>The member function to be executed as a task. </td></tr>
    <tr><td class="paramname">args</td><td>The arguments to be passed to that member function. </td></tr>
  </table>
  </dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname">std::bad_alloc</td><td>This exception will be thrown if memory is exhausted and the system throws in that case. (On systems with over-commit/lazy-commit combined with virtual memory (swap), it is rarely useful to check for memory exhaustion). If this exception is thrown, the task will not start. </td></tr>
    <tr><td class="paramname"><a class="el" href="structCgu_1_1Thread_1_1TaskError.html">Cgu::Thread::TaskError</a></td><td>This exception will be thrown if <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#ae61908c1fb1973f7ce66ab6ae308fe02">stop_all()</a> has previously been called. It will also be thrown if <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a2ac8ae63abc1a6b433f40e861d39ca33">is_error()</a> would return true because this class's internal thread pool loop implementation has thrown std::bad_alloc, or a thread has failed to start correctly. (On systems with over-commit/lazy-commit combined with virtual memory (swap), it is rarely useful to check for memory exhaustion, but there may be some specialized cases where the return value of <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a2ac8ae63abc1a6b433f40e861d39ca33">is_error()</a> is useful.) If this exception is thrown, the task will not start. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section note"><dt>Note</dt><dd>This method will also throw if the copy or move constructor of a bound argument throws. If such an exception is thrown, the task will not start.</dd></dl>
<p>Since 2.0.13 </p>

</div>
</div>
<a class="anchor" id="a5e8ffae7635f0265fb6874d583e87890"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class Ret , class... Params, class... Args&gt; </div>
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classCgu_1_1SharedLockPtr.html">Cgu::SharedLockPtr</a>&lt;<a class="el" href="classCgu_1_1AsyncResult.html">Cgu::AsyncResult</a>&lt;Ret&gt; &gt; Cgu::Thread::TaskManager::make_task_result </td>
          <td>(</td>
          <td class="paramtype">Ret(*)(Params...)&#160;</td>
          <td class="paramname"><em>func</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">Args &amp;&amp;...&#160;</td>
          <td class="paramname"><em>args</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<dl class="deprecated"><dt><b><a class="el" href="deprecated.html#_deprecated000023">Deprecated:</a></b></dt><dd></dd></dl>
<p>DEPRECATED. Use the versions of <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a50dfd5cfa77b1e6b4645c4bd46ce7dd0">make_task_result()</a> which take callable objects.</p>
<p>This is a wrapper which will take a pointer to a function which returns a value, together with arguments, and constructs a <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> task which will execute that function by calling <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a81f7c8af3295d92c0e19d7f9498a4078">add_task()</a> with an appropriate callback object, and returns a <a class="el" href="classCgu_1_1AsyncResult.html" title="A thread-safe asynchronous result class. ">Cgu::AsyncResult</a> object (held by <a class="el" href="classCgu_1_1SharedLockPtr.html" title="This is a smart pointer for managing the lifetime of objects allocated on freestore, with a thread safe reference count. ">Cgu::SharedLockPtr</a>) which will provide the value that the function returns. It is thread safe (any thread may call this method, including another task running on the <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> object). Apart from the absence of a 'one thread per task' model, this method therefore provides a similar interface to the one provided by <a class="el" href="classCgu_1_1Thread_1_1Future.html" title="A class representing a pthread thread which will provide a value. ">Cgu::Thread::Future</a>. See the documentation on <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a81f7c8af3295d92c0e19d7f9498a4078">add_task()</a> for further information about how task execution works.</p>
<p>This method can take up to four bound arguments for the target function.</p>
<p>If the function passed to this method exits by throwing <a class="el" href="classCgu_1_1Thread_1_1Exit.html" title="A class which can be thrown to terminate the throwing thread. ">Thread::Exit</a> or some other exception, then the exception will be consumed and the returned <a class="el" href="classCgu_1_1AsyncResult.html" title="A thread-safe asynchronous result class. ">Cgu::AsyncResult</a> object's get() method will unblock and its get_error() method will return -1.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">func</td><td>The function to be executed as a task. </td></tr>
    <tr><td class="paramname">args</td><td>The arguments to be passed to that function. </td></tr>
  </table>
  </dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname">std::bad_alloc</td><td>This exception will be thrown if memory is exhausted and the system throws in that case. (On systems with over-commit/lazy-commit combined with virtual memory (swap), it is rarely useful to check for memory exhaustion). If this exception is thrown, the task will not start. </td></tr>
    <tr><td class="paramname"><a class="el" href="structCgu_1_1Thread_1_1TaskError.html">Cgu::Thread::TaskError</a></td><td>This exception will be thrown if <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#ae61908c1fb1973f7ce66ab6ae308fe02">stop_all()</a> has previously been called. It will also be thrown if <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a2ac8ae63abc1a6b433f40e861d39ca33">is_error()</a> would return true because this class's internal thread pool loop implementation has thrown std::bad_alloc, or a thread has failed to start correctly. (On systems with over-commit/lazy-commit combined with virtual memory (swap), it is rarely useful to check for memory exhaustion, but there may be some specialized cases where the return value of <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a2ac8ae63abc1a6b433f40e861d39ca33">is_error()</a> is useful.) If this exception is thrown, the task will not start. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section note"><dt>Note</dt><dd>This method will also throw if the copy or move constructor of a bound argument throws. If such an exception is thrown, the task will not start.</dd></dl>
<p>Since 2.0.13 </p>

</div>
</div>
<a class="anchor" id="acc60f7fa8af2062cb2200eb3fead0fac"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class Ret , class Func &gt; </div>
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classCgu_1_1SharedLockPtr.html">Cgu::SharedLockPtr</a>&lt;<a class="el" href="classCgu_1_1AsyncResult.html">Cgu::AsyncResult</a>&lt;Ret&gt; &gt; Cgu::Thread::TaskManager::make_task_result </td>
          <td>(</td>
          <td class="paramtype">Func &amp;&amp;&#160;</td>
          <td class="paramname"><em>f</em>)</td><td></td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>This is a wrapper which will take a callable object (such as a std::function object, a lambda or the return value of std::bind) representing a function which returns a value, and constructs a <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> task which will execute that function by calling <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a81f7c8af3295d92c0e19d7f9498a4078">add_task()</a> with an appropriate callback object, and returns a <a class="el" href="classCgu_1_1AsyncResult.html" title="A thread-safe asynchronous result class. ">Cgu::AsyncResult</a> object (held by <a class="el" href="classCgu_1_1SharedLockPtr.html" title="This is a smart pointer for managing the lifetime of objects allocated on freestore, with a thread safe reference count. ">Cgu::SharedLockPtr</a>) which will provide the value that the function returns. It is thread safe (any thread may call this method, including another task running on the <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> object). Apart from the absence of a 'one thread per task' model, this method therefore provides a similar interface to the one provided by <a class="el" href="classCgu_1_1Thread_1_1Future.html" title="A class representing a pthread thread which will provide a value. ">Cgu::Thread::Future</a>. See the documentation on <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a81f7c8af3295d92c0e19d7f9498a4078">add_task()</a> for further information about how task execution works.</p>
<p>If the callable object passed to this method exits by throwing <a class="el" href="classCgu_1_1Thread_1_1Exit.html" title="A class which can be thrown to terminate the throwing thread. ">Thread::Exit</a> or some other exception, then the exception will be consumed and the returned <a class="el" href="classCgu_1_1AsyncResult.html" title="A thread-safe asynchronous result class. ">Cgu::AsyncResult</a> object's get() method will unblock and its get_error() method will return -1.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">f</td><td>The callable object to be executed as a task, such as formed by a lambda expression or the result of std::bind. It should return a value (it cannot return void). </td></tr>
  </table>
  </dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname">std::bad_alloc</td><td>This exception will be thrown if memory is exhausted and the system throws in that case. (On systems with over-commit/lazy-commit combined with virtual memory (swap), it is rarely useful to check for memory exhaustion). If this exception is thrown, the task will not start. </td></tr>
    <tr><td class="paramname"><a class="el" href="structCgu_1_1Thread_1_1TaskError.html">Cgu::Thread::TaskError</a></td><td>This exception will be thrown if <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#ae61908c1fb1973f7ce66ab6ae308fe02">stop_all()</a> has previously been called. It will also be thrown if <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a2ac8ae63abc1a6b433f40e861d39ca33">is_error()</a> would return true because this class's internal thread pool loop implementation has thrown std::bad_alloc, or a thread has failed to start correctly. (On systems with over-commit/lazy-commit combined with virtual memory (swap), it is rarely useful to check for memory exhaustion, but there may be some specialized cases where the return value of <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a2ac8ae63abc1a6b433f40e861d39ca33">is_error()</a> is useful.) If this exception is thrown, the task will not start. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section note"><dt>Note</dt><dd>1. This method will also throw if the copy or move constructor of the callable object throws. If such an exception is thrown, the task will not start. </dd>
<dd>
2. If the callable object passed as an argument has both const and non-const operator()() methods, the non-const version will be called even if the callable object passed is a const object.</dd></dl>
<p>Since 2.0.14 </p>

</div>
</div>
<a class="anchor" id="a7a013fd7b21096fa76e39cbe5475d31b"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class Ret , class... Params, class... Args, class T &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void Cgu::Thread::TaskManager::make_task_when </td>
          <td>(</td>
          <td class="paramtype">std::unique_ptr&lt; const <a class="el" href="classCgu_1_1Callback_1_1CallbackArg.html">Cgu::Callback::CallbackArg</a>&lt; const Ret &amp; &gt;&gt;&#160;</td>
          <td class="paramname"><em>when</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">GMainContext *&#160;</td>
          <td class="paramname"><em>context</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">T &amp;&#160;</td>
          <td class="paramname"><em>t</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">Ret(T::*)(Params...)&#160;</td>
          <td class="paramname"><em>func</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">Args &amp;&amp;...&#160;</td>
          <td class="paramname"><em>args</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<dl class="deprecated"><dt><b><a class="el" href="deprecated.html#_deprecated000019">Deprecated:</a></b></dt><dd></dd></dl>
<p>DEPRECATED. Use the versions of <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a7a013fd7b21096fa76e39cbe5475d31b">make_task_when()</a> which take callable objects.</p>
<p>This is an abbreviated version of <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#abe374ca418bbe53e6c5228ecc1b6a3ac">make_task_when_full()</a>, which is for use when it is known that the member function passed to this method, and the copy constructors of any non-reference bound arguments passed to it, do not throw, and the user is not interested in std::bad_alloc and does not need a <a class="el" href="classCgu_1_1Releaser.html" title="A class used for tracking EmitterArg and SafeEmitterArg connections. ">Cgu::Releaser</a> object for the 'when' callback (which is likely to cover the majority of uses, particularly when composing tasks using glib because glib terminates the program if it is unable to obtain memory).</p>
<p>This method can take up to three bound arguments for the target member function.</p>
<p>Like <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#abe374ca418bbe53e6c5228ecc1b6a3ac">make_task_when_full()</a>, this method is a wrapper which will take a member function pointer to a member function which returns a value, together with arguments, and constructs a <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> task which will execute that function by calling <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a81f7c8af3295d92c0e19d7f9498a4078">add_task()</a> with an appropriate callback object, and causes the 'when' callback passed as an argument to this method to be executed by a glib main loop if and when the task finishes correctly - the 'when' callback is passed the member function's return value when it is invoked. It is thread safe (any thread may call this method, including another task running on the <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> object). Apart from the absence of a 'one thread per task' model, this method therefore provides a similar interface to the one provided by <a class="el" href="classCgu_1_1Thread_1_1Future.html" title="A class representing a pthread thread which will provide a value. ">Cgu::Thread::Future</a>. See the documentation on <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a81f7c8af3295d92c0e19d7f9498a4078">add_task()</a> for further information about how task execution works.</p>
<p>The 'when' callback will execute with G_PRIORITY_DEFAULT priority in the main loop.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">when</td><td>A callback which will be executed if and when the function passed to this method finishes correctly. The callback is passed that function's return value when it is invoked. If an exception propagates from the 'when' callback, this will be consumed and a g_critical() warning will be issued. The callback will execute in the glib main loop whose GMainContext object is passed to the 'context' argument of this method. </td></tr>
    <tr><td class="paramname">context</td><td>The glib main context of the main loop in which the 'when' callback is to be executed. A value 0/NULL/nullptr will cause the callback to be executed in the main program loop. </td></tr>
    <tr><td class="paramname">t</td><td>The object whose member function passed to this method is to execute as a task. </td></tr>
    <tr><td class="paramname">func</td><td>The member function to be executed as a task. If an exception propagates from the task, the exception will be consumed and (if the thrown object's type is not <a class="el" href="classCgu_1_1Thread_1_1Exit.html" title="A class which can be thrown to terminate the throwing thread. ">Cgu::Thread::Exit</a>) a g_critical() warning will be issued. </td></tr>
    <tr><td class="paramname">args</td><td>The arguments to be passed to that member function. </td></tr>
  </table>
  </dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname">std::bad_alloc</td><td>This exception will be thrown if memory is exhausted and the system throws in that case. (On systems with over-commit/lazy-commit combined with virtual memory (swap), it is rarely useful to check for memory exhaustion). If this exception is thrown, the task will not start (which also means that the 'when' callback will not execute). </td></tr>
    <tr><td class="paramname"><a class="el" href="structCgu_1_1Thread_1_1TaskError.html">Cgu::Thread::TaskError</a></td><td>This exception will be thrown if <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#ae61908c1fb1973f7ce66ab6ae308fe02">stop_all()</a> has previously been called. It will also be thrown if <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a2ac8ae63abc1a6b433f40e861d39ca33">is_error()</a> would return true because this class's internal thread pool loop implementation has thrown std::bad_alloc, or a thread has failed to start correctly. (On systems with over-commit/lazy-commit combined with virtual memory (swap), it is rarely useful to check for memory exhaustion, but there may be some specialized cases where the return value of <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a2ac8ae63abc1a6b433f40e861d39ca33">is_error()</a> is useful.) If this exception is thrown, the task will not start (which also means that the 'when' callback will not execute). </td></tr>
  </table>
  </dd>
</dl>
<dl class="section note"><dt>Note</dt><dd>This method will also throw if the copy or move constructor of a bound argument throws. If such an exception is thrown, the task will not start (which also means that the 'when' callback will not execute).</dd></dl>
<p>Since 2.0.13 </p>

</div>
</div>
<a class="anchor" id="a6bde1cd838159ded5a432d5753997242"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class Ret , class... Params, class... Args, class T &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void Cgu::Thread::TaskManager::make_task_when </td>
          <td>(</td>
          <td class="paramtype">std::unique_ptr&lt; const <a class="el" href="classCgu_1_1Callback_1_1CallbackArg.html">Cgu::Callback::CallbackArg</a>&lt; const Ret &amp; &gt;&gt;&#160;</td>
          <td class="paramname"><em>when</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">GMainContext *&#160;</td>
          <td class="paramname"><em>context</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const T &amp;&#160;</td>
          <td class="paramname"><em>t</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">Ret(T::*)(Params...) const&#160;</td>
          <td class="paramname"><em>func</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">Args &amp;&amp;...&#160;</td>
          <td class="paramname"><em>args</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<dl class="deprecated"><dt><b><a class="el" href="deprecated.html#_deprecated000022">Deprecated:</a></b></dt><dd></dd></dl>
<p>DEPRECATED. Use the versions of <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a7a013fd7b21096fa76e39cbe5475d31b">make_task_when()</a> which take callable objects.</p>
<p>This is an abbreviated version of <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#abe374ca418bbe53e6c5228ecc1b6a3ac">make_task_when_full()</a>, which is for use when it is known that the member function passed to this method, and the copy constructors of any non-reference bound arguments passed to it, do not throw, and the user is not interested in std::bad_alloc and does not need a <a class="el" href="classCgu_1_1Releaser.html" title="A class used for tracking EmitterArg and SafeEmitterArg connections. ">Cgu::Releaser</a> object for the 'when' callback (which is likely to cover the majority of uses, particularly when composing tasks using glib because glib terminates the program if it is unable to obtain memory).</p>
<p>This method can take up to three bound arguments for the target member function.</p>
<p>Like <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#abe374ca418bbe53e6c5228ecc1b6a3ac">make_task_when_full()</a>, this method is a wrapper which will take a member function pointer to a member function which returns a value, together with arguments, and constructs a <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> task which will execute that function by calling <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a81f7c8af3295d92c0e19d7f9498a4078">add_task()</a> with an appropriate callback object, and causes the 'when' callback passed as an argument to this method to be executed by a glib main loop if and when the task finishes correctly - the 'when' callback is passed the member function's return value when it is invoked. It is thread safe (any thread may call this method, including another task running on the <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> object). Apart from the absence of a 'one thread per task' model, this method therefore provides a similar interface to the one provided by <a class="el" href="classCgu_1_1Thread_1_1Future.html" title="A class representing a pthread thread which will provide a value. ">Cgu::Thread::Future</a>. See the documentation on <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a81f7c8af3295d92c0e19d7f9498a4078">add_task()</a> for further information about how task execution works.</p>
<p>The 'when' callback will execute with G_PRIORITY_DEFAULT priority in the main loop.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">when</td><td>A callback which will be executed if and when the function passed to this method finishes correctly. The callback is passed that function's return value when it is invoked. If an exception propagates from the 'when' callback, this will be consumed and a g_critical() warning will be issued. The callback will execute in the glib main loop whose GMainContext object is passed to the 'context' argument of this method. </td></tr>
    <tr><td class="paramname">context</td><td>The glib main context of the main loop in which the 'when' callback is to be executed. A value 0/NULL/nullptr will cause the callback to be executed in the main program loop. </td></tr>
    <tr><td class="paramname">t</td><td>The object whose member function passed to this method is to execute as a task. </td></tr>
    <tr><td class="paramname">func</td><td>The member function to be executed as a task. If an exception propagates from the task, the exception will be consumed and (if the thrown object's type is not <a class="el" href="classCgu_1_1Thread_1_1Exit.html" title="A class which can be thrown to terminate the throwing thread. ">Cgu::Thread::Exit</a>) a g_critical() warning will be issued. </td></tr>
    <tr><td class="paramname">args</td><td>The arguments to be passed to that member function. </td></tr>
  </table>
  </dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname">std::bad_alloc</td><td>This exception will be thrown if memory is exhausted and the system throws in that case. (On systems with over-commit/lazy-commit combined with virtual memory (swap), it is rarely useful to check for memory exhaustion). If this exception is thrown, the task will not start (which also means that the 'when' callback will not execute). </td></tr>
    <tr><td class="paramname"><a class="el" href="structCgu_1_1Thread_1_1TaskError.html">Cgu::Thread::TaskError</a></td><td>This exception will be thrown if <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#ae61908c1fb1973f7ce66ab6ae308fe02">stop_all()</a> has previously been called. It will also be thrown if <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a2ac8ae63abc1a6b433f40e861d39ca33">is_error()</a> would return true because this class's internal thread pool loop implementation has thrown std::bad_alloc, or a thread has failed to start correctly. (On systems with over-commit/lazy-commit combined with virtual memory (swap), it is rarely useful to check for memory exhaustion, but there may be some specialized cases where the return value of <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a2ac8ae63abc1a6b433f40e861d39ca33">is_error()</a> is useful.) If this exception is thrown, the task will not start (which also means that the 'when' callback will not execute). </td></tr>
  </table>
  </dd>
</dl>
<dl class="section note"><dt>Note</dt><dd>This method will also throw if the copy or move constructor of a bound argument throws. If such an exception is thrown, the task will not start (which also means that the 'when' callback will not execute).</dd></dl>
<p>Since 2.0.13 </p>

</div>
</div>
<a class="anchor" id="a397a8391bd656fd9d7c115866c474475"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class Ret , class... Params, class... Args&gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void Cgu::Thread::TaskManager::make_task_when </td>
          <td>(</td>
          <td class="paramtype">std::unique_ptr&lt; const <a class="el" href="classCgu_1_1Callback_1_1CallbackArg.html">Cgu::Callback::CallbackArg</a>&lt; const Ret &amp; &gt;&gt;&#160;</td>
          <td class="paramname"><em>when</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">GMainContext *&#160;</td>
          <td class="paramname"><em>context</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">Ret(*)(Params...)&#160;</td>
          <td class="paramname"><em>func</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">Args &amp;&amp;...&#160;</td>
          <td class="paramname"><em>args</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<dl class="deprecated"><dt><b><a class="el" href="deprecated.html#_deprecated000025">Deprecated:</a></b></dt><dd></dd></dl>
<p>DEPRECATED. Use the versions of <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a7a013fd7b21096fa76e39cbe5475d31b">make_task_when()</a> which take callable objects.</p>
<p>This is an abbreviated version of <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#abe374ca418bbe53e6c5228ecc1b6a3ac">make_task_when_full()</a>, which is for use when it is known that the function passed to this method, and the copy constructors of any non-reference bound arguments passed to it, do not throw, and the user is not interested in std::bad_alloc and does not need a <a class="el" href="classCgu_1_1Releaser.html" title="A class used for tracking EmitterArg and SafeEmitterArg connections. ">Cgu::Releaser</a> object for the 'when' callback (which is likely to cover the majority of uses, particularly when composing tasks using glib because glib terminates the program if it is unable to obtain memory).</p>
<p>This method can take up to four bound arguments for the target function.</p>
<p>Like <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#abe374ca418bbe53e6c5228ecc1b6a3ac">make_task_when_full()</a>, this method is a wrapper which will take a pointer to a function which returns a value, together with arguments, and constructs a <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> task which will execute that function by calling <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a81f7c8af3295d92c0e19d7f9498a4078">add_task()</a> with an appropriate callback object, and causes the 'when' callback passed as an argument to this method to be executed by a glib main loop if and when the task finishes correctly - the 'when' callback is passed the function's return value when it is invoked. It is thread safe (any thread may call this method, including another task running on the <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> object). Apart from the absence of a 'one thread per task' model, this method therefore provides a similar interface to the one provided by <a class="el" href="classCgu_1_1Thread_1_1Future.html" title="A class representing a pthread thread which will provide a value. ">Cgu::Thread::Future</a>. See the documentation on <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a81f7c8af3295d92c0e19d7f9498a4078">add_task()</a> for further information about how task execution works.</p>
<p>The 'when' callback will execute with G_PRIORITY_DEFAULT priority in the main loop.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">when</td><td>A callback which will be executed if and when the function passed to this method finishes correctly. The callback is passed that function's return value when it is invoked. If an exception propagates from the 'when' callback, this will be consumed and a g_critical() warning will be issued. The callback will execute in the glib main loop whose GMainContext object is passed to the 'context' argument of this method. </td></tr>
    <tr><td class="paramname">context</td><td>The glib main context of the main loop in which the 'when' callback is to be executed. A value 0/NULL/nullptr will cause the callback to be executed in the main program loop. </td></tr>
    <tr><td class="paramname">func</td><td>The function to be executed as a task. If an exception propagates from the task, the exception will be consumed and (if the thrown object's type is not <a class="el" href="classCgu_1_1Thread_1_1Exit.html" title="A class which can be thrown to terminate the throwing thread. ">Cgu::Thread::Exit</a>) a g_critical() warning will be issued. </td></tr>
    <tr><td class="paramname">args</td><td>The arguments to be passed to that function. </td></tr>
  </table>
  </dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname">std::bad_alloc</td><td>This exception will be thrown if memory is exhausted and the system throws in that case. (On systems with over-commit/lazy-commit combined with virtual memory (swap), it is rarely useful to check for memory exhaustion). If this exception is thrown, the task will not start (which also means that the 'when' callback will not execute). </td></tr>
    <tr><td class="paramname"><a class="el" href="structCgu_1_1Thread_1_1TaskError.html">Cgu::Thread::TaskError</a></td><td>This exception will be thrown if <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#ae61908c1fb1973f7ce66ab6ae308fe02">stop_all()</a> has previously been called. It will also be thrown if <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a2ac8ae63abc1a6b433f40e861d39ca33">is_error()</a> would return true because this class's internal thread pool loop implementation has thrown std::bad_alloc, or a thread has failed to start correctly. (On systems with over-commit/lazy-commit combined with virtual memory (swap), it is rarely useful to check for memory exhaustion, but there may be some specialized cases where the return value of <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a2ac8ae63abc1a6b433f40e861d39ca33">is_error()</a> is useful.) If this exception is thrown, the task will not start (which also means that the 'when' callback will not execute). </td></tr>
  </table>
  </dd>
</dl>
<dl class="section note"><dt>Note</dt><dd>This method will also throw if the copy or move constructor of a bound argument throws. If such an exception is thrown, the task will not start (which also means that the 'when' callback will not execute).</dd></dl>
<p>Since 2.0.13 </p>

</div>
</div>
<a class="anchor" id="af7d7406d487e71d3954b295c4bd2518d"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class Ret , class Func &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void Cgu::Thread::TaskManager::make_task_when </td>
          <td>(</td>
          <td class="paramtype">std::unique_ptr&lt; const <a class="el" href="classCgu_1_1Callback_1_1CallbackArg.html">Cgu::Callback::CallbackArg</a>&lt; const Ret &amp; &gt;&gt;&#160;</td>
          <td class="paramname"><em>when</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">GMainContext *&#160;</td>
          <td class="paramname"><em>context</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">Func &amp;&amp;&#160;</td>
          <td class="paramname"><em>f</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>This is an abbreviated version of <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#abe374ca418bbe53e6c5228ecc1b6a3ac">make_task_when_full()</a>, which is for use when it is known that the callable object passed to this method does not throw, and the user is not interested in std::bad_alloc and does not need a <a class="el" href="classCgu_1_1Releaser.html" title="A class used for tracking EmitterArg and SafeEmitterArg connections. ">Cgu::Releaser</a> object for the 'when' callback (which is likely to cover the majority of uses, particularly when composing tasks using glib because glib terminates the program if it is unable to obtain memory).</p>
<p>Like <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#abe374ca418bbe53e6c5228ecc1b6a3ac">make_task_when_full()</a>, this method is a wrapper which will take a callable object which returns a value, and constructs a <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> task which will execute that object by calling <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a81f7c8af3295d92c0e19d7f9498a4078">add_task()</a> with an appropriate callback object, and causes the 'when' callback passed as an argument to this method to be executed by a glib main loop if and when the task finishes correctly - the 'when' callback is passed the callable object's return value when it is invoked. It is thread safe (any thread may call this method, including another task running on the <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> object). Apart from the absence of a 'one thread per task' model, this method therefore provides a similar interface to the one provided by <a class="el" href="classCgu_1_1Thread_1_1Future.html" title="A class representing a pthread thread which will provide a value. ">Cgu::Thread::Future</a>. See the documentation on <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a81f7c8af3295d92c0e19d7f9498a4078">add_task()</a> for further information about how task execution works.</p>
<p>The 'when' callback will execute with G_PRIORITY_DEFAULT priority in the main loop.</p>
<p>There is a similar <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a8ebf8f3fb5d9622d5369005c9dd7a14b">make_task_compose()</a> function which has the callable object to be executed as a task as its first argument and the 'when' callback as its last argument, in order to aid task composition.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">when</td><td>A callback which will be executed if and when the callable object passed to this method finishes correctly. The callback is passed that object's return value when it is invoked. If an exception propagates from the 'when' callback, this will be consumed and a g_critical() warning will be issued. The callback will execute in the glib main loop whose GMainContext object is passed to the 'context' argument of this method. </td></tr>
    <tr><td class="paramname">context</td><td>The glib main context of the main loop in which the 'when' callback is to be executed. A value 0/NULL/nullptr will cause the callback to be executed in the main program loop. </td></tr>
    <tr><td class="paramname">f</td><td>The callable object to be executed as a task, such as formed by a lambda expression or the result of std::bind. It should return a value (it cannot return void). It must be fully bound (that is, it must take no arguments when called). If an exception propagates from the task, the exception will be consumed and (if the thrown object's type is not <a class="el" href="classCgu_1_1Thread_1_1Exit.html" title="A class which can be thrown to terminate the throwing thread. ">Cgu::Thread::Exit</a>) a g_critical() warning will be issued. </td></tr>
  </table>
  </dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname">std::bad_alloc</td><td>This exception will be thrown if memory is exhausted and the system throws in that case. (On systems with over-commit/lazy-commit combined with virtual memory (swap), it is rarely useful to check for memory exhaustion). If this exception is thrown, the task will not start (which also means that the 'when' callback will not execute). </td></tr>
    <tr><td class="paramname"><a class="el" href="structCgu_1_1Thread_1_1TaskError.html">Cgu::Thread::TaskError</a></td><td>This exception will be thrown if <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#ae61908c1fb1973f7ce66ab6ae308fe02">stop_all()</a> has previously been called. It will also be thrown if <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a2ac8ae63abc1a6b433f40e861d39ca33">is_error()</a> would return true because this class's internal thread pool loop implementation has thrown std::bad_alloc, or a thread has failed to start correctly. (On systems with over-commit/lazy-commit combined with virtual memory (swap), it is rarely useful to check for memory exhaustion, but there may be some specialized cases where the return value of <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a2ac8ae63abc1a6b433f40e861d39ca33">is_error()</a> is useful.) If this exception is thrown, the task will not start (which also means that the 'when' callback will not execute). </td></tr>
  </table>
  </dd>
</dl>
<dl class="section note"><dt>Note</dt><dd>1. This method will also throw if the copy or move constructor of the callable object throws. If such an exception is thrown, the task will not start (which also means that the 'when' callback will not execute). </dd>
<dd>
2. If the callable object passed as an argument has both const and non-const operator()() methods, the non-const version will be called even if the callable object passed is a const object.</dd></dl>
<p>Since 2.0.14 </p>

</div>
</div>
<a class="anchor" id="a5ebba2ecf246b24c3406aa60585ae523"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class When , class Func , class  = typename std::enable_if&lt;!std::is_convertible&lt;When, std::unique_ptr&lt;const Callback::CallbackArg&lt;const typename std::result_of&lt;Func()&gt;::type&amp;&gt;&gt;&gt;::value&gt;::type&gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void Cgu::Thread::TaskManager::make_task_when </td>
          <td>(</td>
          <td class="paramtype">When &amp;&amp;&#160;</td>
          <td class="paramname"><em>when</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">GMainContext *&#160;</td>
          <td class="paramname"><em>context</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">Func &amp;&amp;&#160;</td>
          <td class="paramname"><em>func</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>This is an abbreviated version of <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#abe374ca418bbe53e6c5228ecc1b6a3ac">make_task_when_full()</a>, which is for use when it is known that the callable object passed to the 'func' argument of this method does not throw, and the user is not interested in std::bad_alloc and does not need a <a class="el" href="classCgu_1_1Releaser.html" title="A class used for tracking EmitterArg and SafeEmitterArg connections. ">Cgu::Releaser</a> object for the 'when' callback (which is likely to cover the majority of uses, particularly when composing tasks using glib because glib terminates the program if it is unable to obtain memory).</p>
<p>Like <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#abe374ca418bbe53e6c5228ecc1b6a3ac">make_task_when_full()</a>, this method is a wrapper which takes a callable object which returns a value as its 'func' argument, and constructs a <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> task which will execute that object by calling <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a81f7c8af3295d92c0e19d7f9498a4078">add_task()</a> with an appropriate callback object, and causes the 'when' callback passed as an argument to this method to be executed by a glib main loop if and when the task finishes correctly - the 'when' callback is passed the return value of the 'func' argument when it is invoked. It is thread safe (any thread may call this method, including another task running on the <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> object). Apart from the absence of a 'one thread per task' model, this method therefore provides a similar interface to the one provided by <a class="el" href="classCgu_1_1Thread_1_1Future.html" title="A class representing a pthread thread which will provide a value. ">Cgu::Thread::Future</a>. See the documentation on <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a81f7c8af3295d92c0e19d7f9498a4078">add_task()</a> for further information about how task execution works.</p>
<p>The 'when' callback will execute with G_PRIORITY_DEFAULT priority in the main loop.</p>
<p>There is a similar <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a8ebf8f3fb5d9622d5369005c9dd7a14b">make_task_compose()</a> function which has the callable object to be executed as a task as its first argument and the 'when' callback as its last argument, in order to aid task composition.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">when</td><td>A callable object (such as formed by a lambda expression or the result of std::bind) which will be executed if and when the 'func' object passed to this method finishes correctly. The 'when' callback is passed that objects's return value when invoked, and should take a single unbound argument, namely a reference to const of the type of that return value. If an exception propagates from the 'when' callback, this will be consumed and a g_critical() warning will be issued. The callback will execute in the glib main loop whose GMainContext object is passed to the 'context' argument of this method. </td></tr>
    <tr><td class="paramname">context</td><td>The glib main context of the main loop in which the 'when' callback is to be executed. A value 0/NULL/nullptr will cause the callback to be executed in the main program loop. </td></tr>
    <tr><td class="paramname">func</td><td>The callable object to be executed as a task, such as formed by a lambda expression or the result of std::bind. It should return a value (it cannot return void). It must be fully bound (that is, it must take no arguments when called). If an exception propagates from the task, the exception will be consumed and (if the thrown object's type is not <a class="el" href="classCgu_1_1Thread_1_1Exit.html" title="A class which can be thrown to terminate the throwing thread. ">Cgu::Thread::Exit</a>) a g_critical() warning will be issued. </td></tr>
  </table>
  </dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname">std::bad_alloc</td><td>This exception will be thrown if memory is exhausted and the system throws in that case. (On systems with over-commit/lazy-commit combined with virtual memory (swap), it is rarely useful to check for memory exhaustion). If this exception is thrown, the task will not start (which also means that the 'when' callback will not execute). </td></tr>
    <tr><td class="paramname"><a class="el" href="structCgu_1_1Thread_1_1TaskError.html">Cgu::Thread::TaskError</a></td><td>This exception will be thrown if <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#ae61908c1fb1973f7ce66ab6ae308fe02">stop_all()</a> has previously been called. It will also be thrown if <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a2ac8ae63abc1a6b433f40e861d39ca33">is_error()</a> would return true because this class's internal thread pool loop implementation has thrown std::bad_alloc, or a thread has failed to start correctly. (On systems with over-commit/lazy-commit combined with virtual memory (swap), it is rarely useful to check for memory exhaustion, but there may be some specialized cases where the return value of <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a2ac8ae63abc1a6b433f40e861d39ca33">is_error()</a> is useful.) If this exception is thrown, the task will not start (which also means that the 'when' callback will not execute). </td></tr>
  </table>
  </dd>
</dl>
<dl class="section note"><dt>Note</dt><dd>1. This method will also throw if the copy or move constructor of the 'func' or 'when' callable objects throws. If such an exception is thrown, the task will not start (which also means that the 'when' callback will not execute). </dd>
<dd>
2. If any of the callable objects passed to this method have both const and non-const operator()() methods, the non-const version will be called even if the callable object passed is a const object.</dd></dl>
<p>Since 2.1.0 </p>

</div>
</div>
<a class="anchor" id="abe374ca418bbe53e6c5228ecc1b6a3ac"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class Ret , class... Params, class... Args, class T &gt; </div>
      <table class="memname">
        <tr>
          <td class="memname">void Cgu::Thread::TaskManager::make_task_when_full </td>
          <td>(</td>
          <td class="paramtype">std::unique_ptr&lt; const <a class="el" href="classCgu_1_1Callback_1_1CallbackArg.html">Cgu::Callback::CallbackArg</a>&lt; const Ret &amp; &gt;&gt;&#160;</td>
          <td class="paramname"><em>when</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="classCgu_1_1Releaser.html">Cgu::Releaser</a> *&#160;</td>
          <td class="paramname"><em>when_releaser</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">std::unique_ptr&lt; const <a class="el" href="namespaceCgu_1_1Callback.html#ab0fdf0ebb22f2a7cc813657f6d90a94d">Cgu::Callback::Callback</a> &gt;&#160;</td>
          <td class="paramname"><em>fail</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="classCgu_1_1Releaser.html">Cgu::Releaser</a> *&#160;</td>
          <td class="paramname"><em>fail_releaser</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">gint&#160;</td>
          <td class="paramname"><em>priority</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">GMainContext *&#160;</td>
          <td class="paramname"><em>context</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">T &amp;&#160;</td>
          <td class="paramname"><em>t</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">Ret(T::*)(Params...)&#160;</td>
          <td class="paramname"><em>func</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">Args &amp;&amp;...&#160;</td>
          <td class="paramname"><em>args</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<dl class="deprecated"><dt><b><a class="el" href="deprecated.html#_deprecated000018">Deprecated:</a></b></dt><dd></dd></dl>
<p>DEPRECATED. Use the versions of <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#abe374ca418bbe53e6c5228ecc1b6a3ac">make_task_when_full()</a> which take callable objects.</p>
<p>This is a wrapper which will take a member function pointer to a member function which returns a value, together with arguments, and constructs a <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> task which will execute that function by calling <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a81f7c8af3295d92c0e19d7f9498a4078">add_task()</a> with an appropriate callback object, and causes the 'when' callback passed as an argument to this method to be executed by a glib main loop if and when the task finishes correctly - the 'when' callback is passed the member function's return value when it is invoked. It is thread safe (any thread may call this method, including another task running on the <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> object). Apart from the absence of a 'one thread per task' model, this method therefore provides a similar interface to the one provided by <a class="el" href="classCgu_1_1Thread_1_1Future.html" title="A class representing a pthread thread which will provide a value. ">Cgu::Thread::Future</a>. See the documentation on <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a81f7c8af3295d92c0e19d7f9498a4078">add_task()</a> for further information about how task execution works.</p>
<p>This method can take up to three bound arguments for the target member function.</p>
<p>Note that unlike <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a81f7c8af3295d92c0e19d7f9498a4078">add_task()</a>, but like the 'fail' callback of <a class="el" href="classCgu_1_1Thread_1_1Future.html" title="A class representing a pthread thread which will provide a value. ">Cgu::Thread::Future</a> objects, if a fail callback is provided to this method and it executes, it will execute in the glib main loop whose GMainContext object is passed to the 'context' argument of this method.</p>
<p>Note also that if releasers are provided for the 'when' or 'fail' callbacks, these are passed by pointer and not by reference (this is so that a NULL pointer can indicate that no releaser is to be provided). If provided, a releaser will enable automatic disconnection of the 'when' or 'fail' callback, if the object having the callback function as a member is destroyed. For this to be race free, the lifetime of that object must be controlled by the thread in whose main loop the 'when' or 'fail' callback will execute.</p>
<p>The <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a7a013fd7b21096fa76e39cbe5475d31b">make_task_when()</a> method is similar to this method but provides an abbreviated set of paramaters suitable for most cases. This method is for use where releasers or a 'fail' callback are required.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">when</td><td>A callback which will be executed if and when the function passed to this method finishes correctly. The callback is passed that function's return value when it is invoked. If an exception propagates from the 'when' callback, this will be consumed and a g_critical() warning will be issued. The callback will execute in the glib main loop whose GMainContext object is passed to the 'context' argument of this method. </td></tr>
    <tr><td class="paramname">when_releaser</td><td>A pointer to a <a class="el" href="classCgu_1_1Releaser.html" title="A class used for tracking EmitterArg and SafeEmitterArg connections. ">Releaser</a> object for automatic disconnection of the 'when' callback before it executes in a main loop (mainly relevant if the callback represents a non-static member function of an object which may be destroyed before the callback executes). A value of 0/NULL/nullptr indicates no releaser. </td></tr>
    <tr><td class="paramname">fail</td><td>A callback which will be executed if the 'when' callback does not execute. This would happen if the function passed to this method exits by throwing <a class="el" href="classCgu_1_1Thread_1_1Exit.html" title="A class which can be thrown to terminate the throwing thread. ">Thread::Exit</a> or some other exception or the copy constructor of a non-reference argument of that function throws, or if the 'when' callback does not execute because the internal implementation of this wrapper throws std::bad_alloc (which will not happen if the library has been installed using the –with-glib-memory-slices-no-compat configuration option: instead glib will terminate the program if it is unable to obtain memory from the operating system). If an exception propagates from the 'fail' callback, this will be consumed and a g_critical() warning will be issued. The callback will execute in the glib main loop whose GMainContext object is passed to the 'context' argument of this method. An empty std::unique_ptr object indicates no 'fail' callback. </td></tr>
    <tr><td class="paramname">fail_releaser</td><td>A pointer to a <a class="el" href="classCgu_1_1Releaser.html" title="A class used for tracking EmitterArg and SafeEmitterArg connections. ">Releaser</a> object for automatic disconnection of the 'fail' callback before it executes in a main loop (mainly relevant if the callback represents a non-static member function of an object which may be destroyed before the callback executes). A value of 0/NULL/nullptr indicates no releaser. </td></tr>
    <tr><td class="paramname">priority</td><td>The priority to be given in the main loop to the 'when' callback or any 'fail' callback. In ascending order of priorities, priorities are G_PRIORITY_LOW, G_PRIORITY_DEFAULT_IDLE, G_PRIORITY_HIGH_IDLE, G_PRIORITY_DEFAULT and G_PRIORITY_HIGH. This determines the order in which the callback will appear in the event list in the main loop, not the priority which the OS will adopt. </td></tr>
    <tr><td class="paramname">context</td><td>The glib main context of the main loop in which the 'when' callback or any 'fail' callback is to be executed. A value 0/NULL/nullptr will cause the callback to be executed in the main program loop. </td></tr>
    <tr><td class="paramname">t</td><td>The object whose member function passed to this method is to execute as a task. </td></tr>
    <tr><td class="paramname">func</td><td>The member function to be executed as a task. If an exception propagates from the task, the exception will be consumed and the 'fail' callback will execute. </td></tr>
    <tr><td class="paramname">args</td><td>The arguments to be passed to that member function. </td></tr>
  </table>
  </dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname">std::bad_alloc</td><td>This exception will be thrown if memory is exhausted and the system throws in that case. (On systems with over-commit/lazy-commit combined with virtual memory (swap), it is rarely useful to check for memory exhaustion). If this exception is thrown, the task will not start (which also means that the 'when' and 'fail' callbacks will not execute). </td></tr>
    <tr><td class="paramname"><a class="el" href="structCgu_1_1Thread_1_1TaskError.html">Cgu::Thread::TaskError</a></td><td>This exception will be thrown if <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#ae61908c1fb1973f7ce66ab6ae308fe02">stop_all()</a> has previously been called. It will also be thrown if <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a2ac8ae63abc1a6b433f40e861d39ca33">is_error()</a> would return true because this class's internal thread pool loop implementation has thrown std::bad_alloc, or a thread has failed to start correctly. (On systems with over-commit/lazy-commit combined with virtual memory (swap), it is rarely useful to check for memory exhaustion, but there may be some specialized cases where the return value of <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a2ac8ae63abc1a6b433f40e861d39ca33">is_error()</a> is useful.) If this exception is thrown, the task will not start (which also means that the 'when' and 'fail' callbacks will not execute). </td></tr>
  </table>
  </dd>
</dl>
<dl class="section note"><dt>Note</dt><dd>1. This method will also throw if the copy or move constructor of a bound argument throws. If such an exception is thrown, the task will not start (which also means that the 'when' and 'fail' callbacks will not execute). </dd>
<dd>
2. If a 'when_releaser' or a 'fail_releaser' argument is provided, it is in theory possible (if memory is exhausted and the system throws in that case) that an internal <a class="el" href="classCgu_1_1SafeEmitterArg.html" title="A thread-safe class to execute callbacks connected to it, with provision for automatic disconnection...">SafeEmitterArg</a> object will throw std::bad_alloc when emitting/executing the 'when' or 'fail' callback in the glib main loop, with the result that the relevant callback will not execute (instead the exception will be consumed and a g_critical() warning will be issued). This is rarely of any relevance because glib will abort the program if it is itself unable to obtain memory from the operating system. However, where it is relevant, design the program so that it is not necessary to provide a releaser object.</dd></dl>
<p>Since 2.0.13 </p>

</div>
</div>
<a class="anchor" id="aa1b4550cfd9edfac22fb85d51ab1037a"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class Ret , class... Params, class... Args, class T &gt; </div>
      <table class="memname">
        <tr>
          <td class="memname">void Cgu::Thread::TaskManager::make_task_when_full </td>
          <td>(</td>
          <td class="paramtype">std::unique_ptr&lt; const <a class="el" href="classCgu_1_1Callback_1_1CallbackArg.html">Cgu::Callback::CallbackArg</a>&lt; const Ret &amp; &gt;&gt;&#160;</td>
          <td class="paramname"><em>when</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="classCgu_1_1Releaser.html">Cgu::Releaser</a> *&#160;</td>
          <td class="paramname"><em>when_releaser</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">std::unique_ptr&lt; const <a class="el" href="namespaceCgu_1_1Callback.html#ab0fdf0ebb22f2a7cc813657f6d90a94d">Cgu::Callback::Callback</a> &gt;&#160;</td>
          <td class="paramname"><em>fail</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="classCgu_1_1Releaser.html">Cgu::Releaser</a> *&#160;</td>
          <td class="paramname"><em>fail_releaser</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">gint&#160;</td>
          <td class="paramname"><em>priority</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">GMainContext *&#160;</td>
          <td class="paramname"><em>context</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const T &amp;&#160;</td>
          <td class="paramname"><em>t</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">Ret(T::*)(Params...) const&#160;</td>
          <td class="paramname"><em>func</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">Args &amp;&amp;...&#160;</td>
          <td class="paramname"><em>args</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<dl class="deprecated"><dt><b><a class="el" href="deprecated.html#_deprecated000021">Deprecated:</a></b></dt><dd></dd></dl>
<p>DEPRECATED. Use the versions of <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#abe374ca418bbe53e6c5228ecc1b6a3ac">make_task_when_full()</a> which take callable objects.</p>
<p>This is a wrapper which will take a member function pointer to a member function which returns a value, together with arguments, and constructs a <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> task which will execute that function by calling <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a81f7c8af3295d92c0e19d7f9498a4078">add_task()</a> with an appropriate callback object, and causes the 'when' callback passed as an argument to this method to be executed by a glib main loop if and when the task finishes correctly - the 'when' callback is passed the member function's return value when it is invoked. It is thread safe (any thread may call this method, including another task running on the <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> object). Apart from the absence of a 'one thread per task' model, this method therefore provides a similar interface to the one provided by <a class="el" href="classCgu_1_1Thread_1_1Future.html" title="A class representing a pthread thread which will provide a value. ">Cgu::Thread::Future</a>. See the documentation on <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a81f7c8af3295d92c0e19d7f9498a4078">add_task()</a> for further information about how task execution works.</p>
<p>This method can take up to three bound arguments for the target member function.</p>
<p>Note that unlike <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a81f7c8af3295d92c0e19d7f9498a4078">add_task()</a>, but like the 'fail' callback of <a class="el" href="classCgu_1_1Thread_1_1Future.html" title="A class representing a pthread thread which will provide a value. ">Cgu::Thread::Future</a> objects, if a fail callback is provided to this method and it executes, it will execute in the glib main loop whose GMainContext object is passed to the 'context' argument of this method.</p>
<p>Note also that if releasers are provided for the 'when' or 'fail' callbacks, these are passed by pointer and not by reference (this is so that a NULL pointer can indicate that no releaser is to be provided). If provided, a releaser will enable automatic disconnection of the 'when' or 'fail' callback, if the object having the callback function as a member is destroyed. For this to be race free, the lifetime of that object must be controlled by the thread in whose main loop the 'when' or 'fail' callback will execute.</p>
<p>The <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a7a013fd7b21096fa76e39cbe5475d31b">make_task_when()</a> method is similar to this method but provides an abbreviated set of paramaters suitable for most cases. This method is for use where releasers or a 'fail' callback are required.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">when</td><td>A callback which will be executed if and when the function passed to this method finishes correctly. The callback is passed that function's return value when it is invoked. If an exception propagates from the 'when' callback, this will be consumed and a g_critical() warning will be issued. The callback will execute in the glib main loop whose GMainContext object is passed to the 'context' argument of this method. </td></tr>
    <tr><td class="paramname">when_releaser</td><td>A pointer to a <a class="el" href="classCgu_1_1Releaser.html" title="A class used for tracking EmitterArg and SafeEmitterArg connections. ">Releaser</a> object for automatic disconnection of the 'when' callback before it executes in a main loop (mainly relevant if the callback represents a non-static member function of an object which may be destroyed before the callback executes). A value of 0/NULL/nullptr indicates no releaser. </td></tr>
    <tr><td class="paramname">fail</td><td>A callback which will be executed if the 'when' callback does not execute. This would happen if the function passed to this method exits by throwing <a class="el" href="classCgu_1_1Thread_1_1Exit.html" title="A class which can be thrown to terminate the throwing thread. ">Thread::Exit</a> or some other exception or the copy constructor of a non-reference argument of that function throws, or if the 'when' callback does not execute because the internal implementation of this wrapper throws std::bad_alloc (which will not happen if the library has been installed using the –with-glib-memory-slices-no-compat configuration option: instead glib will terminate the program if it is unable to obtain memory from the operating system). If an exception propagates from the 'fail' callback, this will be consumed and a g_critical() warning will be issued. The callback will execute in the glib main loop whose GMainContext object is passed to the 'context' argument of this method. An empty std::unique_ptr object indicates no 'fail' callback. </td></tr>
    <tr><td class="paramname">fail_releaser</td><td>A pointer to a <a class="el" href="classCgu_1_1Releaser.html" title="A class used for tracking EmitterArg and SafeEmitterArg connections. ">Releaser</a> object for automatic disconnection of the 'fail' callback before it executes in a main loop (mainly relevant if the callback represents a non-static member function of an object which may be destroyed before the callback executes). A value of 0/NULL/nullptr indicates no releaser. </td></tr>
    <tr><td class="paramname">priority</td><td>The priority to be given in the main loop to the 'when' callback or any 'fail' callback. In ascending order of priorities, priorities are G_PRIORITY_LOW, G_PRIORITY_DEFAULT_IDLE, G_PRIORITY_HIGH_IDLE, G_PRIORITY_DEFAULT and G_PRIORITY_HIGH. This determines the order in which the callback will appear in the event list in the main loop, not the priority which the OS will adopt. </td></tr>
    <tr><td class="paramname">context</td><td>The glib main context of the main loop in which the 'when' callback or any 'fail' callback is to be executed. A value 0/NULL/nullptr will cause the callback to be executed in the main program loop. </td></tr>
    <tr><td class="paramname">t</td><td>The object whose member function passed to this method is to execute as a task. </td></tr>
    <tr><td class="paramname">func</td><td>The member function to be executed as a task. If an exception propagates from the task, the exception will be consumed and the 'fail' callback will execute. </td></tr>
    <tr><td class="paramname">args</td><td>The arguments to be passed to that member function. </td></tr>
  </table>
  </dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname">std::bad_alloc</td><td>This exception will be thrown if memory is exhausted and the system throws in that case. (On systems with over-commit/lazy-commit combined with virtual memory (swap), it is rarely useful to check for memory exhaustion). If this exception is thrown, the task will not start (which also means that the 'when' and 'fail' callbacks will not execute). </td></tr>
    <tr><td class="paramname"><a class="el" href="structCgu_1_1Thread_1_1TaskError.html">Cgu::Thread::TaskError</a></td><td>This exception will be thrown if <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#ae61908c1fb1973f7ce66ab6ae308fe02">stop_all()</a> has previously been called. It will also be thrown if <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a2ac8ae63abc1a6b433f40e861d39ca33">is_error()</a> would return true because this class's internal thread pool loop implementation has thrown std::bad_alloc, or a thread has failed to start correctly. (On systems with over-commit/lazy-commit combined with virtual memory (swap), it is rarely useful to check for memory exhaustion, but there may be some specialized cases where the return value of <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a2ac8ae63abc1a6b433f40e861d39ca33">is_error()</a> is useful.) If this exception is thrown, the task will not start (which also means that the 'when' and 'fail' callbacks will not execute). </td></tr>
  </table>
  </dd>
</dl>
<dl class="section note"><dt>Note</dt><dd>1. This method will also throw if the copy or move constructor of a bound argument throws. If such an exception is thrown, the task will not start (which also means that the 'when' and 'fail' callbacks will not execute). </dd>
<dd>
2. If a 'when_releaser' or a 'fail_releaser' argument is provided, it is in theory possible (if memory is exhausted and the system throws in that case) that an internal <a class="el" href="classCgu_1_1SafeEmitterArg.html" title="A thread-safe class to execute callbacks connected to it, with provision for automatic disconnection...">SafeEmitterArg</a> object will throw std::bad_alloc when emitting/executing the 'when' or 'fail' callback in the glib main loop, with the result that the relevant callback will not execute (instead the exception will be consumed and a g_critical() warning will be issued). This is rarely of any relevance because glib will abort the program if it is itself unable to obtain memory from the operating system. However, where it is relevant, design the program so that it is not necessary to provide a releaser object.</dd></dl>
<p>Since 2.0.13 </p>

</div>
</div>
<a class="anchor" id="aa919ec0a43b078b12a1b2d04028c3bdb"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class Ret , class... Params, class... Args&gt; </div>
      <table class="memname">
        <tr>
          <td class="memname">void Cgu::Thread::TaskManager::make_task_when_full </td>
          <td>(</td>
          <td class="paramtype">std::unique_ptr&lt; const <a class="el" href="classCgu_1_1Callback_1_1CallbackArg.html">Cgu::Callback::CallbackArg</a>&lt; const Ret &amp; &gt;&gt;&#160;</td>
          <td class="paramname"><em>when</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="classCgu_1_1Releaser.html">Cgu::Releaser</a> *&#160;</td>
          <td class="paramname"><em>when_releaser</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">std::unique_ptr&lt; const <a class="el" href="namespaceCgu_1_1Callback.html#ab0fdf0ebb22f2a7cc813657f6d90a94d">Cgu::Callback::Callback</a> &gt;&#160;</td>
          <td class="paramname"><em>fail</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="classCgu_1_1Releaser.html">Cgu::Releaser</a> *&#160;</td>
          <td class="paramname"><em>fail_releaser</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">gint&#160;</td>
          <td class="paramname"><em>priority</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">GMainContext *&#160;</td>
          <td class="paramname"><em>context</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">Ret(*)(Params...)&#160;</td>
          <td class="paramname"><em>func</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">Args &amp;&amp;...&#160;</td>
          <td class="paramname"><em>args</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<dl class="deprecated"><dt><b><a class="el" href="deprecated.html#_deprecated000024">Deprecated:</a></b></dt><dd></dd></dl>
<p>DEPRECATED. Use the versions of <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#abe374ca418bbe53e6c5228ecc1b6a3ac">make_task_when_full()</a> which take callable objects.</p>
<p>This is a wrapper which will take a pointer to a function which returns a value, together with arguments, and constructs a <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> task which will execute that function by calling <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a81f7c8af3295d92c0e19d7f9498a4078">add_task()</a> with an appropriate callback object, and causes the 'when' callback passed as an argument to this method to be executed by a glib main loop if and when the task finishes correctly - the 'when' callback is passed the function's return value when it is invoked. It is thread safe (any thread may call this method, including another task running on the <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> object). Apart from the absence of a 'one thread per task' model, this method therefore provides a similar interface to the one provided by <a class="el" href="classCgu_1_1Thread_1_1Future.html" title="A class representing a pthread thread which will provide a value. ">Cgu::Thread::Future</a>. See the documentation on <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a81f7c8af3295d92c0e19d7f9498a4078">add_task()</a> for further information about how task execution works.</p>
<p>This method can take up to four bound arguments for the target function.</p>
<p>Note that unlike <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a81f7c8af3295d92c0e19d7f9498a4078">add_task()</a>, but like the 'fail' callback of <a class="el" href="classCgu_1_1Thread_1_1Future.html" title="A class representing a pthread thread which will provide a value. ">Cgu::Thread::Future</a> objects, if a fail callback is provided to this method and it executes, it will execute in the glib main loop whose GMainContext object is passed to the 'context' argument of this method.</p>
<p>Note also that if releasers are provided for the 'when' or 'fail' callbacks, these are passed by pointer and not by reference (this is so that a NULL pointer can indicate that no releaser is to be provided). If provided, a releaser will enable automatic disconnection of the 'when' or 'fail' callback, if the object of which the releaser is a member is destroyed. For this to be race free, the lifetime of that object must be controlled by the thread in whose main loop the 'when' or 'fail' callback will execute.</p>
<p>The <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a7a013fd7b21096fa76e39cbe5475d31b">make_task_when()</a> method is similar to this method but provides an abbreviated set of paramaters suitable for most cases. This method is for use where releasers or a 'fail' callback are required.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">when</td><td>A callback which will be executed if and when the function passed to this method finishes correctly. The callback is passed that function's return value when it is invoked. If an exception propagates from the 'when' callback, this will be consumed and a g_critical() warning will be issued. The callback will execute in the glib main loop whose GMainContext object is passed to the 'context' argument of this method. </td></tr>
    <tr><td class="paramname">when_releaser</td><td>A pointer to a <a class="el" href="classCgu_1_1Releaser.html" title="A class used for tracking EmitterArg and SafeEmitterArg connections. ">Releaser</a> object for automatic disconnection of the 'when' callback before it executes in a main loop (mainly relevant if the callback represents a non-static member function of an object which may be destroyed before the callback executes). A value of 0/NULL/nullptr indicates no releaser. </td></tr>
    <tr><td class="paramname">fail</td><td>A callback which will be executed if the 'when' callback does not execute. This would happen if the function passed to this method exits by throwing <a class="el" href="classCgu_1_1Thread_1_1Exit.html" title="A class which can be thrown to terminate the throwing thread. ">Thread::Exit</a> or some other exception or the copy constructor of a non-reference argument of that function throws, or if the 'when' callback does not execute because the internal implementation of this wrapper throws std::bad_alloc (which will not happen if the library has been installed using the –with-glib-memory-slices-no-compat configuration option: instead glib will terminate the program if it is unable to obtain memory from the operating system). If an exception propagates from the 'fail' callback, this will be consumed and a g_critical() warning will be issued. The callback will execute in the glib main loop whose GMainContext object is passed to the 'context' argument of this method. An empty std::unique_ptr object indicates no 'fail' callback. </td></tr>
    <tr><td class="paramname">fail_releaser</td><td>A pointer to a <a class="el" href="classCgu_1_1Releaser.html" title="A class used for tracking EmitterArg and SafeEmitterArg connections. ">Releaser</a> object for automatic disconnection of the 'fail' callback before it executes in a main loop (mainly relevant if the callback represents a non-static member function of an object which may be destroyed before the callback executes). A value of 0/NULL/nullptr indicates no releaser. </td></tr>
    <tr><td class="paramname">priority</td><td>The priority to be given in the main loop to the 'when' callback or any 'fail' callback. In ascending order of priorities, priorities are G_PRIORITY_LOW, G_PRIORITY_DEFAULT_IDLE, G_PRIORITY_HIGH_IDLE, G_PRIORITY_DEFAULT and G_PRIORITY_HIGH. This determines the order in which the callback will appear in the event list in the main loop, not the priority which the OS will adopt. </td></tr>
    <tr><td class="paramname">context</td><td>The glib main context of the main loop in which the 'when' callback or any 'fail' callback is to be executed. A value 0/NULL/nullptr will cause the callback to be executed in the main program loop. </td></tr>
    <tr><td class="paramname">func</td><td>The function to be executed as a task. If an exception propagates from the task, the exception will be consumed and the 'fail' callback will execute. </td></tr>
    <tr><td class="paramname">args</td><td>The arguments to be passed to that function. </td></tr>
  </table>
  </dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname">std::bad_alloc</td><td>This exception will be thrown if memory is exhausted and the system throws in that case. (On systems with over-commit/lazy-commit combined with virtual memory (swap), it is rarely useful to check for memory exhaustion). If this exception is thrown, the task will not start (which also means that the 'when' and 'fail' callbacks will not execute). </td></tr>
    <tr><td class="paramname"><a class="el" href="structCgu_1_1Thread_1_1TaskError.html">Cgu::Thread::TaskError</a></td><td>This exception will be thrown if <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#ae61908c1fb1973f7ce66ab6ae308fe02">stop_all()</a> has previously been called. It will also be thrown if <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a2ac8ae63abc1a6b433f40e861d39ca33">is_error()</a> would return true because this class's internal thread pool loop implementation has thrown std::bad_alloc, or a thread has failed to start correctly. (On systems with over-commit/lazy-commit combined with virtual memory (swap), it is rarely useful to check for memory exhaustion, but there may be some specialized cases where the return value of <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a2ac8ae63abc1a6b433f40e861d39ca33">is_error()</a> is useful.) If this exception is thrown, the task will not start (which also means that the 'when' and 'fail' callbacks will not execute). </td></tr>
  </table>
  </dd>
</dl>
<dl class="section note"><dt>Note</dt><dd>1. This method will also throw if the copy or move constructor of a bound argument throws. If such an exception is thrown, the task will not start (which also means that the 'when' and 'fail' callbacks will not execute). </dd>
<dd>
2. If a 'when_releaser' or a 'fail_releaser' argument is provided, it is in theory possible (if memory is exhausted and the system throws in that case) that an internal <a class="el" href="classCgu_1_1SafeEmitterArg.html" title="A thread-safe class to execute callbacks connected to it, with provision for automatic disconnection...">SafeEmitterArg</a> object will throw std::bad_alloc when emitting/executing the 'when' or 'fail' callback in the glib main loop, with the result that the relevant callback will not execute (instead the exception will be consumed and a g_critical() warning will be issued). This is rarely of any relevance because glib will abort the program if it is itself unable to obtain memory from the operating system. However, where it is relevant, design the program so that it is not necessary to provide a releaser object.</dd></dl>
<p>Since 2.0.13 </p>

</div>
</div>
<a class="anchor" id="a242d56aceb8ce247a9d033915b7d9401"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class Ret , class Func &gt; </div>
      <table class="memname">
        <tr>
          <td class="memname">void Cgu::Thread::TaskManager::make_task_when_full </td>
          <td>(</td>
          <td class="paramtype">std::unique_ptr&lt; const <a class="el" href="classCgu_1_1Callback_1_1CallbackArg.html">Cgu::Callback::CallbackArg</a>&lt; const Ret &amp; &gt;&gt;&#160;</td>
          <td class="paramname"><em>when</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="classCgu_1_1Releaser.html">Cgu::Releaser</a> *&#160;</td>
          <td class="paramname"><em>when_releaser</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">std::unique_ptr&lt; const <a class="el" href="namespaceCgu_1_1Callback.html#ab0fdf0ebb22f2a7cc813657f6d90a94d">Cgu::Callback::Callback</a> &gt;&#160;</td>
          <td class="paramname"><em>fail</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="classCgu_1_1Releaser.html">Cgu::Releaser</a> *&#160;</td>
          <td class="paramname"><em>fail_releaser</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">gint&#160;</td>
          <td class="paramname"><em>priority</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">GMainContext *&#160;</td>
          <td class="paramname"><em>context</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">Func &amp;&amp;&#160;</td>
          <td class="paramname"><em>func</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>This is a wrapper which will take a callable object (such as a std::function object, a lambda or the return value of std::bind) representing a function which returns a value, and constructs a <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> task which will execute that function by calling <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a81f7c8af3295d92c0e19d7f9498a4078">add_task()</a> with an appropriate callback object, and causes the 'when' callback passed as an argument to this method to be executed by a glib main loop if and when the task finishes correctly - the 'when' callback is passed the function's return value when it is invoked. It is thread safe (any thread may call this method, including another task running on the <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> object). Apart from the absence of a 'one thread per task' model, this method therefore provides a similar interface to the one provided by <a class="el" href="classCgu_1_1Thread_1_1Future.html" title="A class representing a pthread thread which will provide a value. ">Cgu::Thread::Future</a>. See the documentation on <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a81f7c8af3295d92c0e19d7f9498a4078">add_task()</a> for further information about how task execution works.</p>
<p>Note that unlike <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a81f7c8af3295d92c0e19d7f9498a4078">add_task()</a>, but like the 'fail' callback of <a class="el" href="classCgu_1_1Thread_1_1Future.html" title="A class representing a pthread thread which will provide a value. ">Cgu::Thread::Future</a> objects, if a fail callback is provided to this method and it executes, it will execute in the glib main loop whose GMainContext object is passed to the 'context' argument of this method.</p>
<p>Note also that if releasers are provided for the 'when' or 'fail' callbacks, these are passed by pointer and not by reference (this is so that a NULL pointer can indicate that no releaser is to be provided). If provided, a releaser will enable automatic disconnection of the 'when' or 'fail' callback, if the object of which the releaser is a member is destroyed. For this to be race free, the lifetime of that object must be controlled by the thread in whose main loop the 'when' or 'fail' callback will execute.</p>
<p>The <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a7a013fd7b21096fa76e39cbe5475d31b">make_task_when()</a> method is similar to this method but provides an abbreviated set of parameters suitable for most cases. This method is for use where releasers or a 'fail' callback are required.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">when</td><td>A callback which will be executed if and when the callable object passed as 'func' to this method finishes correctly. The callback is passed that object's return value when it is invoked. If an exception propagates from the 'when' callback, this will be consumed and a g_critical() warning will be issued. The callback will execute in the glib main loop whose GMainContext object is passed to the 'context' argument of this method. </td></tr>
    <tr><td class="paramname">when_releaser</td><td>A pointer to a <a class="el" href="classCgu_1_1Releaser.html" title="A class used for tracking EmitterArg and SafeEmitterArg connections. ">Releaser</a> object for automatic disconnection of the 'when' callback before it executes in a main loop (mainly relevant if the callback represents a non-static member function of an object which may be destroyed before the callback executes). A value of 0/NULL/nullptr indicates no releaser. </td></tr>
    <tr><td class="paramname">fail</td><td>A callback which will be executed if the 'when' callback does not execute. This would happen if the callable object passed as 'func' to this method exits by throwing <a class="el" href="classCgu_1_1Thread_1_1Exit.html" title="A class which can be thrown to terminate the throwing thread. ">Thread::Exit</a> or some other exception (or if that object represents a function taking a non-reference argument whose copy constructor throws), or if the 'when' callback does not execute because the internal implementation of this wrapper throws std::bad_alloc (which will not happen if the library has been installed using the –with-glib-memory-slices-no-compat configuration option: instead glib will terminate the program if it is unable to obtain memory from the operating system). If an exception propagates from the 'fail' callback, this will be consumed and a g_critical() warning will be issued. The callback will execute in the glib main loop whose GMainContext object is passed to the 'context' argument of this method. An empty std::unique_ptr object indicates no 'fail' callback. </td></tr>
    <tr><td class="paramname">fail_releaser</td><td>A pointer to a <a class="el" href="classCgu_1_1Releaser.html" title="A class used for tracking EmitterArg and SafeEmitterArg connections. ">Releaser</a> object for automatic disconnection of the 'fail' callback before it executes in a main loop (mainly relevant if the callback represents a non-static member function of an object which may be destroyed before the callback executes). A value of 0/NULL/nullptr indicates no releaser. </td></tr>
    <tr><td class="paramname">priority</td><td>The priority to be given in the main loop to the 'when' callback or any 'fail' callback. In ascending order of priorities, priorities are G_PRIORITY_LOW, G_PRIORITY_DEFAULT_IDLE, G_PRIORITY_HIGH_IDLE, G_PRIORITY_DEFAULT and G_PRIORITY_HIGH. This determines the order in which the callback will appear in the event list in the main loop, not the priority which the OS will adopt. </td></tr>
    <tr><td class="paramname">context</td><td>The glib main context of the main loop in which the 'when' callback or any 'fail' callback is to be executed. A value 0/NULL/nullptr will cause the callback to be executed in the main program loop. </td></tr>
    <tr><td class="paramname">func</td><td>The callable object to be executed as a task, such as formed by a lambda expression or the result of std::bind. It should return a value (it cannot return void). It must be fully bound (that is, it must take no arguments when called). If an exception propagates from the task, the exception will be consumed and the 'fail' callback will execute. </td></tr>
  </table>
  </dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname">std::bad_alloc</td><td>This exception will be thrown if memory is exhausted and the system throws in that case. (On systems with over-commit/lazy-commit combined with virtual memory (swap), it is rarely useful to check for memory exhaustion). If this exception is thrown, the task will not start (which also means that the 'when' and 'fail' callbacks will not execute). </td></tr>
    <tr><td class="paramname"><a class="el" href="structCgu_1_1Thread_1_1TaskError.html">Cgu::Thread::TaskError</a></td><td>This exception will be thrown if <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#ae61908c1fb1973f7ce66ab6ae308fe02">stop_all()</a> has previously been called. It will also be thrown if <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a2ac8ae63abc1a6b433f40e861d39ca33">is_error()</a> would return true because this class's internal thread pool loop implementation has thrown std::bad_alloc, or a thread has failed to start correctly. (On systems with over-commit/lazy-commit combined with virtual memory (swap), it is rarely useful to check for memory exhaustion, but there may be some specialized cases where the return value of <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a2ac8ae63abc1a6b433f40e861d39ca33">is_error()</a> is useful.) If this exception is thrown, the task will not start (which also means that the 'when' and 'fail' callbacks will not execute). </td></tr>
  </table>
  </dd>
</dl>
<dl class="section note"><dt>Note</dt><dd>1. This method will also throw if the copy or move constructor of the callable object throws. If such an exception is thrown, the task will not start (which also means that the 'when' and 'fail' callbacks will not execute). </dd>
<dd>
2. If the callable object passed as an argument has both const and non-const operator()() methods, the non-const version will be called even if the callable object passed is a const object. </dd>
<dd>
3. If a 'when_releaser' or a 'fail_releaser' argument is provided, it is in theory possible (if memory is exhausted and the system throws in that case) that an internal <a class="el" href="classCgu_1_1SafeEmitterArg.html" title="A thread-safe class to execute callbacks connected to it, with provision for automatic disconnection...">SafeEmitterArg</a> object will throw std::bad_alloc when emitting/executing the 'when' or 'fail' callback in the glib main loop, with the result that the relevant callback will not execute (instead the exception will be consumed and a g_critical() warning will be issued). This is rarely of any relevance because glib will abort the program if it is itself unable to obtain memory from the operating system. However, where it is relevant, design the program so that it is not necessary to provide a releaser object.</dd></dl>
<p>Since 2.0.14 </p>

</div>
</div>
<a class="anchor" id="a7af7bc37424d6072cd374e840eb90fec"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class When , class Fail , class Func , class  = typename std::enable_if&lt;!std::is_convertible&lt;When, std::unique_ptr&lt;const Callback::CallbackArg&lt;const typename std::result_of&lt;Func()&gt;::type&amp;&gt;&gt;&gt;::value  	    				    &amp;&amp; !std::is_convertible&lt;Fail, std::unique_ptr&lt;const Callback::Callback&gt;&gt;::value&gt;::type&gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void Cgu::Thread::TaskManager::make_task_when_full </td>
          <td>(</td>
          <td class="paramtype">When &amp;&amp;&#160;</td>
          <td class="paramname"><em>when</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="classCgu_1_1Releaser.html">Cgu::Releaser</a> *&#160;</td>
          <td class="paramname"><em>when_releaser</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">Fail &amp;&amp;&#160;</td>
          <td class="paramname"><em>fail</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="classCgu_1_1Releaser.html">Cgu::Releaser</a> *&#160;</td>
          <td class="paramname"><em>fail_releaser</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">gint&#160;</td>
          <td class="paramname"><em>priority</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">GMainContext *&#160;</td>
          <td class="paramname"><em>context</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">Func &amp;&amp;&#160;</td>
          <td class="paramname"><em>func</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>This is a wrapper which will take a callable object (such as a std::function object, a lambda or the return value of std::bind) representing a function which returns a value, and constructs a <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> task which will execute that function by calling <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a81f7c8af3295d92c0e19d7f9498a4078">add_task()</a> with an appropriate callback object, and causes the 'when' callback passed as an argument to this method to be executed by a glib main loop if and when the task finishes correctly - the 'when' callback is passed the function's return value when it is invoked. It is thread safe (any thread may call this method, including another task running on the <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> object). Apart from the absence of a 'one thread per task' model, this method therefore provides a similar interface to the one provided by <a class="el" href="classCgu_1_1Thread_1_1Future.html" title="A class representing a pthread thread which will provide a value. ">Cgu::Thread::Future</a>. See the documentation on <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a81f7c8af3295d92c0e19d7f9498a4078">add_task()</a> for further information about how task execution works.</p>
<p>Note that unlike <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a81f7c8af3295d92c0e19d7f9498a4078">add_task()</a>, but like the 'fail' callback of <a class="el" href="classCgu_1_1Thread_1_1Future.html" title="A class representing a pthread thread which will provide a value. ">Cgu::Thread::Future</a> objects, if a fail callback is provided to this method and it executes, it will execute in the glib main loop whose GMainContext object is passed to the 'context' argument of this method.</p>
<p>Note also that if releasers are provided for the 'when' or 'fail' callbacks, these are passed by pointer and not by reference (this is so that a NULL pointer can indicate that no releaser is to be provided). If provided, a releaser will enable automatic disconnection of the 'when' or 'fail' callback, if the object of which the releaser is a member is destroyed. For this to be race free, the lifetime of that object must be controlled by the thread in whose main loop the 'when' or 'fail' callback will execute.</p>
<p>The <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a7a013fd7b21096fa76e39cbe5475d31b">make_task_when()</a> method is similar to this method but provides an abbreviated set of parameters suitable for most cases. This method is for use where releasers or a 'fail' callback are required.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">when</td><td>A callable object (such as formed by a lambda expression or the result of std::bind) which will be executed if and when the 'func' object passed to this method finishes correctly. The 'when' callback is passed that objects's return value when invoked, and should take a single unbound argument, namely a reference to const of the type of that return value. If an exception propagates from the 'when' callback, this will be consumed and a g_critical() warning will be issued. The callback will execute in the glib main loop whose GMainContext object is passed to the 'context' argument of this method. </td></tr>
    <tr><td class="paramname">when_releaser</td><td>A pointer to a <a class="el" href="classCgu_1_1Releaser.html" title="A class used for tracking EmitterArg and SafeEmitterArg connections. ">Releaser</a> object for automatic disconnection of the 'when' callback before it executes in a main loop (mainly relevant if the callback calls a non-static member function of an object which may be destroyed before the callback executes). A value of 0/NULL/nullptr indicates no releaser. </td></tr>
    <tr><td class="paramname">fail</td><td>A callable object (such as formed by a lambda expression or the result of std::bind) which will be executed if the 'when' callback does not execute. This would happen if the the callable object passed as 'func' to this method exits by throwing <a class="el" href="classCgu_1_1Thread_1_1Exit.html" title="A class which can be thrown to terminate the throwing thread. ">Thread::Exit</a> or some other exception, or if the 'when' callback does not execute because the internal implementation of this wrapper throws std::bad_alloc (which will not happen if the library has been installed using the –with-glib-memory-slices-no-compat configuration option: instead glib will terminate the program if it is unable to obtain memory from the operating system). The callable object must be fully bound (that is, it must take no arguments when called). If an exception propagates from the 'fail' callback, this will be consumed and a g_critical() warning will be issued. The callback will execute in the glib main loop whose GMainContext object is passed to the 'context' argument of this method. If no 'fail' callback is wanted, pass a lambda which does nothing. </td></tr>
    <tr><td class="paramname">fail_releaser</td><td>A pointer to a <a class="el" href="classCgu_1_1Releaser.html" title="A class used for tracking EmitterArg and SafeEmitterArg connections. ">Releaser</a> object for automatic disconnection of the 'fail' callback before it executes in a main loop (mainly relevant if the callback calls a non-static member function of an object which may be destroyed before the callback executes). A value of 0/NULL/nullptr indicates no releaser. </td></tr>
    <tr><td class="paramname">priority</td><td>The priority to be given in the main loop to the 'when' callback or any 'fail' callback. In ascending order of priorities, priorities are G_PRIORITY_LOW, G_PRIORITY_DEFAULT_IDLE, G_PRIORITY_HIGH_IDLE, G_PRIORITY_DEFAULT and G_PRIORITY_HIGH. This determines the order in which the callback will appear in the event list in the main loop, not the priority which the OS will adopt. </td></tr>
    <tr><td class="paramname">context</td><td>The glib main context of the main loop in which the 'when' callback or any 'fail' callback is to be executed. A value 0/NULL/nullptr will cause the callback to be executed in the main program loop. </td></tr>
    <tr><td class="paramname">func</td><td>The callable object to be executed as a task, such as formed by a lambda expression or the result of std::bind. It should return a value (it cannot return void). It must be fully bound (that is, it must take no arguments when called). If an exception propagates from the task, the exception will be consumed and the 'fail' callback will execute. </td></tr>
  </table>
  </dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname">std::bad_alloc</td><td>This exception will be thrown if memory is exhausted and the system throws in that case. (On systems with over-commit/lazy-commit combined with virtual memory (swap), it is rarely useful to check for memory exhaustion). If this exception is thrown, the task will not start (which also means that the 'when' and 'fail' callbacks will not execute). </td></tr>
    <tr><td class="paramname"><a class="el" href="structCgu_1_1Thread_1_1TaskError.html">Cgu::Thread::TaskError</a></td><td>This exception will be thrown if <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#ae61908c1fb1973f7ce66ab6ae308fe02">stop_all()</a> has previously been called. It will also be thrown if <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a2ac8ae63abc1a6b433f40e861d39ca33">is_error()</a> would return true because this class's internal thread pool loop implementation has thrown std::bad_alloc, or a thread has failed to start correctly. (On systems with over-commit/lazy-commit combined with virtual memory (swap), it is rarely useful to check for memory exhaustion, but there may be some specialized cases where the return value of <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a2ac8ae63abc1a6b433f40e861d39ca33">is_error()</a> is useful.) If this exception is thrown, the task will not start (which also means that the 'when' and 'fail' callbacks will not execute). </td></tr>
  </table>
  </dd>
</dl>
<dl class="section note"><dt>Note</dt><dd>1. This method will also throw if the copy or move constructor of the 'func', 'when' or 'fail' callable objects throws. If such an exception is thrown, the task will not start (which also means that the 'when' and 'fail' callbacks will not execute). </dd>
<dd>
2. If any of the callable objects passed to this method have both const and non-const operator()() methods, the non-const version will be called even if the callable object passed is a const object. </dd>
<dd>
3. If a 'when_releaser' or a 'fail_releaser' argument is provided, it is in theory possible (if memory is exhausted and the system throws in that case) that an internal <a class="el" href="classCgu_1_1SafeEmitterArg.html" title="A thread-safe class to execute callbacks connected to it, with provision for automatic disconnection...">SafeEmitterArg</a> object will throw std::bad_alloc when emitting/executing the 'when' or 'fail' callback in the glib main loop, with the result that the relevant callback will not execute (instead the exception will be consumed and a g_critical() warning will be issued). This is rarely of any relevance because glib will abort the program if it is itself unable to obtain memory from the operating system. However, where it is relevant, design the program so that it is not necessary to provide a releaser object.</dd></dl>
<p>Since 2.1.0 </p>

</div>
</div>
<a class="anchor" id="a15186bab37f22c8c72cea5f582f27efe"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classCgu_1_1Thread_1_1TaskManager.html">TaskManager</a>&amp; Cgu::Thread::TaskManager::operator= </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html">TaskManager</a> &amp;&#160;</td>
          <td class="paramname">)</td><td></td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">delete</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>This class cannot be copied. The assignment operator is deleted. </p>

</div>
</div>
<a class="anchor" id="ae4530426fed068208df577ca8eea669f"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void Cgu::Thread::TaskManager::set_blocking </td>
          <td>(</td>
          <td class="paramtype">bool&#160;</td>
          <td class="paramname"><em>blocking</em>)</td><td></td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Sets the current blocking setting, which determines whether calls to <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#ae61908c1fb1973f7ce66ab6ae308fe02">stop_all()</a> and the destructor will block waiting for all remaining tasks to complete. This method cannot be called after <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#ae61908c1fb1973f7ce66ab6ae308fe02">stop_all()</a> has been called (if that is attempted, <a class="el" href="structCgu_1_1Thread_1_1TaskError.html">Cgu::Thread::TaskError</a> will be thrown). It is thread safe. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">blocking</td><td>The new blocking setting. </td></tr>
  </table>
  </dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname"><a class="el" href="structCgu_1_1Thread_1_1TaskError.html">Cgu::Thread::TaskError</a></td><td>This exception will be thrown if <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#ae61908c1fb1973f7ce66ab6ae308fe02">stop_all()</a> has previously been called.</td></tr>
  </table>
  </dd>
</dl>
<p>Since 2.0.12 </p>

</div>
</div>
<a class="anchor" id="ae4d3d2a1c68e58bbc51037a970194ec4"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void Cgu::Thread::TaskManager::set_idle_time </td>
          <td>(</td>
          <td class="paramtype">unsigned int&#160;</td>
          <td class="paramname"><em>idle</em>)</td><td></td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Sets the length of time in milliseconds that threads greater in number than the minimum and not executing any tasks will remain in existence waiting for new tasks. This will only have effect for threads in the pool which begin waiting for new tasks after this method is called. This method will not throw and is thread safe. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">idle</td><td>The length of the idle time in milliseconds during which threads will remain waiting for new tasks.</td></tr>
  </table>
  </dd>
</dl>
<p>Since 2.0.12 </p>

</div>
</div>
<a class="anchor" id="aa5b0225d7acd9c5b6e2f8de39bc711e3"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void Cgu::Thread::TaskManager::set_max_threads </td>
          <td>(</td>
          <td class="paramtype">unsigned int&#160;</td>
          <td class="paramname"><em>max</em>)</td><td></td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<dl class="deprecated"><dt><b><a class="el" href="deprecated.html#_deprecated000016">Deprecated:</a></b></dt><dd></dd></dl>
<p>DEPRECATED. Use <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#ad47297562ee0c838da1242335745d31b">change_max_threads()</a> instead. This method will interfere with the intended operation of the ThreadManager::IncHandle class if one task constructs a <a class="el" href="classCgu_1_1Thread_1_1TaskManager_1_1IncHandle.html" title="A scoped handle for exception safe incrementing of the maximum number of threads that a TaskManager o...">IncHandle</a> object and another calls this method.</p>
<p>Sets the maximum number of threads which the <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> object will currently run in the thread pool. If this is less than the current number of running threads, the number of threads actually running will only be reduced as tasks complete, or as idle timeouts expire. This method does nothing if <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#ae61908c1fb1973f7ce66ab6ae308fe02">stop_all()</a> has previously been called. This method is thread safe. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">max</td><td>The maximum number of threads which the <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> object will currently run in the thread pool. This method will not set the maximum value of threads to a value less than that returned by <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#acd4031c041c0a32e6435e6ab3783bb3d">get_min_threads()</a>, nor to a value less than 1. </td></tr>
  </table>
  </dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname">std::bad_alloc</td><td>If this call is passed a value for 'max' which increases the maximum number of threads from its previous setting and tasks are currently queued for execution, new threads will be started for the queued tasks, so this exception may be thrown on starting the new threads if memory is exhausted and the system throws in that case. (On systems with over-commit/lazy-commit combined with virtual memory (swap), it is rarely useful to check for memory exhaustion). </td></tr>
    <tr><td class="paramname"><a class="el" href="structCgu_1_1Thread_1_1TaskError.html">Cgu::Thread::TaskError</a></td><td>If this call is passed a value for 'max' which increases the maximum number of threads from its previous setting and tasks are currently queued for execution, new threads will be started for the queued tasks, so this exception may be thrown on starting the new threads if a thread fails to start correctly (this would mean that memory is exhausted, the pthread thread limit has been reached or pthread has run out of other resources to start new threads).</td></tr>
  </table>
  </dd>
</dl>
<p>Since 2.0.12 </p>

</div>
</div>
<a class="anchor" id="a410ccc3699dee4e297fd74e1aad7e72d"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void Cgu::Thread::TaskManager::set_stop_mode </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a59de02521dda7778da29462c6d41fc7b">StopMode</a>&#160;</td>
          <td class="paramname"><em>mode</em>)</td><td></td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Sets the current StopMode setting (either <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a59de02521dda7778da29462c6d41fc7ba47b71b9315a0d8ecc2941701bfb0e281">Cgu::Thread::TaskManager::wait_for_running</a> or <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a59de02521dda7778da29462c6d41fc7ba35a4e1e7bfe28bc85a044956369695f1">Cgu::Thread::TaskManager::wait_for_all</a>) executed when running <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#ae61908c1fb1973f7ce66ab6ae308fe02">stop_all()</a> or when the destructor is called. See the documentation on <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#ae61908c1fb1973f7ce66ab6ae308fe02">stop_all()</a> for an explanation of the setting. This method will not throw and is thread safe. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">mode</td><td>The new StopMode setting.</td></tr>
  </table>
  </dd>
</dl>
<p>Since 2.0.12 </p>

</div>
</div>
<a class="anchor" id="ae61908c1fb1973f7ce66ab6ae308fe02"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void Cgu::Thread::TaskManager::stop_all </td>
          <td>(</td>
          <td class="paramname">)</td><td></td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>This will cause the <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> object to stop running tasks. The precise effect depends on the current StopMode and blocking settings. If StopMode is set to <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a59de02521dda7778da29462c6d41fc7ba47b71b9315a0d8ecc2941701bfb0e281">Cgu::Thread::TaskManager::wait_for_running</a>, all queued tasks which are not yet running on a thread will be dispensed with, but any already running will be left to complete normally. If StopMode is set to <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a59de02521dda7778da29462c6d41fc7ba35a4e1e7bfe28bc85a044956369695f1">Cgu::Thread::TaskManager::wait_for_all</a>, both already running tasks and all tasks already queued will be permitted to execute and complete normally. If the blocking setting is set to true, this method will wait until all the tasks still to execute have finished before returning, and if false it will return straight away.</p>
<p>After this method has been called, any attempt to add further tasks with the <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a81f7c8af3295d92c0e19d7f9498a4078">add_task()</a> method will fail, and <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#a81f7c8af3295d92c0e19d7f9498a4078">add_task()</a> will throw <a class="el" href="structCgu_1_1Thread_1_1TaskError.html">Cgu::Thread::TaskError</a>.</p>
<p>This method is thread safe (any thread may call it) unless the blocking setting is true, in which case no task running on the <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> object may call this method. </p>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname">std::bad_alloc</td><td>This exception will be thrown if memory is exhausted and the system throws in that case. (On systems with over-commit/lazy-commit combined with virtual memory (swap), it is rarely useful to check for memory exhaustion). </td></tr>
    <tr><td class="paramname"><a class="el" href="structCgu_1_1Thread_1_1TaskError.html">Cgu::Thread::TaskError</a></td><td>This exception will be thrown if <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html#ae61908c1fb1973f7ce66ab6ae308fe02">stop_all()</a> has previously been called, unless that previous call threw std::bad_alloc: if std::bad_alloc is thrown, this method may be called again to stop all threads, once the memory deficiency is dealt with, but no other methods of the <a class="el" href="classCgu_1_1Thread_1_1TaskManager.html" title="A thread-pool class for managing tasks in multi-threaded programs. ">TaskManager</a> object should be called.</td></tr>
  </table>
  </dd>
</dl>
<p>Since 2.0.12 </p>

</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li><a class="el" href="task__manager_8h_source.html">task_manager.h</a></li>
</ul>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Mon Sep 16 2013 20:45:32 for c++-gtk-utils by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.4
</small></address>
</body>
</html>