File: a00080.html

package info (click to toggle)
libloki 0.1.7-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,608 kB
  • sloc: cpp: 30,475; ansic: 1,974; makefile: 365; php: 316; perl: 108
file content (230 lines) | stat: -rwxr-xr-x 12,491 bytes parent folder | download | duplicates (5)
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Loki: Loki::MultiMutexLocker Class Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css">
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.8 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
    <li>
      <form action="search.php" method="get">
        <table cellspacing="0" cellpadding="0" border="0">
          <tr>
            <td><label>&nbsp;<u>S</u>earch&nbsp;for&nbsp;</label></td>
            <td><input type="text" name="query" value="" size="20" accesskey="s"/></td>
          </tr>
        </table>
      </form>
    </li>
    </ul>
  </div>
  <div class="tabs">
    <ul>
      <li><a href="annotated.html"><span>Class&nbsp;List</span></a></li>
      <li><a href="classes.html"><span>Class&nbsp;Index</span></a></li>
      <li><a href="hierarchy.html"><span>Class&nbsp;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&nbsp;Members</span></a></li>
    </ul>
  </div>
  <div class="navpath"><a class="el" href="a00192.html">Loki</a>::<a class="el" href="a00080.html">MultiMutexLocker</a>
  </div>
</div>
<div class="contents">
<h1>Loki::MultiMutexLocker Class Reference</h1><!-- doxytag: class="Loki::MultiMutexLocker" --><code>#include &lt;LevelMutex.h&gt;</code>
<p>

<p>
<a href="a00340.html">List of all members.</a><table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00080.html#aa646ae058e3273651f89bfbb276cf42">MultiMutexLocker</a> (<a class="el" href="a00071.html#76a0315d91234f5066c75660a9f27a7f">LevelMutexInfo::MutexContainer</a> &amp;mutexes, bool lock=true)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00080.html#a88fcf2068f0c4292e2f25fcd29c3e33">MultiMutexLocker</a> (<a class="el" href="a00071.html#76a0315d91234f5066c75660a9f27a7f">LevelMutexInfo::MutexContainer</a> &amp;mutexes, unsigned int milliSeconds, bool lock=true)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="b3f3fa705ae220da3e5be02e65d6ef10"></a><!-- doxytag: member="Loki::MultiMutexLocker::~MultiMutexLocker" ref="b3f3fa705ae220da3e5be02e65d6ef10" args="(void)" -->
&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00080.html#b3f3fa705ae220da3e5be02e65d6ef10">~MultiMutexLocker</a> (void)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Destructs the locker, and determines if it needs to unlock the mutexes. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">bool&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00080.html#9ce26d13eb156c9a8b7fa6228bf6724f">Lock</a> (void)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">bool&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00080.html#18bfdec10dd2e65e128d64a80e42407f">Unlock</a> (void)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="1bdfd6380329fff07890d2bc0e67427f"></a><!-- doxytag: member="Loki::MultiMutexLocker::IsLocked" ref="1bdfd6380329fff07890d2bc0e67427f" args="(void) const " -->
bool&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00080.html#1bdfd6380329fff07890d2bc0e67427f">IsLocked</a> (void) const </td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Returns true if the mutexes are locked by this object. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="1b95c9bfa8ff0737d0afd67d9820f67f"></a><!-- doxytag: member="Loki::MultiMutexLocker::GetMutexes" ref="1b95c9bfa8ff0737d0afd67d9820f67f" args="(void) const " -->
const <br class="typebreak">
<a class="el" href="a00071.html#76a0315d91234f5066c75660a9f27a7f">LevelMutexInfo::MutexContainer</a> &amp;&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00080.html#1b95c9bfa8ff0737d0afd67d9820f67f">GetMutexes</a> (void) const </td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Provides access to the collection of mutexes controlled by this. <br></td></tr>
</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
You can place an instance of this as a local variable inside a function to lock a collection of mutexes. It locks them if no error occurs, or throws an exception if one does happen. When the function ends, the destructor determines if it needs to unlock the mutexes. This RAII technique insures the mutexes get unlocked even when exceptions occur. You will also have to construct a MutexContainer as a local object within the same function. <hr><h2>Constructor &amp; Destructor Documentation</h2>
<a class="anchor" name="aa646ae058e3273651f89bfbb276cf42"></a><!-- doxytag: member="Loki::MultiMutexLocker::MultiMutexLocker" ref="aa646ae058e3273651f89bfbb276cf42" args="(LevelMutexInfo::MutexContainer &amp;mutexes, bool lock=true)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">Loki::MultiMutexLocker::MultiMutexLocker           </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="a00071.html#76a0315d91234f5066c75660a9f27a7f">LevelMutexInfo::MutexContainer</a> &amp;&nbsp;</td>
          <td class="paramname"> <em>mutexes</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bool&nbsp;</td>
          <td class="paramname"> <em>lock</em> = <code>true</code></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td><code> [explicit]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Creates an object to lock and unlock a collection of mutexes for a function. This will throw if an attempt to lock any mutex fails. If an exception occurs, it unlocks mutexes it previously locked. <dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>mutex</em>&nbsp;</td><td>Reference to a collection of mutexes. </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>lock</em>&nbsp;</td><td>True if function wants to lock the mutex as this gets constructed. </td></tr>
  </table>
