1 | <html> |
---|
2 | <head> |
---|
3 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> |
---|
4 | <title>Class recursive_try_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#id2436754" title="Header <boost/thread/recursive_mutex.hpp>"> |
---|
9 | <link rel="prev" href="recursive_mutex.html" title="Class recursive_mutex"> |
---|
10 | <link rel="next" href="recursive_timed_mutex.html" title="Class recursive_timed_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="recursive_mutex.html"><img src="images/prev.png" alt="Prev"></a><a accesskey="u" href="threads/reference.html#id2436754"><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_timed_mutex.html"><img src="images/next.png" alt="Next"></a> |
---|
24 | </div> |
---|
25 | <div class="refentry" lang="en"> |
---|
26 | <a name="recursive_try_mutex"></a><div class="titlepage"></div> |
---|
27 | <div class="refnamediv"> |
---|
28 | <h2><span class="refentrytitle">Class recursive_try_mutex</span></h2> |
---|
29 | <p>boost::recursive_try_mutex — <p>The <a href="recursive_try_mutex.html" title="Class recursive_try_mutex">recursive_try_mutex</a> class is a model of the |
---|
30 | <a href="threads/concepts.html#threads.concepts.TryMutex" title="TryMutex Concept">TryMutex</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_try_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 | <span class="bold"><strong>typedef</strong></span> <span class="emphasis"><em>implementation-defined</em></span> scoped_try_lock; |
---|
40 | |
---|
41 | <span class="emphasis"><em>// <a href="recursive_try_mutex.html#recursive_try_mutexconstruct-copy-destruct">construct/copy/destruct</a></em></span> |
---|
42 | <a href="recursive_try_mutex.html#id2537565-bb">recursive_try_mutex</a>(); |
---|
43 | <a href="recursive_try_mutex.html#id2613724-bb">~recursive_try_mutex</a>(); |
---|
44 | };</pre></div> |
---|
45 | <div class="refsect1" lang="en"> |
---|
46 | <a name="id2782868"></a><h2>Description</h2> |
---|
47 | <p>The <a href="recursive_try_mutex.html" title="Class recursive_try_mutex">recursive_try_mutex</a> class is a model of the |
---|
48 | <a href="threads/concepts.html#threads.concepts.TryMutex" title="TryMutex Concept">TryMutex</a> concept. |
---|
49 | It should be used to synchronize access to shared resources using |
---|
50 | <a href="threads/concepts.html#threads.concepts.recursive-locking-strategy" title="Recursive Locking Strategy">Recursive</a> |
---|
51 | locking mechanics.</p> |
---|
52 | <p>For classes that model related mutex concepts, see |
---|
53 | <a href="recursive_mutex.html" title="Class recursive_mutex">recursive_mutex</a> and <a href="recursive_timed_mutex.html" title="Class recursive_timed_mutex">recursive_timed_mutex</a>.</p> |
---|
54 | <p>For <a href="threads/concepts.html#threads.concepts.unspecified-locking-strategy" title="Unspecified Locking Strategy">Unspecified</a> |
---|
55 | locking mechanics, see <a href="mutex.html" title="Class mutex">mutex</a>, |
---|
56 | <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>. |
---|
57 | </p> |
---|
58 | <p>The <a href="recursive_try_mutex.html" title="Class recursive_try_mutex">recursive_try_mutex</a> class supplies the following typedefs, |
---|
59 | which model the specified locking strategies: |
---|
60 | |
---|
61 | </p> |
---|
62 | <div class="table"> |
---|
63 | <a name="id2782959"></a><p class="title"><b>Table 12.13. Supported Lock Types</b></p> |
---|
64 | <table class="table" summary="Supported Lock Types"> |
---|
65 | <colgroup> |
---|
66 | <col> |
---|
67 | <col> |
---|
68 | </colgroup> |
---|
69 | <thead><tr> |
---|
70 | <th align="left">Lock Name</th> |
---|
71 | <th align="left">Lock Concept</th> |
---|
72 | </tr></thead> |
---|
73 | <tbody> |
---|
74 | <tr> |
---|
75 | <td align="left">scoped_lock</td> |
---|
76 | <td align="left"><a href="threads/concepts.html#threads.concepts.ScopedLock" title="ScopedLock Concept">ScopedLock</a></td> |
---|
77 | </tr> |
---|
78 | <tr> |
---|
79 | <td align="left">scoped_try_lock</td> |
---|
80 | <td align="left"><a href="threads/concepts.html#threads.concepts.ScopedTryLock" title="ScopedTryLock Concept">ScopedTryLock</a></td> |
---|
81 | </tr> |
---|
82 | </tbody> |
---|
83 | </table> |
---|
84 | </div> |
---|
85 | <p>The <a href="recursive_try_mutex.html" title="Class recursive_try_mutex">recursive_try_mutex</a> class uses a |
---|
86 | <a href="threads/concepts.html#threads.concepts.recursive-locking-strategy" title="Recursive Locking Strategy">Recursive</a> |
---|
87 | locking strategy, so attempts to recursively lock a |
---|
88 | <a href="recursive_try_mutex.html" title="Class recursive_try_mutex">recursive_try_mutex</a> object |
---|
89 | succeed and an internal "lock count" is maintained. |
---|
90 | Attempts to unlock a <a href="recursive_mutex.html" title="Class recursive_mutex">recursive_mutex</a> object |
---|
91 | by threads that don't own a lock on it result in |
---|
92 | <span class="bold"><strong>undefined behavior</strong></span>.</p> |
---|
93 | <p>Like all |
---|
94 | <a href="threads/concepts.html#threads.concepts.mutex-models" title="Mutex Models">mutex models</a> |
---|
95 | in <span class="bold"><strong>Boost.Threads</strong></span>, <a href="recursive_try_mutex.html" title="Class recursive_try_mutex">recursive_try_mutex</a> leaves the |
---|
96 | <a href="threads/concepts.html#threads.concepts.sheduling-policies" title="Scheduling Policies">scheduling policy</a> |
---|
97 | as <a href="threads/concepts.html#threads.concepts.unspecified-scheduling-policy" title="Unspecified Policy">Unspecified</a>. |
---|
98 | Programmers should make no assumptions about the order in which |
---|
99 | waiting threads acquire a lock.</p> |
---|
100 | <div class="refsect2" lang="en"> |
---|
101 | <a name="id2783084"></a><h3> |
---|
102 | <a name="recursive_try_mutexconstruct-copy-destruct"></a><code class="computeroutput">recursive_try_mutex</code> construct/copy/destruct</h3> |
---|
103 | <div class="orderedlist"><ol type="1"> |
---|
104 | <li> |
---|
105 | <pre class="literallayout"><a name="id2537565-bb"></a>recursive_try_mutex();</pre> |
---|
106 | <p><b xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"><span class="term">Effects</span></b>: |
---|
107 | |
---|
108 | Constructs a <a href="recursive_try_mutex.html" title="Class recursive_try_mutex">recursive_try_mutex</a> object. |
---|
109 | <br><b xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"><span class="term">Postconditions</span></b>: |
---|
110 | |
---|
111 | <code class="computeroutput">*this</code> is in an unlocked state. |
---|
112 | </p> |
---|
113 | </li> |
---|
114 | <li> |
---|
115 | <pre class="literallayout"><a name="id2613724-bb"></a>~recursive_try_mutex();</pre> |
---|
116 | <p><b xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"><span class="term">Effects</span></b>: |
---|
117 | |
---|
118 | Destroys a <a href="recursive_try_mutex.html" title="Class recursive_try_mutex">recursive_try_mutex</a> object. |
---|
119 | <br><b xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"><span class="term">Requires</span></b>: |
---|
120 | |
---|
121 | <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>: |
---|
122 | |
---|
123 | <span class="bold"><strong>Danger:</strong></span> Destruction of a |
---|
124 | locked mutex is a serious programming error resulting in undefined |
---|
125 | behavior such as a program crash.</p> |
---|
126 | </li> |
---|
127 | </ol></div> |
---|
128 | </div> |
---|
129 | </div> |
---|
130 | </div> |
---|
131 | <table width="100%"><tr> |
---|
132 | <td align="left"></td> |
---|
133 | <td align="right"><small>Copyright © 2001-2003 William E. Kempf</small></td> |
---|
134 | </tr></table> |
---|
135 | <hr> |
---|
136 | <div class="spirit-nav"> |
---|
137 | <a accesskey="p" href="recursive_mutex.html"><img src="images/prev.png" alt="Prev"></a><a accesskey="u" href="threads/reference.html#id2436754"><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_timed_mutex.html"><img src="images/next.png" alt="Next"></a> |
---|
138 | </div> |
---|
139 | </body> |
---|
140 | </html> |
---|