Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/doc/html/boost/try_mutex.html @ 29

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

updated boost from 1_33_1 to 1_34_1

File size: 8.2 KB
Line 
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
4<title>Class try_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="mutex.html" title="Class mutex">
10<link rel="next" href="timed_mutex.html" title="Class 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 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="mutex.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="timed_mutex.html"><img src="../images/next.png" alt="Next"></a>
24</div>
25<div class="refentry" lang="en">
26<a name="boost.try_mutex"></a><div class="titlepage"></div>
27<div class="refnamediv">
28<h2><span class="refentrytitle">Class try_mutex</span></h2>
29<p>boost::try_mutex &#8212; <p>The <a href="try_mutex.html" title="Class try_mutex">try_mutex</a> class is a model of the
30                        <a href="../thread/concepts.html#thread.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> 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="try_mutex.html#boost.try_mutexconstruct-copy-destruct">construct/copy/destruct</a></em></span>
42  <a href="try_mutex.html#id1258000-bb">try_mutex</a>();
43  <a href="try_mutex.html#id1280837-bb">~try_mutex</a>();
44};</pre></div>
45<div class="refsect1" lang="en">
46<a name="id1738984"></a><h2>Description</h2>
47<p>The <a href="try_mutex.html" title="Class try_mutex">try_mutex</a> class is a model of the
48                        <a href="../thread/concepts.html#thread.concepts.TryMutex" title="TryMutex Concept">TryMutex</a> concept.
49                        It should be used to synchronize access to shared resources using
50                        <a href="../thread/concepts.html#thread.concepts.unspecified-locking-strategy" title="Unspecified Locking Strategy">Unspecified</a>
51                        locking mechanics.</p>
52<p>For classes that model related mutex concepts, see
53                        <a href="mutex.html" title="Class mutex">mutex</a> and <a href="timed_mutex.html" title="Class timed_mutex">timed_mutex</a>.</p>
54<p>For <a href="../thread/concepts.html#thread.concepts.recursive-locking-strategy" title="Recursive Locking Strategy">Recursive</a>
55                        locking mechanics, see <a href="recursive_mutex.html" title="Class recursive_mutex">recursive_mutex</a>,
56                        <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>.
57                        </p>
58<p>The <a href="try_mutex.html" title="Class try_mutex">try_mutex</a> class supplies the following typedefs,
59                        which <a href="../thread/concepts.html#thread.concepts.lock-models" title="Lock Models">model</a>
60                        the specified locking strategies:
61
62                        </p>
63<div class="informaltable"><table class="table">
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>
73<tr>
74<td align="left">scoped_lock</td>
75<td align="left"><a href="../thread/concepts.html#thread.concepts.ScopedLock" title="ScopedLock Concept">ScopedLock</a></td>
76</tr>
77<tr>
78<td align="left">scoped_try_lock</td>
79<td align="left"><a href="../thread/concepts.html#thread.concepts.ScopedTryLock" title="ScopedTryLock Concept">ScopedTryLock</a></td>
80</tr>
81</tbody>
82</table></div>
83<p>
84                        </p>
85<p>The <a href="try_mutex.html" title="Class try_mutex">try_mutex</a> class uses an
86                        <a href="../thread/concepts.html#thread.concepts.unspecified-locking-strategy" title="Unspecified Locking Strategy">Unspecified</a>
87                        locking strategy, so attempts to recursively lock a <a href="try_mutex.html" title="Class try_mutex">try_mutex</a>
88                        object or attempts to unlock one by threads that don't own a lock on it result in
89                        <span class="bold"><strong>undefined behavior</strong></span>.
90                        This strategy allows implementations to be as efficient as possible
91                        on any given platform. It is, however, recommended that
92                        implementations include debugging support to detect misuse when
93                        <code class="computeroutput">NDEBUG</code> is not defined.</p>
94<p>Like all
95                        <a href="../thread/concepts.html#thread.concepts.mutex-models" title="Mutex Models">mutex models</a>
96                        in <span class="bold"><strong>Boost.Thread</strong></span>, <a href="try_mutex.html" title="Class try_mutex">try_mutex</a> leaves the
97                        <a href="../thread/concepts.html#thread.concepts.sheduling-policies" title="Scheduling Policies">scheduling policy</a>
98                        as <a href="../thread/concepts.html#thread.concepts.unspecified-scheduling-policy" title="Unspecified Policy">Unspecified</a>.
99                        Programmers should make no assumptions about the order in which
100                        waiting threads acquire a lock.</p>
101<div class="refsect2" lang="en">
102<a name="id1739231"></a><h3>
103<a name="boost.try_mutexconstruct-copy-destruct"></a><code class="computeroutput">try_mutex</code> construct/copy/destruct</h3>
104<div class="orderedlist"><ol type="1">
105<li>
106<pre class="literallayout"><a name="id1258000-bb"></a>try_mutex();</pre>
107<div class="variablelist"><table border="0">
108<col align="left" valign="top">
109<tbody>
110<tr>
111<td>
112<span class="term">Effects:</span></td>
113<td>Constructs a <a href="try_mutex.html" title="Class try_mutex">try_mutex</a> object.
114                        </td>
115</tr>
116<tr>
117<td>
118<span class="term">Postconditions:</span></td>
119<td>
120<code class="computeroutput">*this</code> is in an unlocked state.
121                        </td>
122</tr>
123</tbody>
124</table></div>
125</li>
126<li>
127<pre class="literallayout"><a name="id1280837-bb"></a>~try_mutex();</pre>
128<div class="variablelist"><table border="0">
129<col align="left" valign="top">
130<tbody>
131<tr>
132<td>
133<span class="term">Effects:</span></td>
134<td>Destroys a <a href="try_mutex.html" title="Class try_mutex">try_mutex</a> object.
135                        </td>
136</tr>
137<tr>
138<td>
139<span class="term">Requires:</span></td>
140<td>
141<code class="computeroutput">*this</code> is in an unlocked state.</td>
142</tr>
143<tr>
144<td>
145<span class="term">Notes:</span></td>
146<td>
147<span class="bold"><strong>Danger:</strong></span> Destruction of a
148                        locked mutex is a serious programming error resulting in undefined
149                        behavior such as a program crash.</td>
150</tr>
151</tbody>
152</table></div>
153</li>
154</ol></div>
155</div>
156</div>
157</div>
158<table width="100%"><tr>
159<td align="left"></td>
160<td align="right"><small>Copyright © 2001-2003 William E. Kempf</small></td>
161</tr></table>
162<hr>
163<div class="spirit-nav">
164<a accesskey="p" href="mutex.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="timed_mutex.html"><img src="../images/next.png" alt="Next"></a>
165</div>
166</body>
167</html>
Note: See TracBrowser for help on using the repository browser.