1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2<html xml:lang="en-US" lang="en-US" xmlns="http://www.w3.org/1999/xhtml">
3  <head>
4    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5    <meta http-equiv="Content-Style-Type" content="text/css" />
6    <link rel="stylesheet" href="../../../css/manpage.css" type="text/css" />
7    <style type="text/css"><!--
8      span.static_style
9      {
10        font-size			: 8pt;
11        color				: white;
12        font-weight			: bold;
13        background			: #44f;
14        border-left			: solid 1px #aaf;
15        border-top			: solid 1px #aaf;
16        border-right		: solid 1px #00c;
17        border-bottom		: solid 1px #00c;
18        padding-left		: 2px;
19        padding-right		: 2px;
20      }
21      span.virtual_style
22      {
23        font-size			 : 8pt;
24        color				 : white;
25        font-weight			: bold;
26        background			: #0a0;
27        border-left			: solid 1px #0f0;
28        border-top			: solid 1px #0f0;
29        border-right		: solid 1px #060;
30        border-bottom		: solid 1px #060;
31        padding-left		: 2px;
32        padding-right		: 2px;
33      }
34      span.protected_style
35      {
36        font-size			 : 8pt;
37        color				 : white;
38        font-weight			: bold;
39        background			: #444;
40        border-left			: solid 1px #ccc;
41        border-top			: solid 1px #ccc;
42        border-right		: solid 1px #222;
43        border-bottom		: solid 1px #222;
44        padding-left		: 2px;
45        padding-right		: 2px;
46      }
47        --></style>
48<title>nn::os::Mutex</title>
49  </head>
50  <body>
51<h1><CODE><a href="../../../nn/Overview.html">nn</a>::<a href="../../../nn/os/Overview.html">os</a>::Mutex</CODE> Class</h1>
52    <div class="section">
53<b>Header file: </b>nn/os.h</div>
54<h2>Syntax</h2>
55    <div class="section">
56<pre class="definition">class Mutex : public <a href="../../../nn/os/WaitObject/Overview.html">nn::os::WaitObject</a></pre>
57    </div>
58<h2>Description</h2>
59    <div class="section">
60<p>Class for handling mutexes. Mutexes are synchronization objects used for providing mutual exclusion.</p><p>Generally, use the <a href="../../../nn/os/Mutex/Overview.html"><CODE>nn::os::Mutex</CODE></a> class instead of <a href="../../../nn/os/CriticalSection/Overview.html"><CODE>nn::os::CriticalSection</CODE></a>. The <a href="../../../nn/os/CriticalSection/Overview.html"><CODE>nn::os::CriticalSection</CODE></a> class performs considerably faster than <a href="../../../nn/os/Mutex/Overview.html"><CODE>nn::os::Mutex</CODE></a> when there are no lock collisions between threads.</p><p>This mechanism prevents certain areas within programs from being run simultaneously within multiple threads. It also prevents data, registers, and other resources from being accessed by multiple threads simultaneously.</p><p>Mutexes can be locked using <a href="../../../nn/os/Mutex/Lock.html"><CODE>Lock</CODE></a>. A mutex that is locked by a certain thread cannot be locked by other threads. If another thread attempts to lock it, that thread will block until the mutex is unlocked.</p><p>The <CODE><a href="../../../nn/os/Mutex/Unlock.html">Unlock</a></CODE> method unlocks mutexes, but it can only be called from the locking thread because mutex locks are associated with their threads.</p><p>The <CODE><a href="../../../nn/os/Mutex/Overview.html">Mutex</a></CODE> class implements recursively locking mutexes. (In other words, <CODE><a href="../../../nn/os/Mutex/Lock.html">Lock</a></CODE> can be called from a locked thread.) In this case, the mutex will not be unlocked until <CODE><a href="../../../nn/os/Mutex/Unlock.html">Unlock</a></CODE> is called the same number of times that <CODE><a href="../../../nn/os/Mutex/Lock.html">Lock</a></CODE> was called.</p><p>The <CODE><a href="../../../nn/os/Mutex/Overview.html">Mutex</a></CODE> class implements priority inheritance. If a high-priority thread (&quot;H&quot;) attempts to get a lock on a mutex that is already locked by a low-priority thread (&quot;L&quot;), the priority of thread L will temporarily be raised to the same priority as thread H.</p><p>The <CODE>Wait</CODE> operation of a <CODE><a href="../../../nn/os/Mutex/Overview.html">Mutex</a></CODE> object gets a lock. Once the lock can be obtained, the <CODE>Wait</CODE> operation is released.</p><p>The use of <CODE><a href="../../../nn/os/Mutex/ScopedLock/Overview.html">nn::os::Mutex::ScopedLock</a></CODE> makes it possible to lock a mutex starting when an object is created, and continuing until it goes out of scope.</p><p>You can create up to 32 <a href="../../../nn/os/Mutex/Overview.html"><CODE>Mutex</CODE></a> objects. Note also that different functions might use up resources that count against this limit.</p><!-- write here --></div>
61    <a name="class" id="class">
62<h2>Classes</h2>
63      <div class="section">
64        <table class="members">
65          <tr>
66            <th>
67<a href="../../../nn/os/Mutex/ScopedLock/Overview.html"><CODE>nn::os::Mutex::ScopedLock</CODE></a>
68            </th>
69<td>Locks a mutex starting when an object is created, and continues locking it until the the object goes out of scope.</td>
70          </tr> </table>
71      </div>
72    </a> <a name="function" id="function">
73<h2>Member Functions</h2>
74      <div class="section">
75        <table class="members">
76          <tr>
77            <td width="100">  </td>
78            <th>
79<a href="../../../nn/os/Mutex/Mutex.html"><CODE>Mutex</CODE></a>
80            </th>
81<td>Constructs and initializes a mutex.</td>
82          </tr>
83          <tr>
84            <td width="100">  </td>
85            <th>
86<a href="../../../nn/os/Mutex/Initialize.html"><CODE>Initialize</CODE></a>
87            </th>
88<td>Initializes a mutex.</td>
89          </tr>
90          <tr>
91            <td width="100">  </td>
92            <th>
93<a href="../../../nn/os/Mutex/TryInitialize.html"><CODE>TryInitialize</CODE></a>
94            </th>
95<td>Tries to initialize a mutex.</td>
96          </tr>
97          <tr>
98            <td width="100">  </td>
99            <th>
100<a href="../../../nn/os/Mutex/Finalize.html"><CODE>Finalize</CODE></a>
101            </th>
102<td>Destroys a mutex.</td>
103          </tr>
104          <tr>
105            <td width="100">  </td>
106            <th>
107<a href="../../../nn/os/Mutex/~Mutex.html"><CODE>~Mutex</CODE></a>
108            </th>
109<td>Destructor.</td>
110          </tr>
111          <tr>
112            <td width="100">  </td>
113            <th>
114<a href="../../../nn/os/Mutex/Lock.html"><CODE>Lock</CODE></a>
115            </th>
116<td>Locks a mutex.</td>
117          </tr>
118          <tr>
119            <td width="100">  </td>
120            <th>
121<a href="../../../nn/os/Mutex/TryLock.html"><CODE>TryLock</CODE></a>
122            </th>
123<td>Tries to lock a mutex.</td>
124          </tr>
125          <tr>
126            <td width="100">  </td>
127            <th>
128<a href="../../../nn/os/Mutex/Unlock.html"><CODE>Unlock</CODE></a>
129            </th>
130<td>Unlocks a mutex.</td>
131          </tr> </table>
132      </div>
133    </a>
134<h2>Class Hierarchy</h2>
135    <div class="section">
136<p class="hierarchy"><span>ADLFireWall::NonCopyable</span><br />&nbsp;&nbsp;<a href="../../../nn/os/HandleObject/Overview.html">nn::os::HandleObject</a><br />&nbsp;&nbsp;&nbsp;&nbsp;<a href="../../../nn/os/WaitObject/Overview.html">nn::os::WaitObject</a><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>nn::os::Mutex</b>
137      </p>
138    </div>
139<h2>Revision History</h2>
140    <div class="section">
141      <dl class="history">
142        <dt>2010/01/07</dt>
143<dd>Initial version.<br />
144        </dd>
145      </dl>
146    </div>
147  <hr><p>CONFIDENTIAL</p></body>
148</html>
149