Blob Blame History Raw
<!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.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>glibmm: Glib::ThreadPool 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" />
<link href="doxygen-extra.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 id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">glibmm
   &#160;<span id="projectnumber">2.56.0</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',false,false,'search.php','Search');
});
</script>
<div id="main-nav"></div>
<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="namespaceGlib.html">Glib</a></li><li class="navelem"><a class="el" href="classGlib_1_1ThreadPool.html">ThreadPool</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#pub-static-methods">Static Public Member Functions</a> &#124;
<a href="classGlib_1_1ThreadPool-members.html">List of all members</a>  </div>
  <div class="headertitle">
<div class="title">Glib::ThreadPool Class Reference<div class="ingroups"><a class="el" href="group__ThreadPools.html">Thread Pools</a></div></div>  </div>
</div><!--header-->
<div class="contents">

<p>A pool of threads to execute work concurrently.  
 <a href="classGlib_1_1ThreadPool.html#details">More...</a></p>

<p><code>#include &lt;glibmm/threadpool.h&gt;</code></p>
<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:afd549a2867eafe34663d8935c17efbe2"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1ThreadPool.html#afd549a2867eafe34663d8935c17efbe2">ThreadPool</a> (int max_threads=-1, bool exclusive=false)</td></tr>
<tr class="memdesc:afd549a2867eafe34663d8935c17efbe2"><td class="mdescLeft">&#160;</td><td class="mdescRight">Constructs a new thread pool.  <a href="#afd549a2867eafe34663d8935c17efbe2">More...</a><br /></td></tr>
<tr class="separator:afd549a2867eafe34663d8935c17efbe2"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a68dc576f1a75ec573d206fa8fdf9c5ea"><td class="memItemLeft" align="right" valign="top">virtual&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1ThreadPool.html#a68dc576f1a75ec573d206fa8fdf9c5ea">~ThreadPool</a> () noexcept</td></tr>
<tr class="separator:a68dc576f1a75ec573d206fa8fdf9c5ea"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a7b37fdac9f7a6e4a8791b4668e23e264"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1ThreadPool.html#a7b37fdac9f7a6e4a8791b4668e23e264">push</a> (const <a class="elRef" doxygen="libsigc++-2.0.tag:http://library.gnome.org/devel/libsigc++/unstable/" href="http://library.gnome.org/devel/libsigc++/unstable/classsigc_1_1slot.html">sigc::slot</a>&lt; void &gt;&amp; slot)</td></tr>
<tr class="memdesc:a7b37fdac9f7a6e4a8791b4668e23e264"><td class="mdescLeft">&#160;</td><td class="mdescRight">Inserts <em>slot</em> into the list of tasks to be executed by the pool.  <a href="#a7b37fdac9f7a6e4a8791b4668e23e264">More...</a><br /></td></tr>
<tr class="separator:a7b37fdac9f7a6e4a8791b4668e23e264"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ae19ed9a523788e40509ee4f39d2b10a9"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1ThreadPool.html#ae19ed9a523788e40509ee4f39d2b10a9">set_max_threads</a> (int max_threads)</td></tr>
<tr class="memdesc:ae19ed9a523788e40509ee4f39d2b10a9"><td class="mdescLeft">&#160;</td><td class="mdescRight">Sets the maximal allowed number of threads for the pool.  <a href="#ae19ed9a523788e40509ee4f39d2b10a9">More...</a><br /></td></tr>
<tr class="separator:ae19ed9a523788e40509ee4f39d2b10a9"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a665b9f1b05056056d8ab93743f914b3f"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1ThreadPool.html#a665b9f1b05056056d8ab93743f914b3f">get_max_threads</a> () const</td></tr>
<tr class="memdesc:a665b9f1b05056056d8ab93743f914b3f"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns the maximal number of threads for the pool.  <a href="#a665b9f1b05056056d8ab93743f914b3f">More...</a><br /></td></tr>
<tr class="separator:a665b9f1b05056056d8ab93743f914b3f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aa785ae473dc95908021ccf4dc2ebe292"><td class="memItemLeft" align="right" valign="top">unsigned int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1ThreadPool.html#aa785ae473dc95908021ccf4dc2ebe292">get_num_threads</a> () const</td></tr>
<tr class="memdesc:aa785ae473dc95908021ccf4dc2ebe292"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns the number of threads currently running in the pool.  <a href="#aa785ae473dc95908021ccf4dc2ebe292">More...</a><br /></td></tr>
<tr class="separator:aa785ae473dc95908021ccf4dc2ebe292"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af524f6259f1fe5fbdc5f485d9dbebd67"><td class="memItemLeft" align="right" valign="top">unsigned int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1ThreadPool.html#af524f6259f1fe5fbdc5f485d9dbebd67">unprocessed</a> () const</td></tr>
<tr class="memdesc:af524f6259f1fe5fbdc5f485d9dbebd67"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns the number of tasks still unprocessed in the pool.  <a href="#af524f6259f1fe5fbdc5f485d9dbebd67">More...</a><br /></td></tr>
<tr class="separator:af524f6259f1fe5fbdc5f485d9dbebd67"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a545086fd8284d982a0883638d12c4440"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1ThreadPool.html#a545086fd8284d982a0883638d12c4440">get_exclusive</a> () const</td></tr>
<tr class="memdesc:a545086fd8284d982a0883638d12c4440"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns whether all threads are exclusive to this pool.  <a href="#a545086fd8284d982a0883638d12c4440">More...</a><br /></td></tr>
<tr class="separator:a545086fd8284d982a0883638d12c4440"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a14a3e00a1fec5fec2bded78ea6a2b796"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1ThreadPool.html#a14a3e00a1fec5fec2bded78ea6a2b796">shutdown</a> (bool immediately=false)</td></tr>
<tr class="memdesc:a14a3e00a1fec5fec2bded78ea6a2b796"><td class="mdescLeft">&#160;</td><td class="mdescRight">Frees all resources allocated for the pool.  <a href="#a14a3e00a1fec5fec2bded78ea6a2b796">More...</a><br /></td></tr>
<tr class="separator:a14a3e00a1fec5fec2bded78ea6a2b796"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ac7f444f305942afb54c45204f509bc39"><td class="memItemLeft" align="right" valign="top">GThreadPool*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1ThreadPool.html#ac7f444f305942afb54c45204f509bc39">gobj</a> ()</td></tr>
<tr class="separator:ac7f444f305942afb54c45204f509bc39"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:acb4334cfa47d113dcc4f10ef00af81b3"><td class="memItemLeft" align="right" valign="top">const GThreadPool*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1ThreadPool.html#acb4334cfa47d113dcc4f10ef00af81b3">gobj</a> () const</td></tr>
<tr class="separator:acb4334cfa47d113dcc4f10ef00af81b3"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-static-methods"></a>
Static Public Member Functions</h2></td></tr>
<tr class="memitem:af057a2e30dc3e32137944f71658467db"><td class="memItemLeft" align="right" valign="top">static void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1ThreadPool.html#af057a2e30dc3e32137944f71658467db">set_max_unused_threads</a> (int max_threads)</td></tr>
<tr class="memdesc:af057a2e30dc3e32137944f71658467db"><td class="mdescLeft">&#160;</td><td class="mdescRight">Sets the maximal number of unused threads to <em>max_threads</em>.  <a href="#af057a2e30dc3e32137944f71658467db">More...</a><br /></td></tr>
<tr class="separator:af057a2e30dc3e32137944f71658467db"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aa0bb8c1914b2e36fa0222bbaeb44b94e"><td class="memItemLeft" align="right" valign="top">static int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1ThreadPool.html#aa0bb8c1914b2e36fa0222bbaeb44b94e">get_max_unused_threads</a> ()</td></tr>
<tr class="memdesc:aa0bb8c1914b2e36fa0222bbaeb44b94e"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns the maximal allowed number of unused threads.  <a href="#aa0bb8c1914b2e36fa0222bbaeb44b94e">More...</a><br /></td></tr>
<tr class="separator:aa0bb8c1914b2e36fa0222bbaeb44b94e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a9904f39dc346cd44296f361415147ae1"><td class="memItemLeft" align="right" valign="top">static unsigned int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1ThreadPool.html#a9904f39dc346cd44296f361415147ae1">get_num_unused_threads</a> ()</td></tr>
<tr class="memdesc:a9904f39dc346cd44296f361415147ae1"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns the number of currently unused threads.  <a href="#a9904f39dc346cd44296f361415147ae1">More...</a><br /></td></tr>
<tr class="separator:a9904f39dc346cd44296f361415147ae1"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a132a7f8416d29f9499ed87ba102c37a3"><td class="memItemLeft" align="right" valign="top">static void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1ThreadPool.html#a132a7f8416d29f9499ed87ba102c37a3">stop_unused_threads</a> ()</td></tr>
<tr class="memdesc:a132a7f8416d29f9499ed87ba102c37a3"><td class="mdescLeft">&#160;</td><td class="mdescRight">Stops all currently unused threads.  <a href="#a132a7f8416d29f9499ed87ba102c37a3">More...</a><br /></td></tr>
<tr class="separator:a132a7f8416d29f9499ed87ba102c37a3"><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 pool of threads to execute work concurrently. </p>
<dl class="deprecated"><dt><b><a class="el" href="deprecated.html#_deprecated000073">Deprecated:</a></b></dt><dd>This is deprecated in favor of the standard C++ concurrency API in C++11 and C++14. </dd></dl>
</div><h2 class="groupheader">Constructor &amp; Destructor Documentation</h2>
<a id="afd549a2867eafe34663d8935c17efbe2"></a>
<h2 class="memtitle"><span class="permalink"><a href="#afd549a2867eafe34663d8935c17efbe2">&#9670;&#160;</a></span>ThreadPool()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">Glib::ThreadPool::ThreadPool </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>max_threads</em> = <code>-1</code>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bool&#160;</td>
          <td class="paramname"><em>exclusive</em> = <code>false</code>&#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">explicit</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Constructs a new thread pool. </p>