</dl>

<p>References <a class="el" href="a00242.html#l00316">Loki::LevelMutexInfo::MultiLock()</a>.</p>

<p>
<div class="dynheader">
Here is the call graph for this function:</div>
<div class="dynsection">
</div>

</div>
</div><p>
<a class="anchor" name="a88fcf2068f0c4292e2f25fcd29c3e33"></a><!-- doxytag: member="Loki::MultiMutexLocker::MultiMutexLocker" ref="a88fcf2068f0c4292e2f25fcd29c3e33" args="(LevelMutexInfo::MutexContainer &amp;mutexes, unsigned int milliSeconds, bool lock=true)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">Loki::MultiMutexLocker::MultiMutexLocker           </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="a00071.html#76a0315d91234f5066c75660a9f27a7f">LevelMutexInfo::MutexContainer</a> &amp;&nbsp;</td>
          <td class="paramname"> <em>mutexes</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">unsigned int&nbsp;</td>
          <td class="paramname"> <em>milliSeconds</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bool&nbsp;</td>
          <td class="paramname"> <em>lock</em> = <code>true</code></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Creates an object to lock and unlock a collection of mutexes for a function. This waits a specified amount of time for other threads to unlock each mutex that is locked. This will throw if an attempt to lock any mutex fails. If an exception occurs, it unlocks mutexes it previously locked. <dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>mutexes</em>&nbsp;</td><td>Reference to a collection of mutexes. </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>milliSeconds</em>&nbsp;</td><td>Amount of time to wait for another thread to unlock the mutex. </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>lock</em>&nbsp;</td><td>True if function wants to lock the mutexes as this gets constructed. </td></tr>
  </table>
</dl>

<p>References <a class="el" href="a00242.html#l00316">Loki::LevelMutexInfo::MultiLock()</a>.</p>

<p>
<div class="dynheader">
Here is the call graph for this function:</div>
<div class="dynsection">
</div>

</div>
</div><p>
<hr><h2>Member Function Documentation</h2>
<a class="anchor" name="9ce26d13eb156c9a8b7fa6228bf6724f"></a><!-- doxytag: member="Loki::MultiMutexLocker::Lock" ref="9ce26d13eb156c9a8b7fa6228bf6724f" args="(void)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool Loki::MultiMutexLocker::Lock           </td>
          <td>(</td>
          <td class="paramtype">void&nbsp;</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
You can call this to lock (or relock) the mutexes. In theory, you can lock and unlock mutexes several times within a function in order to give other threads access to resources while this function does not need them. <dl class="return" compact><dt><b>Returns:</b></dt><dd>True if mutex is locked by this, else false if not locked. </dd></dl>

<p>References <a class="el" href="a00242.html#l00316">Loki::LevelMutexInfo::MultiLock()</a>.</p>

<p>
<div class="dynheader">
Here is the call graph for this function:</div>
<div class="dynsection">
</div>

</div>
</div><p>
<a class="anchor" name="18bfdec10dd2e65e128d64a80e42407f"></a><!-- doxytag: member="Loki::MultiMutexLocker::Unlock" ref="18bfdec10dd2e65e128d64a80e42407f" args="(void)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool Loki::MultiMutexLocker::Unlock           </td>
          <td>(</td>
          <td class="paramtype">void&nbsp;</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
You can call this to unlock the mutexes before the destructor does it. By unlocking the mutexes before returning, the function can do other operations without making other threads wait too long. <dl class="return" compact><dt><b>Returns:</b></dt><dd>True if unlocked by this, else false if not unlocked by this. (Which is not the same as whether the mutex itself is locked or not by another thread.) </dd></dl>

<p>References <a class="el" href="a00242.html#l00479">Loki::LevelMutexInfo::MultiUnlock()</a>.</p>

<p>
<div class="dynheader">
Here is the call graph for this function:</div>
<div class="dynsection">
</div>

</div>
</div><p>
<hr>The documentation for this class was generated from the following files:<ul>
<li><a class="el" href="a00158.html">LevelMutex.h</a><li><a class="el" href="a00157.html">LevelMutex.cpp</a></ul>
</div>
<hr size="1"><address style="text-align: right;"><small>Generated on Thu Jan 29 18:51:43 2009 for Loki by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.8 </small></address>
</body>
</html>