Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_33_1/doc/html/mutex.html @ 25

Last change on this file since 25 was 12, checked in by landauf, 17 years ago

added boost

File size: 7.7 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.69.1">
7<link rel="start" href="index.html" title="The Boost C++ Libraries">
8<link rel="up" href="threads/reference.html#id2534429" 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.png (6897 bytes)" 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="threads/reference.html#id2534429"><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="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="threads/concepts.html#threads.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#mutexconstruct-copy-destruct">construct/copy/destruct</a></em></span>
41  <a href="mutex.html#id2601515-bb">mutex</a>();
42  <a href="mutex.html#id2589157-bb">~mutex</a>();
43};</pre></div>
44<div class="refsect1" lang="en">
45<a name="id2780758"></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="threads/concepts.html#threads.concepts.Mutex" title="Mutex Concept">Mutex</a> concept.
48                        It should be used to synchronize access to shared resources using
49                        <a href="threads/concepts.html#threads.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="threads/concepts.html#threads.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="threads/concepts.html#threads.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="threads/concepts.html#threads.concepts.ScopedLock" title="ScopedLock Concept">ScopedLock</a></td>
74</tr></tbody>
75</table></div>
76<p>The <a href="mutex.html" title="Class mutex">mutex</a> class uses an
77                        <a href="threads/concepts.html#threads.concepts.unspecified-locking-strategy" title="Unspecified Locking Strategy">Unspecified</a>
78                        locking strategy, so attempts to recursively lock a <a href="mutex.html" title="Class mutex">mutex</a>
79                        object or attempts to unlock one by threads that don't own a lock on it result in
80                        <span class="bold"><strong>undefined behavior</strong></span>.
81                        This strategy allows implementations to be as efficient as possible
82                        on any given platform. It is, however, recommended that
83                        implementations include debugging support to detect misuse when
84                        <code class="computeroutput">NDEBUG</code> is not defined.</p>
85<p>Like all
86                        <a href="threads/concepts.html#threads.concepts.mutex-models" title="Mutex Models">mutex models</a>
87                        in <span class="bold"><strong>Boost.Threads</strong></span>, <a href="mutex.html" title="Class mutex">mutex</a> leaves the
88                        <a href="threads/concepts.html#threads.concepts.sheduling-policies" title="Scheduling Policies">scheduling policy</a>
89                        as <a href="threads/concepts.html#threads.concepts.unspecified-scheduling-policy" title="Unspecified Policy">Unspecified</a>.
90                        Programmers should make no assumptions about the order in which
91                        waiting threads acquire a lock.</p>
92<div class="refsect2" lang="en">
93<a name="id2780971"></a><h3>
94<a name="mutexconstruct-copy-destruct"></a><code class="computeroutput">mutex</code> construct/copy/destruct</h3>
95<div class="orderedlist"><ol type="1">
96<li>
97<pre class="literallayout"><a name="id2601515-bb"></a>mutex();</pre>
98<p><b xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"><span class="term">Effects</span></b>:
99
100    Constructs a <a href="mutex.html" title="Class mutex">mutex</a> object.
101                        <br><b xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"><span class="term">Postconditions</span></b>:
102
103    <code class="computeroutput">*this</code> is in an unlocked state.
104                        </p>
105</li>
106<li>
107<pre class="literallayout"><a name="id2589157-bb"></a>~mutex();</pre>
108<p><b xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"><span class="term">Effects</span></b>:
109
110    Destroys a <a href="mutex.html" title="Class mutex">mutex</a> object.<br><b xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"><span class="term">Requires</span></b>:
111
112    <code class="computeroutput">*this</code> is in an unlocked state.<br><b xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"><span class="term">Notes</span></b>:
113
114    <span class="bold"><strong>Danger:</strong></span> Destruction of a
115                        locked mutex is a serious programming error resulting in undefined
116                        behavior such as a program crash.</p>
117</li>
118</ol></div>
119</div>
120</div>
121</div>
122<table width="100%"><tr>
123<td align="left"></td>
124<td align="right"><small>Copyright © 2001-2003 William E. Kempf</small></td>
125</tr></table>
126<hr>
127<div class="spirit-nav">
128<a accesskey="p" href="thread_resource_error.html"><img src="images/prev.png" alt="Prev"></a><a accesskey="u" href="threads/reference.html#id2534429"><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>
129</div>
130</body>
131</html>
Note: See TracBrowser for help on using the repository browser.