Imported Upstream version 1.72.0
[platform/upstream/boost.git] / doc / html / boost / interprocess / upgradable_lock.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2 <html>
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
5 <title>Class template upgradable_lock</title>
6 <link rel="stylesheet" href="../../../../doc/src/boostbook.css" type="text/css">
7 <meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
8 <link rel="home" href="../../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset">
9 <link rel="up" href="../../interprocess/indexes_reference.html#header.boost.interprocess.sync.upgradable_lock_hpp" title="Header &lt;boost/interprocess/sync/upgradable_lock.hpp&gt;">
10 <link rel="prev" href="sharable_lock.html" title="Class template sharable_lock">
11 <link rel="next" href="windows_shared_memory.html" title="Class windows_shared_memory">
12 </head>
13 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
14 <table cellpadding="2" width="100%"><tr>
15 <td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../boost.png"></td>
16 <td align="center"><a href="../../../../index.html">Home</a></td>
17 <td align="center"><a href="../../../../libs/libraries.htm">Libraries</a></td>
18 <td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
19 <td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
20 <td align="center"><a href="../../../../more/index.htm">More</a></td>
21 </tr></table>
22 <hr>
23 <div class="spirit-nav">
24 <a accesskey="p" href="sharable_lock.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../interprocess/indexes_reference.html#header.boost.interprocess.sync.upgradable_lock_hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="windows_shared_memory.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
25 </div>
26 <div class="refentry">
27 <a name="boost.interprocess.upgradable_lock"></a><div class="titlepage"></div>
28 <div class="refnamediv">
29 <h2><span class="refentrytitle">Class template upgradable_lock</span></h2>
30 <p>boost::interprocess::upgradable_lock</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"><span class="comment">// In header: &lt;<a class="link" href="../../interprocess/indexes_reference.html#header.boost.interprocess.sync.upgradable_lock_hpp" title="Header &lt;boost/interprocess/sync/upgradable_lock.hpp&gt;">boost/interprocess/sync/upgradable_lock.hpp</a>&gt;
34
35 </span><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> UpgradableMutex<span class="special">&gt;</span> 
36 <span class="keyword">class</span> <a class="link" href="upgradable_lock.html" title="Class template upgradable_lock">upgradable_lock</a> <span class="special">{</span>
37 <span class="keyword">public</span><span class="special">:</span>
38   <span class="comment">// types</span>
39   <span class="keyword">typedef</span> <span class="identifier">UpgradableMutex</span> <a name="boost.interprocess.upgradable_lock.mutex_type"></a><span class="identifier">mutex_type</span><span class="special">;</span>
40
41   <span class="comment">// <a class="link" href="upgradable_lock.html#boost.interprocess.upgradable_lockconstruct-copy-destruct">construct/copy/destruct</a></span>
42   <a class="link" href="upgradable_lock.html#idm45336639928112-bb"><span class="identifier">upgradable_lock</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>
43   <span class="keyword">explicit</span> <a class="link" href="upgradable_lock.html#idm45336639926624-bb"><span class="identifier">upgradable_lock</span></a><span class="special">(</span><span class="identifier">mutex_type</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
44   <a class="link" href="upgradable_lock.html#idm45336639925376-bb"><span class="identifier">upgradable_lock</span></a><span class="special">(</span><span class="identifier">mutex_type</span> <span class="special">&amp;</span><span class="special">,</span> <a class="link" href="defer_lock_type.html" title="Struct defer_lock_type">defer_lock_type</a><span class="special">)</span><span class="special">;</span>
45   <a class="link" href="upgradable_lock.html#idm45336639923024-bb"><span class="identifier">upgradable_lock</span></a><span class="special">(</span><span class="identifier">mutex_type</span> <span class="special">&amp;</span><span class="special">,</span> <a class="link" href="accept_ownership_type.html" title="Struct accept_ownership_type">accept_ownership_type</a><span class="special">)</span><span class="special">;</span>
46   <a class="link" href="upgradable_lock.html#idm45336639920640-bb"><span class="identifier">upgradable_lock</span></a><span class="special">(</span><span class="identifier">mutex_type</span> <span class="special">&amp;</span><span class="special">,</span> <a class="link" href="try_to_lock_type.html" title="Struct try_to_lock_type">try_to_lock_type</a><span class="special">)</span><span class="special">;</span>
47   <a class="link" href="upgradable_lock.html#idm45336639917968-bb"><span class="identifier">upgradable_lock</span></a><span class="special">(</span><span class="identifier">mutex_type</span> <span class="special">&amp;</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">posix_time</span><span class="special">::</span><span class="identifier">ptime</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
48   <a class="link" href="upgradable_lock.html#idm45336639915376-bb"><span class="identifier">upgradable_lock</span></a><span class="special">(</span><a class="link" href="upgradable_lock.html" title="Class template upgradable_lock">upgradable_lock</a><span class="special">&lt;</span> <span class="identifier">mutex_type</span> <span class="special">&gt;</span> <span class="special">&amp;&amp;</span><span class="special">)</span><span class="special">;</span>
49   <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> T<span class="special">&gt;</span> <a class="link" href="upgradable_lock.html#idm45336639910272-bb"><span class="identifier">upgradable_lock</span></a><span class="special">(</span><a class="link" href="scoped_lock.html" title="Class template scoped_lock">scoped_lock</a><span class="special">&lt;</span> <span class="identifier">T</span> <span class="special">&gt;</span> <span class="special">&amp;&amp;</span><span class="special">,</span> <span class="emphasis"><em><span class="identifier">unspecified</span></em></span> <span class="special">=</span> <span class="number">0</span><span class="special">)</span><span class="special">;</span>
50   <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> T<span class="special">&gt;</span> 
51     <a class="link" href="upgradable_lock.html#idm45336639904000-bb"><span class="identifier">upgradable_lock</span></a><span class="special">(</span><a class="link" href="sharable_lock.html" title="Class template sharable_lock">sharable_lock</a><span class="special">&lt;</span> <span class="identifier">T</span> <span class="special">&gt;</span> <span class="special">&amp;&amp;</span><span class="special">,</span> <a class="link" href="try_to_lock_type.html" title="Struct try_to_lock_type">try_to_lock_type</a><span class="special">,</span> <span class="emphasis"><em><span class="identifier">unspecified</span></em></span> <span class="special">=</span> <span class="number">0</span><span class="special">)</span><span class="special">;</span>
52   <a class="link" href="upgradable_lock.html" title="Class template upgradable_lock">upgradable_lock</a> <span class="special">&amp;</span> <a class="link" href="upgradable_lock.html#idm45336639897136-bb"><span class="keyword">operator</span><span class="special">=</span></a><span class="special">(</span><a class="link" href="upgradable_lock.html" title="Class template upgradable_lock">upgradable_lock</a> <span class="special">&amp;&amp;</span><span class="special">)</span><span class="special">;</span>
53   <a class="link" href="upgradable_lock.html#idm45336639897952-bb"><span class="special">~</span><span class="identifier">upgradable_lock</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>
54
55   <span class="comment">// <a class="link" href="upgradable_lock.html#idm45336639948080-bb">public member functions</a></span>
56   <span class="keyword">void</span> <a class="link" href="upgradable_lock.html#idm45336639947520-bb"><span class="identifier">lock</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>
57   <span class="keyword">bool</span> <a class="link" href="upgradable_lock.html#idm45336639945280-bb"><span class="identifier">try_lock</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>
58   <span class="keyword">bool</span> <a class="link" href="upgradable_lock.html#idm45336639942832-bb"><span class="identifier">timed_lock</span></a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">posix_time</span><span class="special">::</span><span class="identifier">ptime</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
59   <span class="keyword">void</span> <a class="link" href="upgradable_lock.html#idm45336639939616-bb"><span class="identifier">unlock</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>
60   <span class="keyword">bool</span> <a class="link" href="upgradable_lock.html#idm45336639937408-bb"><span class="identifier">owns</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
61   <a class="link" href="upgradable_lock.html#idm45336639935104-bb"><span class="keyword">operator</span> <span class="identifier">unspecified_bool_type</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
62   <span class="identifier">mutex_type</span> <span class="special">*</span> <a class="link" href="upgradable_lock.html#idm45336639933552-bb"><span class="identifier">mutex</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
63   <span class="identifier">mutex_type</span> <span class="special">*</span> <a class="link" href="upgradable_lock.html#idm45336639931936-bb"><span class="identifier">release</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>
64   <span class="keyword">void</span> <a class="link" href="upgradable_lock.html#idm45336639930544-bb"><span class="identifier">swap</span></a><span class="special">(</span><a class="link" href="upgradable_lock.html" title="Class template upgradable_lock">upgradable_lock</a><span class="special">&lt;</span> <span class="identifier">mutex_type</span> <span class="special">&gt;</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
65 <span class="special">}</span><span class="special">;</span></pre></div>
66 <div class="refsect1">
67 <a name="id-1.3.19.17.3.77.4.4"></a><h2>Description</h2>
68 <p><a class="link" href="upgradable_lock.html" title="Class template upgradable_lock">upgradable_lock</a> is meant to carry out the tasks for read-locking, unlocking, try-read-locking and timed-read-locking (recursive or not) for the Mutex. Additionally the <a class="link" href="upgradable_lock.html" title="Class template upgradable_lock">upgradable_lock</a> can transfer ownership to a <a class="link" href="scoped_lock.html" title="Class template scoped_lock">scoped_lock</a> using transfer_lock syntax. The Mutex need not supply all of the functionality. If the client of upgradable_lock&lt;Mutex&gt; does not use functionality which the Mutex does not supply, no harm is done. Mutex ownership can be shared among read_locks, and a single <a class="link" href="upgradable_lock.html" title="Class template upgradable_lock">upgradable_lock</a>. <a class="link" href="upgradable_lock.html" title="Class template upgradable_lock">upgradable_lock</a> does not support copy semantics. However <a class="link" href="upgradable_lock.html" title="Class template upgradable_lock">upgradable_lock</a> supports ownership transfer from a upgradable_locks or scoped_locks via transfer_lock syntax. </p>
69 <div class="refsect2">
70 <a name="id-1.3.19.17.3.77.4.4.3"></a><h3>
71 <a name="boost.interprocess.upgradable_lockconstruct-copy-destruct"></a><code class="computeroutput">upgradable_lock</code> 
72         public
73        construct/copy/destruct</h3>
74 <div class="orderedlist"><ol class="orderedlist" type="1">
75 <li class="listitem">
76 <pre class="literallayout"><a name="idm45336639928112-bb"></a><span class="identifier">upgradable_lock</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre>
77 <p>Effects: Default constructs a <code class="computeroutput"><a class="link" href="upgradable_lock.html" title="Class template upgradable_lock">upgradable_lock</a></code>. Postconditions: owns() == false and mutex() == 0. </p>
78 </li>
79 <li class="listitem"><pre class="literallayout"><span class="keyword">explicit</span> <a name="idm45336639926624-bb"></a><span class="identifier">upgradable_lock</span><span class="special">(</span><span class="identifier">mutex_type</span> <span class="special">&amp;</span> m<span class="special">)</span><span class="special">;</span></pre></li>
80 <li class="listitem">
81 <pre class="literallayout"><a name="idm45336639925376-bb"></a><span class="identifier">upgradable_lock</span><span class="special">(</span><span class="identifier">mutex_type</span> <span class="special">&amp;</span> m<span class="special">,</span> <a class="link" href="defer_lock_type.html" title="Struct defer_lock_type">defer_lock_type</a><span class="special">)</span><span class="special">;</span></pre>
82 <p>Postconditions: owns() == false, and mutex() == &amp;m. Notes: The constructor will not take ownership of the mutex. There is no effect required on the referenced mutex. </p>
83 </li>
84 <li class="listitem">
85 <pre class="literallayout"><a name="idm45336639923024-bb"></a><span class="identifier">upgradable_lock</span><span class="special">(</span><span class="identifier">mutex_type</span> <span class="special">&amp;</span> m<span class="special">,</span> <a class="link" href="accept_ownership_type.html" title="Struct accept_ownership_type">accept_ownership_type</a><span class="special">)</span><span class="special">;</span></pre>
86 <p>Postconditions: owns() == true, and mutex() == &amp;m. Notes: The constructor will suppose that the mutex is already upgradable locked. There is no effect required on the referenced mutex. </p>
87 </li>
88 <li class="listitem">
89 <pre class="literallayout"><a name="idm45336639920640-bb"></a><span class="identifier">upgradable_lock</span><span class="special">(</span><span class="identifier">mutex_type</span> <span class="special">&amp;</span> m<span class="special">,</span> <a class="link" href="try_to_lock_type.html" title="Struct try_to_lock_type">try_to_lock_type</a><span class="special">)</span><span class="special">;</span></pre>
90 <p>Effects: m.try_lock_upgradable(). Postconditions: mutex() == &amp;m. owns() == the return value of the m.try_lock_upgradable() executed within the constructor. Notes: The constructor will take upgradable-ownership of the mutex if it can do so without waiting. Whether or not this constructor handles recursive locking depends upon the mutex. If the mutex_type does not support try_lock_upgradable, this constructor will fail at compile time if instantiated, but otherwise have no effect. </p>
91 </li>
92 <li class="listitem">
93 <pre class="literallayout"><a name="idm45336639917968-bb"></a><span class="identifier">upgradable_lock</span><span class="special">(</span><span class="identifier">mutex_type</span> <span class="special">&amp;</span> m<span class="special">,</span> <span class="keyword">const</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">posix_time</span><span class="special">::</span><span class="identifier">ptime</span> <span class="special">&amp;</span> abs_time<span class="special">)</span><span class="special">;</span></pre>
94 <p>Effects: m.timed_lock_upgradable(abs_time) Postconditions: mutex() == &amp;m. owns() == the return value of the m.timed_lock_upgradable() executed within the constructor. Notes: The constructor will take upgradable-ownership of the mutex if it can do so within the time specified. Whether or not this constructor handles recursive locking depends upon the mutex. If the mutex_type does not support timed_lock_upgradable, this constructor will fail at compile time if instantiated, but otherwise have no effect. </p>
95 </li>
96 <li class="listitem">
97 <pre class="literallayout"><a name="idm45336639915376-bb"></a><span class="identifier">upgradable_lock</span><span class="special">(</span><a class="link" href="upgradable_lock.html" title="Class template upgradable_lock">upgradable_lock</a><span class="special">&lt;</span> <span class="identifier">mutex_type</span> <span class="special">&gt;</span> <span class="special">&amp;&amp;</span> upgr<span class="special">)</span><span class="special">;</span></pre>
98 <p>Effects: No effects on the underlying mutex. Postconditions: mutex() == the value upgr.mutex() had before the construction. upgr.mutex() == 0. owns() == upgr.owns() before the construction. upgr.owns() == false. Notes: If upgr is locked, this constructor will lock this <code class="computeroutput"><a class="link" href="upgradable_lock.html" title="Class template upgradable_lock">upgradable_lock</a></code> while unlocking upgr. If upgr is unlocked, then this <code class="computeroutput"><a class="link" href="upgradable_lock.html" title="Class template upgradable_lock">upgradable_lock</a></code> will be unlocked as well. Only a moved <code class="computeroutput"><a class="link" href="upgradable_lock.html" title="Class template upgradable_lock">upgradable_lock</a></code>'s will match this signature. An non-moved <code class="computeroutput"><a class="link" href="upgradable_lock.html" title="Class template upgradable_lock">upgradable_lock</a></code> can be moved with the expression: "boost::move(lock);". This constructor does not alter the state of the mutex, only potentially who owns it. </p>
99 </li>
100 <li class="listitem">
101 <pre class="literallayout"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> T<span class="special">&gt;</span> 
102   <a name="idm45336639910272-bb"></a><span class="identifier">upgradable_lock</span><span class="special">(</span><a class="link" href="scoped_lock.html" title="Class template scoped_lock">scoped_lock</a><span class="special">&lt;</span> <span class="identifier">T</span> <span class="special">&gt;</span> <span class="special">&amp;&amp;</span> scop<span class="special">,</span> <span class="emphasis"><em><span class="identifier">unspecified</span></em></span> <span class="special">=</span> <span class="number">0</span><span class="special">)</span><span class="special">;</span></pre>
103 <p>Effects: If scop.owns(), m_.unlock_and_lock_upgradable(). Postconditions: mutex() == the value scop.mutex() had before the construction. scop.mutex() == 0. owns() == scop.owns() before the constructor. After the construction, scop.owns() == false. Notes: If scop is locked, this constructor will transfer the exclusive-ownership to an upgradable-ownership of this <code class="computeroutput"><a class="link" href="upgradable_lock.html" title="Class template upgradable_lock">upgradable_lock</a></code>. Only a moved <code class="computeroutput"><a class="link" href="sharable_lock.html" title="Class template sharable_lock">sharable_lock</a></code>'s will match this signature. An non-moved <code class="computeroutput"><a class="link" href="sharable_lock.html" title="Class template sharable_lock">sharable_lock</a></code> can be moved with the expression: "boost::move(lock);". </p>
104 </li>
105 <li class="listitem">
106 <pre class="literallayout"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> T<span class="special">&gt;</span> 
107   <a name="idm45336639904000-bb"></a><span class="identifier">upgradable_lock</span><span class="special">(</span><a class="link" href="sharable_lock.html" title="Class template sharable_lock">sharable_lock</a><span class="special">&lt;</span> <span class="identifier">T</span> <span class="special">&gt;</span> <span class="special">&amp;&amp;</span> shar<span class="special">,</span> <a class="link" href="try_to_lock_type.html" title="Struct try_to_lock_type">try_to_lock_type</a><span class="special">,</span> 
108                   <span class="emphasis"><em><span class="identifier">unspecified</span></em></span> <span class="special">=</span> <span class="number">0</span><span class="special">)</span><span class="special">;</span></pre>
109 <p>Effects: If shar.owns() then calls try_unlock_sharable_and_lock_upgradable() on the referenced mutex. a)if try_unlock_sharable_and_lock_upgradable() returns true then mutex() obtains the value from shar.release() and owns() is set to true. b)if try_unlock_sharable_and_lock_upgradable() returns false then shar is unaffected and this <code class="computeroutput"><a class="link" href="upgradable_lock.html" title="Class template upgradable_lock">upgradable_lock</a></code> construction has the same effects as a default construction. c)Else shar.owns() is false. mutex() obtains the value from shar.release() and owns() is set to false. Notes: This construction will not block. It will try to obtain mutex ownership from shar immediately, while changing the lock type from a "read lock" to an "upgradable lock". If the "read lock" isn't held in the first place, the mutex merely changes type to an unlocked "upgradable lock". If the "read lock" is held, then mutex transfer occurs only if it can do so in a non-blocking manner. </p>
110 </li>
111 <li class="listitem">
112 <pre class="literallayout"><a class="link" href="upgradable_lock.html" title="Class template upgradable_lock">upgradable_lock</a> <span class="special">&amp;</span> <a name="idm45336639897136-bb"></a><span class="keyword">operator</span><span class="special">=</span><span class="special">(</span><a class="link" href="upgradable_lock.html" title="Class template upgradable_lock">upgradable_lock</a> <span class="special">&amp;&amp;</span> upgr<span class="special">)</span><span class="special">;</span></pre>
113 <p>Effects: If owns(), then unlock_upgradable() is called on mutex(). *this gets the state of upgr and upgr gets set to a default constructed state. Notes: With a recursive mutex it is possible that both this and upgr own the mutex before the assignment. In this case, this will own the mutex after the assignment (and upgr will not), but the mutex's upgradable lock count will be decremented by one. </p>
114 </li>
115 <li class="listitem">
116 <pre class="literallayout"><a name="idm45336639897952-bb"></a><span class="special">~</span><span class="identifier">upgradable_lock</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre>
117 <p>Effects: if (owns()) m_-&gt;unlock_upgradable(). Notes: The destructor behavior ensures that the mutex lock is not leaked. </p>
118 </li>
119 </ol></div>
120 </div>
121 <div class="refsect2">
122 <a name="id-1.3.19.17.3.77.4.4.4"></a><h3>
123 <a name="idm45336639948080-bb"></a><code class="computeroutput">upgradable_lock</code> public member functions</h3>
124 <div class="orderedlist"><ol class="orderedlist" type="1">
125 <li class="listitem">
126 <pre class="literallayout"><span class="keyword">void</span> <a name="idm45336639947520-bb"></a><span class="identifier">lock</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre>
127 <p>Effects: If mutex() == 0 or if already locked, throws a lock_exception() exception. Calls lock_upgradable() on the referenced mutex. Postconditions: owns() == true. Notes: The <code class="computeroutput"><a class="link" href="sharable_lock.html" title="Class template sharable_lock">sharable_lock</a></code> changes from a state of not owning the mutex, to owning the mutex, blocking if necessary. </p>
128 </li>
129 <li class="listitem">
130 <pre class="literallayout"><span class="keyword">bool</span> <a name="idm45336639945280-bb"></a><span class="identifier">try_lock</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre>
131 <p>Effects: If mutex() == 0 or if already locked, throws a lock_exception() exception. Calls try_lock_upgradable() on the referenced mutex. Postconditions: owns() == the value returned from mutex()-&gt;try_lock_upgradable(). Notes: The <code class="computeroutput"><a class="link" href="upgradable_lock.html" title="Class template upgradable_lock">upgradable_lock</a></code> changes from a state of not owning the mutex, to owning the mutex, but only if blocking was not required. If the mutex_type does not support try_lock_upgradable(), this function will fail at compile time if instantiated, but otherwise have no effect. </p>
132 </li>
133 <li class="listitem">
134 <pre class="literallayout"><span class="keyword">bool</span> <a name="idm45336639942832-bb"></a><span class="identifier">timed_lock</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">posix_time</span><span class="special">::</span><span class="identifier">ptime</span> <span class="special">&amp;</span> abs_time<span class="special">)</span><span class="special">;</span></pre>
135 <p>Effects: If mutex() == 0 or if already locked, throws a lock_exception() exception. Calls timed_lock_upgradable(abs_time) on the referenced mutex. Postconditions: owns() == the value returned from mutex()-&gt;timed_lock_upgradable(abs_time). Notes: The <code class="computeroutput"><a class="link" href="upgradable_lock.html" title="Class template upgradable_lock">upgradable_lock</a></code> changes from a state of not owning the mutex, to owning the mutex, but only if it can obtain ownership within the specified time. If the mutex_type does not support timed_lock_upgradable(abs_time), this function will fail at compile time if instantiated, but otherwise have no effect. </p>
136 </li>
137 <li class="listitem">
138 <pre class="literallayout"><span class="keyword">void</span> <a name="idm45336639939616-bb"></a><span class="identifier">unlock</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre>
139 <p>Effects: If mutex() == 0 or if not locked, throws a lock_exception() exception. Calls unlock_upgradable() on the referenced mutex. Postconditions: owns() == false. Notes: The <code class="computeroutput"><a class="link" href="upgradable_lock.html" title="Class template upgradable_lock">upgradable_lock</a></code> changes from a state of owning the mutex, to not owning the mutex. </p>
140 </li>
141 <li class="listitem">
142 <pre class="literallayout"><span class="keyword">bool</span> <a name="idm45336639937408-bb"></a><span class="identifier">owns</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>
143 <p>Effects: Returns true if this <code class="computeroutput"><a class="link" href="scoped_lock.html" title="Class template scoped_lock">scoped_lock</a></code> has acquired the referenced mutex. </p>
144 </li>
145 <li class="listitem">
146 <pre class="literallayout"><a name="idm45336639935104-bb"></a><span class="keyword">operator</span> <span class="identifier">unspecified_bool_type</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>
147 <p>Conversion to bool. Returns owns(). </p>
148 </li>
149 <li class="listitem">
150 <pre class="literallayout"><span class="identifier">mutex_type</span> <span class="special">*</span> <a name="idm45336639933552-bb"></a><span class="identifier">mutex</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>
151 <p>Effects: Returns a pointer to the referenced mutex, or 0 if there is no mutex to reference. </p>
152 </li>
153 <li class="listitem">
154 <pre class="literallayout"><span class="identifier">mutex_type</span> <span class="special">*</span> <a name="idm45336639931936-bb"></a><span class="identifier">release</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre>
155 <p>Effects: Returns a pointer to the referenced mutex, or 0 if there is no mutex to reference. Postconditions: mutex() == 0 and owns() == false. </p>
156 </li>
157 <li class="listitem">
158 <pre class="literallayout"><span class="keyword">void</span> <a name="idm45336639930544-bb"></a><span class="identifier">swap</span><span class="special">(</span><a class="link" href="upgradable_lock.html" title="Class template upgradable_lock">upgradable_lock</a><span class="special">&lt;</span> <span class="identifier">mutex_type</span> <span class="special">&gt;</span> <span class="special">&amp;</span> other<span class="special">)</span><span class="special">;</span></pre>
159 <p>Effects: Swaps state with moved lock. Throws: Nothing. </p>
160 </li>
161 </ol></div>
162 </div>
163 </div>
164 </div>
165 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
166 <td align="left"></td>
167 <td align="right"><div class="copyright-footer">Copyright &#169; 2005-2015 Ion Gaztanaga<p>
168         Distributed under the Boost Software License, Version 1.0. (See accompanying
169         file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
170       </p>
171 </div></td>
172 </tr></table>
173 <hr>
174 <div class="spirit-nav">
175 <a accesskey="p" href="sharable_lock.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../interprocess/indexes_reference.html#header.boost.interprocess.sync.upgradable_lock_hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="windows_shared_memory.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
176 </div>
177 </body>
178 </html>