summaryrefslogtreecommitdiff
path: root/doc/html/timed_mutex.html
blob: 5fe4398bfdd1c723c451277c195d79e238b6774e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Class timed_mutex</title>
<link rel="stylesheet" href="boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.68.1">
<link rel="start" href="index.html" title="The Boost C++ Libraries">
<link rel="up" href="threads/reference.html#id868118" title="Header &lt;boost/thread/mutex.hpp&gt;">
<link rel="prev" href="try_mutex.html" title="Class try_mutex">
<link rel="next" href="BOOST_ONCE_INIT.html" title="Macro BOOST_ONCE_INIT">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%">
<td valign="top"><img alt="boost.png (6897 bytes)" width="277" height="86" src="../../boost.png"></td>
<td align="center"><a href="../../index.htm">Home</a></td>
<td align="center"><a href="../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="../../people/people.htm">People</a></td>
<td align="center"><a href="../../more/faq.htm">FAQ</a></td>
<td align="center"><a href="../../more/index.htm">More</a></td>
</table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="try_mutex.html"><img src="images/prev.png" alt="Prev"></a><a accesskey="u" href="threads/reference.html#id868118"><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="BOOST_ONCE_INIT.html"><img src="images/next.png" alt="Next"></a>
</div>
<div class="refentry" lang="en">
<a name="timed_mutex"></a><div class="titlepage"></div>
<div class="refnamediv">
<h2><span class="refentrytitle">Class timed_mutex</span></h2>
<p>boost::timed_mutex &#8212; <p>The <a href="timed_mutex.html" title="Class timed_mutex">timed_mutex</a> class is a model of the 
			<a href="threads/concepts.html#threads.concepts.TimedMutex" title="TimedMutex Concept">TimedMutex</a> concept.</p></p>
</div>
<h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2>
<div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis">
<span class="bold"><strong>class</strong></span> timed_mutex : <span class="bold"><strong>private</strong></span> boost::noncopyable   <span class="emphasis"><em>// Exposition only</em></span>
{
<span class="bold"><strong>public</strong></span>:
  <span class="emphasis"><em>// types</em></span>
  <span class="bold"><strong>typedef</strong></span> <span class="emphasis"><em>implementation-defined</em></span> scoped_lock;      
  <span class="bold"><strong>typedef</strong></span> <span class="emphasis"><em>implementation-defined</em></span> scoped_try_lock;  
  <span class="bold"><strong>typedef</strong></span> <span class="emphasis"><em>implementation-defined</em></span> scoped_timed_lock;

  <span class="emphasis"><em>// <a href="timed_mutex.html#timed_mutexconstruct-copy-destruct">construct/copy/destruct</a></em></span>
  <a href="timed_mutex.html#id1220728-bb">timed_mutex</a>();
  <a href="timed_mutex.html#id1175673-bb">~timed_mutex</a>();
};</pre></div>
<div class="refsect1" lang="en">
<a name="id1559327"></a><h2>Description</h2>
<p>The <a href="timed_mutex.html" title="Class timed_mutex">timed_mutex</a> class is a model of the 
			<a href="threads/concepts.html#threads.concepts.TimedMutex" title="TimedMutex Concept">TimedMutex</a> concept. 
			It should be used to synchronize access to shared resources using
			<a href="threads/concepts.html#threads.concepts.unspecified-locking-strategy" title="Unspecified Locking Strategy">Unspecified</a>
			locking mechanics.</p>
<p>For classes that model related mutex concepts, see 
			<a href="mutex.html" title="Class mutex">mutex</a> and <a href="try_mutex.html" title="Class try_mutex">try_mutex</a>.</p>
<p>For <a href="threads/concepts.html#threads.concepts.recursive-locking-strategy" title="Recursive Locking Strategy">Recursive</a>
			locking mechanics, see <a href="recursive_mutex.html" title="Class recursive_mutex">recursive_mutex</a>,
			<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>