<p>Whenever you call <a class="el" href="classGlib_1_1ThreadPool.html#a7b37fdac9f7a6e4a8791b4668e23e264" title="Inserts slot into the list of tasks to be executed by the pool. ">ThreadPool::push()</a>, either a new thread is created or an unused one is reused. At most <em>max_threads</em> threads are running concurrently for this thread pool. <em>max_threads&#160;=&#160;-1</em> allows unlimited threads to be created for this thread pool.</p>
<p>The parameter <em>exclusive</em> determines, whether the thread pool owns all threads exclusive or whether the threads are shared globally. If <em>exclusive</em> is <code>true</code>, <em>max_threads</em> threads are started immediately and they will run exclusively for this thread pool until it is destroyed by <a class="el" href="classGlib_1_1ThreadPool.html#a68dc576f1a75ec573d206fa8fdf9c5ea">~ThreadPool()</a>. If <em>exclusive</em> is <code>false</code>, threads are created when needed and shared between all non-exclusive thread pools. This implies that <em>max_threads</em> may not be -1 for exclusive thread pools.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">max_threads</td><td>The maximal number of threads to execute concurrently in the new thread pool, -1 means no limit. </td></tr>
    <tr><td class="paramname">exclusive</td><td>Should this thread pool be exclusive? </td></tr>
  </table>
  </dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname"><a class="el" href="classGlib_1_1ThreadError.html" title="Exception class for thread-related errors. ">Glib::ThreadError</a></td><td>An error can only occur when <em>exclusive</em> is set to <code>true</code> and not all <em>max_threads</em> threads could be created. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="a68dc576f1a75ec573d206fa8fdf9c5ea"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a68dc576f1a75ec573d206fa8fdf9c5ea">&#9670;&#160;</a></span>~ThreadPool()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">virtual Glib::ThreadPool::~ThreadPool </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">virtual</span><span class="mlabel">noexcept</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a id="a545086fd8284d982a0883638d12c4440"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a545086fd8284d982a0883638d12c4440">&#9670;&#160;</a></span>get_exclusive()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool Glib::ThreadPool::get_exclusive </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Returns whether all threads are exclusive to this pool. </p>
