Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/doc/html/boost/mutex.html @ 47

Last change on this file since 47 was 29, checked in by landauf, 17 years ago

updated boost from 1_33_1 to 1_34_1

File size: 7.8 KB
Line 
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
4<title>Class mutex</title>
5<link rel="stylesheet" href="../boostbook.css" type="text/css">
6<meta name="generator" content="DocBook XSL Stylesheets V1.68.1">
7<link rel="start" href="../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset">
8<link rel="up" href="../thread/reference.html#header.boost.thread.mutex.hpp" title="Header &lt;boost/thread/mutex.hpp&gt;">
9<link rel="prev" href="thread_resource_error.html" title="Class thread_resource_error">
10<link rel="next" href="try_mutex.html" title="Class try_mutex">
11</head>
12<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
13<table cellpadding="2" width="100%">
14<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td>
15<td align="center"><a href="../../../index.htm">Home</a></td>
16<td align="center"><a href="../../../libs/libraries.htm">Libraries</a></td>
17<td align="center"><a href="../../../people/people.htm">People</a></td>
18<td align="center"><a href="../../../more/faq.htm">FAQ</a></td>
19<td align="center"><a href="../../../more/index.htm">More</a></td>
20</table>
21<hr>
22<div class="spirit-nav">
23<a accesskey="p" href="thread_resource_error.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../thread/reference.html#header.boost.thread.mutex.hpp"><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="try_mutex.html"><img src="../images/next.png" alt="Next"></a>
24</div>
25<div class="refentry" lang="en">
26<a name="boost.mutex"></a><div class="titlepage"></div>
27<div class="refnamediv">
28<h2><span class="refentrytitle">Class mutex</span></h2>
29<p>boost::mutex &#8212; <p>The <a href="mutex.html" title="Class mutex">mutex</a> class is a model of the
30                        <a href="../thread/concepts.html#thread.concepts.Mutex" title="Mutex Concept">Mutex</a> concept.</p></p>
31</div>
32<h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2>
33<div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis">
34<span class="bold"><strong>class</strong></span> mutex : <span class="bold"><strong>private</strong></span> boost::noncopyable   <span class="emphasis"><em>// Exposition only</em></span>
35{
36<span class="bold"><strong>public</strong></span>:
37  <span class="emphasis"><em>// types</em></span>
38  <span class="bold"><strong>typedef</strong></span> <span class="emphasis"><em>implementation-defined</em></span> scoped_lock;
39
40  <span class="emphasis"><em>// <a href="mutex.html#boost.mutexconstruct-copy-destruct">construct/copy/destruct</a></em></span>
41  <a href="mutex.html#id1311831-bb">mutex</a>();
42  <a href="mutex.html#id1254923-bb">~mutex</a>();
43};</pre></div>
44<div class="refsect1" lang="en">
45<a name="id1738524"></a><h2>Description</h2>
46<p>The <a href="mutex.html" title="Class mutex">mutex</a> class is a model of the
47                        <a href="../thread/concepts.html#thread.concepts.Mutex" title="Mutex Concept">Mutex</a> concept.
48                        It should be used to synchronize access to shared resources using
49                        <a href="../thread/concepts.html#thread.concepts.unspecified-locking-strategy" title="Unspecified Locking Strategy">Unspecified</a>
50                        locking mechanics.</p>
51<p>For classes that model related mutex concepts, see
52                        <a href="try_mutex.html" title="Class try_mutex">try_mutex</a> and <a href="timed_mutex.html" title="Class timed_mutex">timed_mutex</a>.</p>
53<p>For <a href="../thread/concepts.html#thread.concepts.recursive-locking-strategy" title="Recursive Locking Strategy">Recursive</a>
54                        locking mechanics, see <a href="recursive_mutex.html" title="Class recursive_mutex">recursive_mutex</a>,
55                        <a href="recursive_try_mutex.html" title="Class recursive_try_mutex">recursive_try_mutex</a>, and <a href="recursive_timed_mutex.html" title="Class recursive_timed_mutex">recursive_timed_mutex</a>.
56                        </p>
57<p>The <a href="mutex.html" title="Class mutex">mutex</a> class supplies the following typedef,
58                        which <a href="../thread/concepts.html#thread.concepts.lock-models" title="Lock Models">models</a>
59                        the specified locking strategy:
60
61                        </p>
62<div class="informaltable"><table class="table">
63<colgroup>
64<col>
65<col>
66</colgroup>
67<thead><tr>
68<th align="left">Lock Name</th>
69<th align="left">Lock Concept</th>
70</tr></thead>
71<tbody><tr>
72<td align="left">scoped_lock</td>
73<td align="left"><a href="../thread/concepts.html#thread.concepts.ScopedLock" title="ScopedLock Concept">ScopedLock</a></td>
74</tr></tbody>
75</table></div>
76<p>                     
77                        </p>
78<p>The <a href="mutex.html" title="Class mutex">mutex</a> class uses an
79                        <a href="../thread/concepts.html#thread.concepts.unspecified-locking-strategy" title="Unspecified Locking Strategy">Unspecified</a>
80                        locking strategy, so attempts to recursively lock a <a href="mutex.html" title="Class mutex">mutex</a>
81                        object or attempts to unlock one by threads that don't own a lock on it result in
82                        <span class="bold"><strong>undefined behavior</strong></span>.
83                        This strategy allows implementations to be as efficient as possible
84                        on any given platform. It is, however, recommended that
85                        implementations include debugging support to detect misuse when
86                        <code class="computeroutput">NDEBUG</code> is not defined.</p>
87<p>Like all
88                        <a href="../thread/concepts.html#thread.concepts.mutex-models" title="Mutex Models">mutex models</a>
89                        in <span class="bold"><strong>Boost.Thread</strong></span>, <a href="mutex.html" title="Class mutex">mutex</a> leaves the
90                        <a href="../thread/concepts.html#thread.concepts.sheduling-policies" title="Scheduling Policies">scheduling policy</a>
91                        as <a href="../thread/concepts.html#thread.concepts.unspecified-scheduling-policy" title="Unspecified Policy">Unspecified</a>.
92                        Programmers should make no assumptions about the order in which
93                        waiting threads acquire a lock.</p>
94<div class="refsect2" lang="en">
95<a name="id1738760"></a><h3>
96<a name="boost.mutexconstruct-copy-destruct"></a><code class="computeroutput">mutex</code> construct/copy/destruct</h3>
97<div class="orderedlist"><ol type="1">
98<li>
99<pre class="literallayout"><a name="id1311831-bb"></a>mutex();</pre>
100<div class="variablelist"><table border="0">
101<col align="left" valign="top">
102<tbody>
103<tr>
104<td>
105<span class="term">Effects:</span></td>
106<td>Constructs a <a href="mutex.html" title="Class mutex">mutex</a> object.
107                        </td>
108</tr>
109<tr>
110<td>
111<span class="term">Postconditions:</span></td>
112<td>
113<code class="computeroutput">*this</code> is in an unlocked state.
114                        </td>
115</tr>
116</tbody>
117</table></div>
118</li>
119<li>
120<pre class="literallayout"><a name="id1254923-bb"></a>~mutex();</pre>
121<div class="variablelist"><table border="0">
122<col align="left" valign="top">
123<tbody>
124<tr>
125<td>
126<span class="term">Effects:</span></td>
127<td>Destroys a <a href="mutex.html" title="Class mutex">mutex</a> object.</td>
128</tr>
129<tr>
130<td>
131<span class="term">Requires:</span></td>
132<td>
133<code class="computeroutput">*this</code> is in an unlocked state.</td>
134</tr>
135<tr>
136<td>
137<span class="term">Notes:</span></td>
138<td>
139<span class="bold"><strong>Danger:</strong></span> Destruction of a
140                        locked mutex is a serious programming error resulting in undefined
141                        behavior such as a program crash.</td>
142</tr>
143</tbody>
144</table></div>
145</li>
146</ol></div>
147</div>
148</div>
149</div>
150<table width="100%"><tr>
151<td align="left"></td>
152<td align="right"><small>Copyright © 2001-2003 William E. Kempf</small></td>
153</tr></table>
154<hr>
155<div class="spirit-nav">
156<a accesskey="p" href="thread_resource_error.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../thread/reference.html#header.boost.thread.mutex.hpp"><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="try_mutex.html"><img src="../images/next.png" alt="Next"></a>
157</div>
158</body>
159</html>
Note: See TracBrowser for help on using the repository browser.