| [12] | 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.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="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.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="call_once.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_try_mutex.html"><img src="images/next.png" alt="Next"></a> |
|---|
| 24 | </div> |
|---|
| 25 | <div class="refentry" lang="en"> |
|---|
| 26 | <a name="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="threads/concepts.html#threads.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#recursive_mutexconstruct-copy-destruct">construct/copy/destruct</a></em></span> |
|---|
| 41 | <a href="recursive_mutex.html#id2596976-bb">recursive_mutex</a>(); |
|---|
| 42 | <a href="recursive_mutex.html#id2575603-bb">~recursive_mutex</a>(); |
|---|
| 43 | };</pre></div> |
|---|
| 44 | <div class="refsect1" lang="en"> |
|---|
| 45 | <a name="id2782436"></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="threads/concepts.html#threads.concepts.Mutex" title="Mutex Concept">Mutex</a> concept. |
|---|
| 48 | It should be used to synchronize access to shared resources using |
|---|
| 49 | <a href="threads/concepts.html#threads.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="threads/concepts.html#threads.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="id2782528"></a><p class="title"><b>Table 12.12. 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="threads/concepts.html#threads.concepts.ScopedLock" title="ScopedLock Concept">ScopedLock</a></td> |
|---|
| 75 | </tr></tbody> |
|---|
| 76 | </table> |
|---|
| 77 | </div> |
|---|
| 78 | <p>The <a href="recursive_mutex.html" title="Class recursive_mutex">recursive_mutex</a> class uses a |
|---|
| 79 | <a href="threads/concepts.html#threads.concepts.recursive-locking-strategy" title="Recursive Locking Strategy">Recursive</a> |
|---|
| 80 | locking strategy, so attempts to recursively lock a |
|---|
| 81 | <a href="recursive_mutex.html" title="Class recursive_mutex">recursive_mutex</a> object |
|---|
| 82 | succeed and an internal "lock count" is maintained. |
|---|
| 83 | Attempts to unlock a <a href="recursive_mutex.html" title="Class recursive_mutex">recursive_mutex</a> object |
|---|
| 84 | by threads that don't own a lock on it result in |
|---|
| 85 | <span class="bold"><strong>undefined behavior</strong></span>.</p> |
|---|
| 86 | <p>Like all |
|---|
| 87 | <a href="threads/concepts.html#threads.concepts.mutex-models" title="Mutex Models">mutex models</a> |
|---|
| 88 | in <span class="bold"><strong>Boost.Threads</strong></span>, <a href="recursive_mutex.html" title="Class recursive_mutex">recursive_mutex</a> leaves the |
|---|
| 89 | <a href="threads/concepts.html#threads.concepts.sheduling-policies" title="Scheduling Policies">scheduling policy</a> |
|---|
| 90 | as <a href="threads/concepts.html#threads.concepts.unspecified-scheduling-policy" title="Unspecified Policy">Unspecified</a>. |
|---|
| 91 | Programmers should make no assumptions about the order in which |
|---|
| 92 | waiting threads acquire a lock.</p> |
|---|
| 93 | <div class="refsect2" lang="en"> |
|---|
| 94 | <a name="id2782641"></a><h3> |
|---|
| 95 | <a name="recursive_mutexconstruct-copy-destruct"></a><code class="computeroutput">recursive_mutex</code> construct/copy/destruct</h3> |
|---|
| 96 | <div class="orderedlist"><ol type="1"> |
|---|
| 97 | <li> |
|---|
| 98 | <pre class="literallayout"><a name="id2596976-bb"></a>recursive_mutex();</pre> |
|---|
| 99 | <p><b xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"><span class="term">Effects</span></b>: |
|---|
| 100 | |
|---|
| 101 | Constructs a <a href="recursive_mutex.html" title="Class recursive_mutex">recursive_mutex</a> object. |
|---|
| 102 | <br><b xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"><span class="term">Postconditions</span></b>: |
|---|
| 103 | |
|---|
| 104 | <code class="computeroutput">*this</code> is in an unlocked state. |
|---|
| 105 | </p> |
|---|
| 106 | </li> |
|---|
| 107 | <li> |
|---|
| 108 | <pre class="literallayout"><a name="id2575603-bb"></a>~recursive_mutex();</pre> |
|---|
| 109 | <p><b xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"><span class="term">Effects</span></b>: |
|---|
| 110 | |
|---|
| 111 | Destroys a <a href="recursive_mutex.html" title="Class recursive_mutex">recursive_mutex</a> object.<br><b xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"><span class="term">Requires</span></b>: |
|---|
| 112 | |
|---|
| 113 | <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>: |
|---|
| 114 | |
|---|
| 115 | <span class="bold"><strong>Danger:</strong></span> Destruction of a |
|---|
| 116 | locked mutex is a serious programming error resulting in undefined |
|---|
| 117 | behavior such as a program crash.</p> |
|---|
| 118 | </li> |
|---|
| 119 | </ol></div> |
|---|
| 120 | </div> |
|---|
| 121 | </div> |
|---|
| 122 | </div> |
|---|
| 123 | <table width="100%"><tr> |
|---|
| 124 | <td align="left"></td> |
|---|
| 125 | <td align="right"><small>Copyright © 2001-2003 William E. Kempf</small></td> |
|---|
| 126 | </tr></table> |
|---|
| 127 | <hr> |
|---|
| 128 | <div class="spirit-nav"> |
|---|
| 129 | <a accesskey="p" href="call_once.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_try_mutex.html"><img src="images/next.png" alt="Next"></a> |
|---|
| 130 | </div> |
|---|
| 131 | </body> |
|---|
| 132 | </html> |
|---|