<dl class="section return"><dt>Returns</dt><dd>Whether all threads are exclusive to this pool. </dd></dl>

</div>
</div>
<a id="a665b9f1b05056056d8ab93743f914b3f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a665b9f1b05056056d8ab93743f914b3f">&#9670;&#160;</a></span>get_max_threads()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int Glib::ThreadPool::get_max_threads </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Returns the maximal number of threads for the pool. </p>
<dl class="section return"><dt>Returns</dt><dd>The maximal number of threads. </dd></dl>

</div>
</div>
<a id="aa0bb8c1914b2e36fa0222bbaeb44b94e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aa0bb8c1914b2e36fa0222bbaeb44b94e">&#9670;&#160;</a></span>get_max_unused_threads()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">static int Glib::ThreadPool::get_max_unused_threads </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Returns the maximal allowed number of unused threads. </p>
<dl class="section return"><dt>Returns</dt><dd>The maximal number of unused threads. </dd></dl>

</div>
</div>
<a id="aa785ae473dc95908021ccf4dc2ebe292"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aa785ae473dc95908021ccf4dc2ebe292">&#9670;&#160;</a></span>get_num_threads()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">unsigned int Glib::ThreadPool::get_num_threads </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Returns the number of threads currently running in the pool. </p>
<dl class="section return"><dt>Returns</dt><dd>The number of threads currently running. </dd></dl>

