File: classGlib_1_1ThreadPool.html

package info (click to toggle)
glibmm2.4 2.42.0-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 53,308 kB
  • ctags: 14,868
  • sloc: xml: 108,462; cpp: 15,282; sh: 11,421; perl: 5,139; python: 1,626; makefile: 304
file content (520 lines) | stat: -rw-r--r-- 29,297 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
<!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.7"/>
<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" />
</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">glibmm
   &#160;<span id="projectnumber">2.42.0</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.7 -->
  <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="examples.html"><span>Examples</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="inherits.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="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:aaed3b188194822da768fa9a29e608b16"><td class="memItemLeft" align="right" valign="top">virtual&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1ThreadPool.html#aaed3b188194822da768fa9a29e608b16">~ThreadPool</a> ()</td></tr>
<tr class="separator:aaed3b188194822da768fa9a29e608b16"><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="/opt/gnome/share/doc/libsigc++-2.0/reference/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:a6dbe83ceeb65fd0f157e1b1895ed3db5"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1ThreadPool.html#a6dbe83ceeb65fd0f157e1b1895ed3db5">get_max_threads</a> () const </td></tr>
<tr class="memdesc:a6dbe83ceeb65fd0f157e1b1895ed3db5"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns the maximal number of threads for the pool.  <a href="#a6dbe83ceeb65fd0f157e1b1895ed3db5">More...</a><br /></td></tr>
<tr class="separator:a6dbe83ceeb65fd0f157e1b1895ed3db5"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a2a6bc66c4eb03e346429e6f7fe3a5fe3"><td class="memItemLeft" align="right" valign="top">unsigned int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1ThreadPool.html#a2a6bc66c4eb03e346429e6f7fe3a5fe3">get_num_threads</a> () const </td></tr>
<tr class="memdesc:a2a6bc66c4eb03e346429e6f7fe3a5fe3"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns the number of threads currently running in the pool.  <a href="#a2a6bc66c4eb03e346429e6f7fe3a5fe3">More...</a><br /></td></tr>
<tr class="separator:a2a6bc66c4eb03e346429e6f7fe3a5fe3"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a8eb62f226a5f5e2f93b66b25c49cc401"><td class="memItemLeft" align="right" valign="top">unsigned int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1ThreadPool.html#a8eb62f226a5f5e2f93b66b25c49cc401">unprocessed</a> () const </td></tr>
<tr class="memdesc:a8eb62f226a5f5e2f93b66b25c49cc401"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns the number of tasks still unprocessed in the pool.  <a href="#a8eb62f226a5f5e2f93b66b25c49cc401">More...</a><br /></td></tr>
<tr class="separator:a8eb62f226a5f5e2f93b66b25c49cc401"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ab59582875f80b94bf4707c1c77f234ba"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1ThreadPool.html#ab59582875f80b94bf4707c1c77f234ba">get_exclusive</a> () const </td></tr>
<tr class="memdesc:ab59582875f80b94bf4707c1c77f234ba"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns whether all threads are exclusive to this pool.  <a href="#ab59582875f80b94bf4707c1c77f234ba">More...</a><br /></td></tr>
<tr class="separator:ab59582875f80b94bf4707c1c77f234ba"><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:aba0bd84d5851f3a64269685dc102cd4b"><td class="memItemLeft" align="right" valign="top">const GThreadPool*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1ThreadPool.html#aba0bd84d5851f3a64269685dc102cd4b">gobj</a> () const </td></tr>
<tr class="separator:aba0bd84d5851f3a64269685dc102cd4b"><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>
</div><h2 class="groupheader">Constructor &amp; Destructor Documentation</h2>
<a class="anchor" id="afd549a2867eafe34663d8935c17efbe2"></a>
<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#aaed3b188194822da768fa9a29e608b16">~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 class="anchor" id="aaed3b188194822da768fa9a29e608b16"></a>
<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>  </td>
  </tr>
</table>
</div><div class="memdoc">

</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a class="anchor" id="ab59582875f80b94bf4707c1c77f234ba"></a>
<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 class="anchor" id="a6dbe83ceeb65fd0f157e1b1895ed3db5"></a>
<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 class="anchor" id="aa0bb8c1914b2e36fa0222bbaeb44b94e"></a>
<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 class="anchor" id="a2a6bc66c4eb03e346429e6f7fe3a5fe3"></a>
<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 class="anchor" id="a9904f39dc346cd44296f361415147ae1"></a>
<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 class="anchor" id="ac7f444f305942afb54c45204f509bc39"></a>
<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 class="anchor" id="aba0bd84d5851f3a64269685dc102cd4b"></a>
<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 class="anchor" id="a7b37fdac9f7a6e4a8791b4668e23e264"></a>
<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="/opt/gnome/share/doc/libsigc++-2.0/reference/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="/opt/gnome/share/doc/libsigc++-2.0/reference/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="/opt/gnome/share/doc/libsigc++-2.0/reference/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="/opt/gnome/share/doc/libsigc++-2.0/reference/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="/opt/gnome/share/mm-common/doctags/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="/opt/gnome/share/doc/libsigc++-2.0/reference/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 class="anchor" id="ae19ed9a523788e40509ee4f39d2b10a9"></a>
<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 class="anchor" id="af057a2e30dc3e32137944f71658467db"></a>
<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 class="anchor" id="a14a3e00a1fec5fec2bded78ea6a2b796"></a>
<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 class="anchor" id="a132a7f8416d29f9499ed87ba102c37a3"></a>
<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 class="anchor" id="a8eb62f226a5f5e2f93b66b25c49cc401"></a>
<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 Mon Sep 22 2014 21:38:33 for glibmm by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.7
</small></address>
</body>
</html>