blob: 3d34525de1f54c443f24fd8b02d83708dbd78918 (
plain)
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
|
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Class thread_group</title>
<link rel="stylesheet" href="boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.67.2">
<link rel="start" href="index.html" title="The Boost C++ Libraries">
<link rel="up" href="threads/reference.html#id619529" title="Header <boost/thread/thread.hpp>">
<link rel="prev" href="thread.html" title="Class thread">
<link rel="next" href="thread_specific_ptr.html" title="Class thread_specific_ptr">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%">
<td valign="top"><img alt="boost.png (6897 bytes)" width="277" height="86" src="../../boost.png"></td>
<td align="center"><a href="../../index.htm">Home</a></td>
<td align="center"><a href="../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="../../people/people.htm">People</a></td>
<td align="center"><a href="../../more/faq.htm">FAQ</a></td>
<td align="center"><a href="../../more/index.htm">More</a></td>
</table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="thread.html"><img src="images/prev.png" alt="Prev"></a><a accesskey="u" href="threads/reference.html#id619529"><img src="images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="images/home.png" alt="Home"></a><a accesskey="n" href="thread_specific_ptr.html"><img src="images/next.png" alt="Next"></a>
</div>
<div class="refentry" lang="en">
<a name="thread_group"></a><div class="titlepage"></div>
<div class="refnamediv">
<h2><span class="refentrytitle">Class thread_group</span></h2>
<p>boost::thread_group —
The <a href="thread_group.html" title="Class thread_group">thread_group</a> class provides a container
for easy grouping of threads to simplify several common thread
creation and management idioms.
</p>
</div>
<h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2>
<div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis">
<span class="bold"><strong>class</strong></span> thread_group : <span class="bold"><strong>private</strong></span> boost::noncopyable <span class="emphasis"><em>// Exposition only</em></span>
{
<span class="bold"><strong>public</strong></span>:
<span class="emphasis"><em>// <a href="thread_group.html#thread_groupconstruct-copy-destruct">construct/copy/destruct</a></em></span>
<a href="thread_group.html#id725909-bb">thread_group</a>();
<a href="thread_group.html#id1147177-bb">~thread_group</a>();
<span class="emphasis"><em>// <a href="thread_group.html#id1103368-bb">modifier</a></em></span>
<span class="type"><a href="thread.html" title="Class thread">thread</a>*</span> <a href="thread_group.html#id695313-bb">create_thread</a>(<span class="bold"><strong>const</strong></span> boost::function0<<span class="bold"><strong>void</strong></span>>&);
<span class="type"><span class="bold"><strong>void</strong></span></span> <a href="thread_group.html#id583731-bb">add_thread</a>(<a href="thread.html" title="Class thread">thread</a>* thrd);
<span class="type"><span class="bold"><strong>void</strong></span></span> <a href="thread_group.html#id588973-bb">remove_thread</a>(<a href="thread.html" title="Class thread">thread</a>* thrd);
<span class="type"><span class="bold"><strong>void</strong></span></span> <a href="thread_group.html#id1034490-bb">join_all</a>();
};</pre></div>
<div class="refsect1" lang="en">
<a name="id1220071"></a><h2>Description</h2>
<div class="refsect2" lang="en">
<a name="id1220075"></a><h3>
<a name="thread_groupconstruct-copy-destruct"></a><code class="computeroutput">thread_group</code> construct/copy/destruct</h3>
<div class="orderedlist"><ol type="1">
<li>
<pre class="literallayout"><a name="id725909-bb"></a>thread_group();</pre>
<p><b xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"><span class="term">Effects</span></b>:
Constructs an empty <a href="thread_group.html" title="Class thread_group">thread_group</a>
container.</p>
</li>
<li>
<pre class="literallayout"><a name="id1147177-bb"></a>~thread_group();</pre>
<p><b xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"><span class="term">Effects</span></b>:
Destroys each contained thread object. Destroys <code class="computeroutput">*this</code>.<br><b xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"><span class="term">Notes</span></b>:
Behavior is undefined if another thread references
<code class="computeroutput">*this </code> during the execution of the destructor.
</p>
</li>
</ol></div>
</div>
<div class="refsect2" lang="en">
<a name="id1220167"></a><h3>
<a name="id1103368-bb"></a><code class="computeroutput">thread_group</code> modifier</h3>
<div class="orderedlist"><ol type="1">
<li>
<pre class="literallayout"><span class="type"><a href="thread.html" title="Class thread">thread</a>*</span> <a name="id695313-bb"></a>create_thread(<span class="bold"><strong>const</strong></span> boost::function0<<span class="bold"><strong>void</strong></span>>& threadfunc);</pre>
<p><b xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"><span class="term">Effects</span></b>:
Creates a new <a href="thread.html" title="Class thread">thread</a> object
that executes <code class="computeroutput">threadfunc</code> and adds it to the
<code class="computeroutput">thread_group</code> container object's list of managed
<a href="thread.html" title="Class thread">thread</a> objects.<br><b xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"><span class="term">Returns</span></b>:
Pointer to the newly created
<a href="thread.html" title="Class thread">thread</a> object.</p>
</li>
<li>
<pre class="literallayout"><span class="type"><span class="bold"><strong>void</strong></span></span> <a name="id583731-bb"></a>add_thread(<a href="thread.html" title="Class thread">thread</a>* thrd thrd);</pre>
<p><b xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"><span class="term">Effects</span></b>:
Adds <code class="computeroutput">thrd</code> to the
<a href="thread_group.html" title="Class thread_group">thread_group</a> object's list of managed
<a href="thread.html" title="Class thread">thread</a> objects. The <code class="computeroutput">thrd</code>
object must have been allocated via <code class="computeroutput">operator new</code> and will
be deleted when the group is destroyed.</p>
</li>
<li>
<pre class="literallayout"><span class="type"><span class="bold"><strong>void</strong></span></span> <a name="id588973-bb"></a>remove_thread(<a href="thread.html" title="Class thread">thread</a>* thrd thrd);</pre>
<p><b xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"><span class="term">Effects</span></b>:
Removes <code class="computeroutput">thread</code> from <code class="computeroutput">*this</code>'s
list of managed <a href="thread.html" title="Class thread">thread</a> objects.<br><b xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"><span class="term">Throws</span></b>:
<span class="bold"><strong>???</strong></span> if
<code class="computeroutput">thrd</code> is not in <code class="computeroutput">*this</code>'s list
of managed <a href="thread.html" title="Class thread">thread</a> objects.</p>
</li>
<li>
<pre class="literallayout"><span class="type"><span class="bold"><strong>void</strong></span></span> <a name="id1034490-bb"></a>join_all();</pre>
<p><b xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"><span class="term">Effects</span></b>:
Calls <code class="computeroutput">join()</code> on each of the managed
<a href="thread.html" title="Class thread">thread</a> objects.</p>
</li>
</ol></div>
</div>
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><small>Copyright © 2001-2003 William E. Kempf</small></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="thread.html"><img src="images/prev.png" alt="Prev"></a><a accesskey="u" href="threads/reference.html#id619529"><img src="images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="images/home.png" alt="Home"></a><a accesskey="n" href="thread_specific_ptr.html"><img src="images/next.png" alt="Next"></a>
</div>
</body>
</html>
|