<p>The <a href="timed_mutex.html" title="Class timed_mutex">timed_mutex</a> class supplies the following typedefs,
			which <a href="threads/concepts.html#threads.concepts.lock-models" title="Lock Models">model</a>
			the specified locking strategies:

			</p>
<div class="informaltable"><table class="table">
<colgroup>
<col>
<col>
</colgroup>
<thead><tr>
<th align="left">Lock Name</th>
<th align="left">Lock Concept</th>
</tr></thead>
<tbody>
<tr>
<td align="left">scoped_lock</td>
<td align="left"><a href="threads/concepts.html#threads.concepts.ScopedLock" title="ScopedLock Concept">ScopedLock</a></td>
</tr>
<tr>
<td align="left">scoped_try_lock</td>
<td align="left"><a href="threads/concepts.html#threads.concepts.ScopedTryLock" title="ScopedTryLock Concept">ScopedTryLock</a></td>
</tr>
<tr>
<td align="left">scoped_timed_lock</td>
<td align="left"><a href="threads/concepts.html#threads.concepts.ScopedTimedLock" title="ScopedTimedLock Concept">ScopedTimedLock</a></td>
</tr>
</tbody>
</table></div>
<p>The <a href="timed_mutex.html" title="Class timed_mutex">timed_mutex</a> class uses an 
			<a href="threads/concepts.html#threads.concepts.unspecified-locking-strategy" title="Unspecified Locking Strategy">Unspecified</a>
			locking strategy, so attempts to recursively lock a <a href="timed_mutex.html" title="Class timed_mutex">timed_mutex</a>
			object or attempts to unlock one by threads that don't own a lock on it result in
			<span class="bold"><strong>undefined behavior</strong></span>.
			This strategy allows implementations to be as efficient as possible
			on any given platform. It is, however, recommended that
			implementations include debugging support to detect misuse when
			<code class="computeroutput">NDEBUG</code> is not defined.</p>
<p>Like all 
			<a href="threads/concepts.html#threads.concepts.mutex-models" title="Mutex Models">mutex models</a>
			in  , <a href="timed_mutex.html" title="Class timed_mutex">timed_mutex</a> leaves the 
			<a href="threads/concepts.html#threads.concepts.sheduling-policies" title="Scheduling Policies">scheduling policy</a>
			as <a href="threads/concepts.html#threads.concepts.unspecified-scheduling-policy" title="Unspecified Policy">Unspecified</a>. 
			Programmers should make no assumptions about the order in which
			waiting threads acquire a lock.</p>
<div class="refsect2" lang="en">
<a name="id1559550"></a><h3>
<a name="timed_mutexconstruct-copy-destruct"></a><code class="computeroutput">timed_mutex</code> construct/copy/destruct</h3>
<div class="orderedlist"><ol type="1">
<li>
<pre class="literallayout"><a name="id1220728-bb"></a>timed_mutex();</pre>
<p><b xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"><span class="term">Effects</span></b>:

    Constructs a <a href="timed_mutex.html" title="Class timed_mutex">timed_mutex</a> object.
			<br><b xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"><span class="term">Postconditions</span></b>:

    <code class="computeroutput">*this</code> is in an unlocked state.
			</p>
</li>
<li>
<pre class="literallayout"><a name="id1175673-bb"></a>~timed_mutex();</pre>
<p><b xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"><span class="term">Effects</span></b>:

    Destroys a <a href="timed_mutex.html" title="Class timed_mutex">timed_mutex</a> object.<br><b xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"><span class="term">Requires</span></b>:

    <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>:

    <span class="bold"><strong>Danger:</strong></span> Destruction of a
			locked mutex is a serious programming error resulting in undefined
			behavior such as a program crash.</p>
</li>
</ol></div>
</div>
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><small>Copyright © 2001-2003 William E. Kempf</small></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="try_mutex.html"><img src="images/prev.png" alt="Prev"></a><a accesskey="u" href="threads/reference.html#id868118"><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="BOOST_ONCE_INIT.html"><img src="images/next.png" alt="Next"></a>
</div>
</body>
</html>