1 | <html> |
---|
2 | <head> |
---|
3 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> |
---|
4 | <title>Class recursive_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.recursive_mutex.hpp" title="Header <boost/thread/recursive_mutex.hpp>"> |
---|
9 | <link rel="prev" href="call_once.html" title="Function call_once"> |
---|
10 | <link rel="next" href="recursive_try_mutex.html" title="Class recursive_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="call_once.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../thread/reference.html#header.boost.thread.recursive_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="recursive_try_mutex.html"><img src="../images/next.png" alt="Next"></a> |
---|
24 | </div> |
---|
25 | <div class="refentry" lang="en"> |
---|
26 | <a name="boost.recursive_mutex"></a><div class="titlepage"></div> |
---|
27 | <div class="refnamediv"> |
---|
28 | <h2><span class="refentrytitle">Class recursive_mutex</span></h2> |
---|
29 | <p>boost::recursive_mutex — <p>The <a href="recursive_mutex.html" title="Class recursive_mutex">recursive_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> recursive_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="recursive_mutex.html#boost.recursive_mutexconstruct-copy-destruct">construct/copy/destruct</a></em></span> |
---|
41 | <a href="recursive_mutex.html#id652014-bb">recursive_mutex</a>(); |
---|
42 | <a href="recursive_mutex.html#id1034540-bb">~recursive_mutex</a>(); |
---|
43 | };</pre></div> |
---|
44 | <div class="refsect1" lang="en"> |
---|
45 | <a name="id1740293"></a><h2>Description</h2> |
---|
46 | <p>The <a href="recursive_mutex.html" title="Class recursive_mutex">recursive_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.recursive-locking-strategy" title="Recursive Locking Strategy">Recursive</a> |
---|
50 | locking mechanics.</p> |
---|
51 | <p>For classes that model related mutex concepts, see |
---|
52 | <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>.</p> |
---|
53 | <p>For <a href="../thread/concepts.html#thread.concepts.unspecified-locking-strategy" title="Unspecified Locking Strategy">Unspecified</a> |
---|
54 | locking mechanics, see <a href="mutex.html" title="Class mutex">mutex</a>, |
---|
55 | <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>. |
---|
56 | </p> |
---|
57 | <p>The <a href="recursive_mutex.html" title="Class recursive_mutex">recursive_mutex</a> class supplies the following typedef, |
---|
58 | which models the specified locking strategy: |
---|
59 | |
---|
60 | </p> |
---|
61 | <div class="table"> |
---|
62 | <a name="id1740390"></a><p class="title"><b>Table 15.23. Supported Lock Types</b></p> |
---|
63 | <table class="table" summary="Supported Lock Types"> |
---|
64 | <colgroup> |
---|
65 | <col> |
---|
66 | <col> |
---|
67 | </colgroup> |
---|
68 | <thead><tr> |
---|
69 | <th align="left">Lock Name</th> |
---|
70 | <th align="left">Lock Concept</th> |
---|
71 | </tr></thead> |
---|
72 | <tbody><tr> |
---|
73 | <td align="left">scoped_lock</td> |
---|
74 | <td align="left"><a href="../thread/concepts.html#thread.concepts.ScopedLock" title="ScopedLock Concept">ScopedLock</a></td> |
---|
75 | </tr></tbody> |
---|
76 | </table> |
---|
77 | </div> |
---|
78 | <p> |
---|
79 | </p> |
---|
80 | <p>The <a href="recursive_mutex.html" title="Class recursive_mutex">recursive_mutex</a> class uses a |
---|
81 | <a href="../thread/concepts.html#thread.concepts.recursive-locking-strategy" title="Recursive Locking Strategy">Recursive</a> |
---|
82 | locking strategy, so attempts to recursively lock a |
---|
83 | <a href="recursive_mutex.html" title="Class recursive_mutex">recursive_mutex</a> object |
---|
84 | succeed and an internal "lock count" is maintained. |
---|
85 | Attempts to unlock a <a href="recursive_mutex.html" title="Class recursive_mutex">recursive_mutex</a> object |
---|
86 | by threads that don't own a lock on it result in |
---|
87 | <span class="bold"><strong>undefined behavior</strong></span>.</p> |
---|
88 | <p>Like all |
---|
89 | <a href="../thread/concepts.html#thread.concepts.mutex-models" title="Mutex Models">mutex models</a> |
---|
90 | in <span class="bold"><strong>Boost.Thread</strong></span>, <a href="recursive_mutex.html" title="Class recursive_mutex">recursive_mutex</a> leaves the |
---|
91 | <a href="../thread/concepts.html#thread.concepts.sheduling-policies" title="Scheduling Policies">scheduling policy</a> |
---|
92 | as <a href="../thread/concepts.html#thread.concepts.unspecified-scheduling-policy" title="Unspecified Policy">Unspecified</a>. |
---|
93 | Programmers should make no assumptions about the order in which |
---|
94 | waiting threads acquire a lock.</p> |
---|
95 | <div class="refsect2" lang="en"> |
---|
96 | <a name="id1740522"></a><h3> |
---|
97 | <a name="boost.recursive_mutexconstruct-copy-destruct"></a><code class="computeroutput">recursive_mutex</code> construct/copy/destruct</h3> |
---|
98 | <div class="orderedlist"><ol type="1"> |
---|
99 | <li> |
---|
100 | <pre class="literallayout"><a name="id652014-bb"></a>recursive_mutex();</pre> |
---|
101 | <div class="variablelist"><table border="0"> |
---|
102 | <col align="left" valign="top"> |
---|
103 | <tbody> |
---|
104 | <tr> |
---|
105 | <td> |
---|
106 | <span class="term">Effects:</span></td> |
---|
107 | <td>Constructs a <a href="recursive_mutex.html" title="Class recursive_mutex">recursive_mutex</a> object. |
---|
108 | </td> |
---|
109 | </tr> |
---|
110 | <tr> |
---|
111 | <td> |
---|
112 | <span class="term">Postconditions:</span></td> |
---|
113 | <td> |
---|
114 | <code class="computeroutput">*this</code> is in an unlocked state. |
---|
115 | </td> |
---|
116 | </tr> |
---|
117 | </tbody> |
---|
118 | </table></div> |
---|
119 | </li> |
---|
120 | <li> |
---|
121 | <pre class="literallayout"><a name="id1034540-bb"></a>~recursive_mutex();</pre> |
---|
122 | <div class="variablelist"><table border="0"> |
---|
123 | <col align="left" valign="top"> |
---|
124 | <tbody> |
---|
125 | <tr> |
---|
126 | <td> |
---|
127 | <span class="term">Effects:</span></td> |
---|
128 | <td>Destroys a <a href="recursive_mutex.html" title="Class recursive_mutex">recursive_mutex</a> object.</td> |
---|
129 | </tr> |
---|
130 | <tr> |
---|
131 | <td> |
---|
132 | <span class="term">Requires:</span></td> |
---|
133 | <td> |
---|
134 | <code class="computeroutput">*this</code> is in an unlocked state.</td> |
---|
135 | </tr> |
---|
136 | <tr> |
---|
137 | <td> |
---|
138 | <span class="term">Notes:</span></td> |
---|
139 | <td> |
---|
140 | <span class="bold"><strong>Danger:</strong></span> Destruction of a |
---|
141 | locked mutex is a serious programming error resulting in undefined |
---|
142 | behavior such as a program crash.</td> |
---|
143 | </tr> |
---|
144 | </tbody> |
---|
145 | </table></div> |
---|
146 | </li> |
---|
147 | </ol></div> |
---|
148 | </div> |
---|
149 | </div> |
---|
150 | </div> |
---|
151 | <table width="100%"><tr> |
---|
152 | <td align="left"></td> |
---|
153 | <td align="right"><small>Copyright © 2001-2003 William E. Kempf</small></td> |
---|
154 | </tr></table> |
---|
155 | <hr> |
---|
156 | <div class="spirit-nav"> |
---|
157 | <a accesskey="p" href="call_once.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../thread/reference.html#header.boost.thread.recursive_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="recursive_try_mutex.html"><img src="../images/next.png" alt="Next"></a> |
---|
158 | </div> |
---|
159 | </body> |
---|
160 | </html> |
---|