Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_33_1/doc/html/try_read_write_mutex.html @ 12

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

added boost

File size: 11.2 KB
Line 
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
4<title>Class try_read_write_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">
8<link rel="up" href="threads/reference.html#id693680" title="Header &lt;boost/thread/read_write_mutex.hpp&gt;">
9<link rel="prev" href="read_write_mutex.html" title="Class read_write_mutex">
10<link rel="next" href="timed_read_write_mutex.html" title="Class timed_read_write_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="read_write_mutex.html"><img src="images/prev.png" alt="Prev"></a><a accesskey="u" href="threads/reference.html#id693680"><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_read_write_mutex.html"><img src="images/next.png" alt="Next"></a>
24</div>
25<div class="refentry" lang="en">
26<a name="try_read_write_mutex"></a><div class="titlepage"></div>
27<div class="refnamediv">
28<h2><span class="refentrytitle">Class try_read_write_mutex</span></h2>
29<p>boost::try_read_write_mutex &#8212; <p>The <a href="try_read_write_mutex.html" title="Class try_read_write_mutex">try_read_write_mutex</a> class is a model of the
30                        <a href="threads/concepts.html#threads.concepts.TryReadWriteMutex" title="TryReadWriteMutex Concept">TryReadWriteMutex</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_read_write_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_read_write_lock;    
39  <span class="bold"><strong>typedef</strong></span> <span class="emphasis"><em>implementation-defined</em></span> scoped_try_read_write_lock;
40  <span class="bold"><strong>typedef</strong></span> <span class="emphasis"><em>implementation-defined</em></span> scoped_read_lock;          
41  <span class="bold"><strong>typedef</strong></span> <span class="emphasis"><em>implementation-defined</em></span> scoped_try_read_lock;      
42  <span class="bold"><strong>typedef</strong></span> <span class="emphasis"><em>implementation-defined</em></span> scoped_write_lock;         
43  <span class="bold"><strong>typedef</strong></span> <span class="emphasis"><em>implementation-defined</em></span> scoped_try_write_lock;     
44
45  <span class="emphasis"><em>// <a href="try_read_write_mutex.html#try_read_write_mutexconstruct-copy-destruct">construct/copy/destruct</a></em></span>
46  <a href="try_read_write_mutex.html#id1184940-bb">try_read_write_mutex</a>(boost::read_write_scheduling_policy);
47  <a href="try_read_write_mutex.html#id1150477-bb">~try_read_write_mutex</a>();
48};</pre></div>
49<div class="refsect1" lang="en">
50<a name="id1562104"></a><h2>Description</h2>
51<p>The <a href="try_read_write_mutex.html" title="Class try_read_write_mutex">try_read_write_mutex</a> class is a model of the
52                        <a href="threads/concepts.html#threads.concepts.TryReadWriteMutex" title="TryReadWriteMutex Concept">TryReadWriteMutex</a> concept.
53                        It should be used to synchronize access to shared resources using
54                        <a href="threads/concepts.html#threads.concepts.read-write-locking-strategies.unspecified" title="Unspecified Locking Strategy">Unspecified</a>
55                        locking mechanics.</p>
56<p>For classes that model related mutex concepts, see
57                        <a href="read_write_mutex.html" title="Class read_write_mutex">read_write_mutex</a> and <a href="timed_read_write_mutex.html" title="Class timed_read_write_mutex">timed_read_write_mutex</a>.</p>
58<p>The <a href="try_read_write_mutex.html" title="Class try_read_write_mutex">try_read_write_mutex</a> class supplies the following typedefs,
59                        which <a href="threads/concepts.html#threads.concepts.read-write-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_read_write_lock</td>
75<td align="left"><a href="threads/concepts.html#threads.concepts.ScopedReadWriteLock" title="ScopedReadWriteLock Concept">ScopedReadWriteLock</a></td>
76</tr>
77<tr>
78<td align="left">scoped_try_read_write_lock</td>
79<td align="left"><a href="threads/concepts.html#threads.concepts.ScopedTryReadWriteLock" title="ScopedTryReadWriteLock Expressions">ScopedTryReadWriteLock</a></td>
80</tr>
81<tr>
82<td align="left">scoped_read_lock</td>
83<td align="left"><a href="threads/concepts.html#threads.concepts.ScopedLock" title="ScopedLock Concept">ScopedLock</a></td>
84</tr>
85<tr>
86<td align="left">scoped_try_read_lock</td>
87<td align="left"><a href="threads/concepts.html#threads.concepts.ScopedTryLock" title="ScopedTryLock Concept">ScopedTryLock</a></td>
88</tr>
89<tr>
90<td align="left">scoped_write_lock</td>
91<td align="left"><a href="threads/concepts.html#threads.concepts.ScopedLock" title="ScopedLock Concept">ScopedLock</a></td>
92</tr>
93<tr>
94<td align="left">scoped_try_write_lock</td>
95<td align="left"><a href="threads/concepts.html#threads.concepts.ScopedTryLock" title="ScopedTryLock Concept">ScopedTryLock</a></td>
96</tr>
97</tbody>
98</table></div>
99<p>The <a href="try_read_write_mutex.html" title="Class try_read_write_mutex">try_read_write_mutex</a> class uses an
100                        <a href="threads/concepts.html#threads.concepts.read-write-locking-strategies.unspecified" title="Unspecified Locking Strategy">Unspecified</a>
101                        locking strategy, so attempts to recursively lock a <a href="try_read_write_mutex.html" title="Class try_read_write_mutex">try_read_write_mutex</a>
102                        object or attempts to unlock one by threads that don't own a lock on it result in
103                        <span class="bold"><strong>undefined behavior</strong></span>.
104                        This strategy allows implementations to be as efficient as possible
105                        on any given platform. It is, however, recommended that
106                        implementations include debugging support to detect misuse when
107                        <code class="computeroutput">NDEBUG</code> is not defined.</p>
108<p>Like all
109                        <a href="threads/concepts.html#threads.concepts.read-write-mutex-models" title="Mutex Models">read/write mutex models</a>
110                        in , <a href="try_read_write_mutex.html" title="Class try_read_write_mutex">try_read_write_mutex</a> has two types of
111                        <a href="threads/concepts.html#threads.concepts.read-write-scheduling-policies" title="Scheduling Policies">scheduling policies</a>, an
112                        <a href="threads/concepts.html#threads.concepts.read-write-scheduling-policies.inter-class" title="Inter-Class Scheduling Policies">inter-class sheduling policy</a>
113                        between threads trying to obtain different types of locks and an
114                        <a href="threads/concepts.html#threads.concepts.read-write-scheduling-policies.intra-class" title="Intra-Class Scheduling Policies">intra-class sheduling policy</a>
115                        between threads trying to obtain the same type of lock.
116                        The <a href="try_read_write_mutex.html" title="Class try_read_write_mutex">try_read_write_mutex</a> class allows the
117                        programmer to choose what
118                        <a href="threads/concepts.html#threads.concepts.read-write-scheduling-policies.inter-class" title="Inter-Class Scheduling Policies">inter-class sheduling policy</a>
119                        will be used; however, like all read/write mutex models,
120                        <a href="try_read_write_mutex.html" title="Class try_read_write_mutex">try_read_write_mutex</a> leaves the
121                        <a href="threads/concepts.html#threads.concepts.read-write-scheduling-policies.intra-class" title="Intra-Class Scheduling Policies">intra-class sheduling policy</a> as
122                        <a href="threads/concepts.html#threads.concepts.unspecified-scheduling-policy" title="Unspecified Policy">Unspecified</a>.                     
123                        </p>
124<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
125<h3 class="title">Note</h3>Self-deadlock is virtually guaranteed if a thread tries to
126                        lock the same <a href="try_read_write_mutex.html" title="Class try_read_write_mutex">try_read_write_mutex</a> multiple times
127                        unless all locks are read-locks (but see below)</div>
128<div class="refsect2" lang="en">
129<a name="id1562402"></a><h3>
130<a name="try_read_write_mutexconstruct-copy-destruct"></a><code class="computeroutput">try_read_write_mutex</code> construct/copy/destruct</h3>
131<div class="orderedlist"><ol type="1">
132<li>
133<pre class="literallayout"><a name="id1184940-bb"></a>try_read_write_mutex(boost::read_write_scheduling_policy count);</pre>
134<p><b xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"><span class="term">Effects</span></b>:
135
136    Constructs a <a href="try_read_write_mutex.html" title="Class try_read_write_mutex">try_read_write_mutex</a> object.
137                        <br><b xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"><span class="term">Postconditions</span></b>:
138
139    <code class="computeroutput">*this</code> is in an unlocked state.
140                        </p>
141</li>
142<li>
143<pre class="literallayout"><a name="id1150477-bb"></a>~try_read_write_mutex();</pre>
144<p><b xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"><span class="term">Effects</span></b>:
145
146    Destroys a <a href="try_read_write_mutex.html" title="Class try_read_write_mutex">try_read_write_mutex</a> object.<br><b xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"><span class="term">Requires</span></b>:
147
148    <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>:
149
150    <span class="bold"><strong>Danger:</strong></span> Destruction of a
151                        locked mutex is a serious programming error resulting in undefined
152                        behavior such as a program crash.</p>
153</li>
154</ol></div>
155</div>
156</div>
157</div>
158<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" 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="read_write_mutex.html"><img src="images/prev.png" alt="Prev"></a><a accesskey="u" href="threads/reference.html#id693680"><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_read_write_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.