</div>
</div>
<a id="a9904f39dc346cd44296f361415147ae1"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a9904f39dc346cd44296f361415147ae1">&#9670;&#160;</a></span>get_num_unused_threads()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">static unsigned int Glib::ThreadPool::get_num_unused_threads </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Returns the number of currently unused threads. </p>
<dl class="section return"><dt>Returns</dt><dd>The number of currently unused threads. </dd></dl>

</div>
</div>
<a id="ac7f444f305942afb54c45204f509bc39"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ac7f444f305942afb54c45204f509bc39">&#9670;&#160;</a></span>gobj() <span class="overload">[1/2]</span></h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">GThreadPool* Glib::ThreadPool::gobj </td>
          <td>(</td>
          <td class="paramname"></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">

</div>
</div>
<a id="acb4334cfa47d113dcc4f10ef00af81b3"></a>
<h2 class="memtitle"><span class="permalink"><a href="#acb4334cfa47d113dcc4f10ef00af81b3">&#9670;&#160;</a></span>gobj() <span class="overload">[2/2]</span></h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">const GThreadPool* Glib::ThreadPool::gobj </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

</div>
</div>
<a id="a7b37fdac9f7a6e4a8791b4668e23e264"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a7b37fdac9f7a6e4a8791b4668e23e264">&#9670;&#160;</a></span>push()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void Glib::ThreadPool::push </td>
          <td>(</td>
          <td class="paramtype">const <a class="elRef" doxygen="libsigc++-2.0.tag:http://library.gnome.org/devel/libsigc++/unstable/" href="http://library.gnome.org/devel/libsigc++/unstable/classsigc_1_1slot.html">sigc::slot</a>&lt; void &gt; &amp;&#160;</td>
          <td class="paramname"><em>slot</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Inserts <em>slot</em> into the list of tasks to be executed by the pool. </p>
<p>When the number of currently running threads is lower than the maximal allowed number of threads, a new thread is started (or reused). Otherwise <em>slot</em> stays in the queue until a thread in this pool finishes its previous task and processes <em>slot</em>.</p>
<p>Because <a class="elRef" doxygen="libsigc++-2.0.tag:http://library.gnome.org/devel/libsigc++/unstable/" href="http://library.gnome.org/devel/libsigc++/unstable/structsigc_1_1trackable.html">sigc::trackable</a> is not thread-safe, if the slot represents a non-static class method and is created by <a class="elRef" doxygen="libsigc++-2.0.tag:http://library.gnome.org/devel/libsigc++/unstable/" href="http://library.gnome.org/devel/libsigc++/unstable/group__mem__fun.html#gadf6b6d22c503b439019f0a2e77352419">sigc::mem_fun()</a>, the class concerned should not derive from <a class="elRef" doxygen="libsigc++-2.0.tag:http://library.gnome.org/devel/libsigc++/unstable/" href="http://library.gnome.org/devel/libsigc++/unstable/structsigc_1_1trackable.html">sigc::trackable</a>. You can use, say, boost::bind() or, in C++11, <a class="elRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a01682.html#ga4c3052b337dde285bace96cbb996055c">std::bind()</a> or a C++11 lambda expression instead of <a class="elRef" doxygen="libsigc++-2.0.tag:http://library.gnome.org/devel/libsigc++/unstable/" href="http://library.gnome.org/devel/libsigc++/unstable/group__mem__fun.html#gadf6b6d22c503b439019f0a2e77352419">sigc::mem_fun()</a>.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">slot</td><td>A new task for the thread pool. </td></tr>
  </table>
  </dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname"><a class="el" href="classGlib_1_1ThreadError.html" title="Exception class for thread-related errors. ">Glib::ThreadError</a></td><td>An error can only occur when a new thread couldn't be created. In that case <em>slot</em> is simply appended to the queue of work to do. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="ae19ed9a523788e40509ee4f39d2b10a9"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ae19ed9a523788e40509ee4f39d2b10a9">&#9670;&#160;</a></span>set_max_threads()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void Glib::ThreadPool::set_max_threads </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>max_threads</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Sets the maximal allowed number of threads for the pool. </p>
<p>A value of -1 means that the maximal number of threads is unlimited. Setting <em>max_threads</em> to 0 means stopping all work for pool. It is effectively frozen until <em>max_threads</em> is set to a non-zero value again.</p>
<p>A thread is never terminated while it is still running. Instead the maximal number of threads only has effect for the allocation of new threads in <a class="el" href="classGlib_1_1ThreadPool.html#a7b37fdac9f7a6e4a8791b4668e23e264" title="Inserts slot into the list of tasks to be executed by the pool. ">ThreadPool::push()</a>. A new thread is allocated whenever the number of currently running threads in the pool is smaller than the maximal number.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">max_threads</td><td>A new maximal number of threads for the pool. </td></tr>
  </table>
  </dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname"><a class="el" href="classGlib_1_1ThreadError.html" title="Exception class for thread-related errors. ">Glib::ThreadError</a></td><td>An error can only occur when a new thread couldn't be created. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="af057a2e30dc3e32137944f71658467db"></a>
<h2 class="memtitle"><span class="permalink"><a href="#af057a2e30dc3e32137944f71658467db">&#9670;&#160;</a></span>set_max_unused_threads()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">static void Glib::ThreadPool::set_max_unused_threads </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>max_threads</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Sets the maximal number of unused threads to <em>max_threads</em>. </p>
<p>If <em>max_threads</em> is -1, no limit is imposed on the number of unused threads. </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">max_threads</td><td>Maximal number of unused threads. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="a14a3e00a1fec5fec2bded78ea6a2b796"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a14a3e00a1fec5fec2bded78ea6a2b796">&#9670;&#160;</a></span>shutdown()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void Glib::ThreadPool::shutdown </td>
          <td>(</td>
          <td class="paramtype">bool&#160;</td>
          <td class="paramname"><em>immediately</em> = <code>false</code></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Frees all resources allocated for the pool. </p>
<p>If <em>immediately</em> is <code>true</code>, no new task is processed. Otherwise the pool is not freed before the last task is processed. Note however, that no thread of this pool is interrupted while processing a task. Instead at least all still running threads can finish their tasks before the pool is freed.</p>
<p>This method does not return before all tasks to be processed (dependent on <em>immediately</em>, whether all or only the currently running) are ready. After calling <a class="el" href="classGlib_1_1ThreadPool.html#a14a3e00a1fec5fec2bded78ea6a2b796" title="Frees all resources allocated for the pool. ">shutdown()</a> the pool must not be used anymore.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">immediately</td><td>Should the pool shut down immediately? </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="a132a7f8416d29f9499ed87ba102c37a3"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a132a7f8416d29f9499ed87ba102c37a3">&#9670;&#160;</a></span>stop_unused_threads()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">static void Glib::ThreadPool::stop_unused_threads </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Stops all currently unused threads. </p>
<p>This does not change the maximal number of unused threads. This function can be used to regularly stop all unused threads e.g. from <a class="el" href="group__MainLoop.html#gaadb206fcc112f086f9d47c016b1f2175" title="Convenience timeout signal. ">Glib::signal_timeout()</a>. </p>

</div>
</div>
<a id="af524f6259f1fe5fbdc5f485d9dbebd67"></a>
<h2 class="memtitle"><span class="permalink"><a href="#af524f6259f1fe5fbdc5f485d9dbebd67">&#9670;&#160;</a></span>unprocessed()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">unsigned int Glib::ThreadPool::unprocessed </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Returns the number of tasks still unprocessed in the pool. </p>
<dl class="section return"><dt>Returns</dt><dd>The number of unprocessed tasks. </dd></dl>

</div>
</div>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Sat Mar 31 2018 09:12:11 for glibmm by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.13
</small></address>
</body>
</html>