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::CriticalSection</title>
49  </head>
50  <body>
51<h1><CODE><a href="../../../nn/Overview.html">nn</a>::<a href="../../../nn/os/Overview.html">os</a>::CriticalSection</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 CriticalSection :private <a href="../../../nn/util/NonCopyable/Overview.html">nn::util::NonCopyable&lt; CriticalSection &gt;</a></pre>
57    </div>
58<h2>Description</h2>
59    <div class="section">
60<p>Class for handling critical sections. Critical sections are synchronization objects used for providing mutual exclusion.</p><p>This mechanism prevents certain areas within programs from being run simultaneously within multiple threads. It also prevents resources from being accessed by multiple threads simultaneously.</p><p>Critical sections play the same role as mutexes (<a href="../../../nn/os/Mutex/Overview.html"><CODE>nn::os::Mutex</CODE></a>), but they have the following limitations.</p><p><itemizedlist><listitem><para>No priority inheritance takes place. Problems such as priority inversion may occur.</para></listitem><listitem><para>Critical sections use more memory to store objects than mutexes do. 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. In most cases, use <a href="../../../nn/os/CriticalSection/Overview.html"><CODE>nn::os::CriticalSection</CODE></a> instead of <a href="../../../nn/os/Mutex/Overview.html"><CODE>nn::os::Mutex</CODE></a>.</p><p>The use of <a href="../../../nn/os/CriticalSection/ScopedLock/Overview.html"><CODE>nn::os::CriticalSection::ScopedLock</CODE></a> makes it possible to enter a critical section when an object is created and stay in the critical section until the scope is exited.</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/CriticalSection/ScopedLock/Overview.html"><CODE>nn::os::CriticalSection::ScopedLock</CODE></a>
68            </th>
69<td>Enters a critical section when an object is created and stays in until the scope is exited.</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/CriticalSection/CriticalSection.html"><CODE>CriticalSection</CODE></a>
80            </th>
81<td>Constructs an object.</td>
82          </tr>
83          <tr>
84            <td width="100">  </td>
85            <th>
86<a href="../../../nn/os/CriticalSection/Initialize.html"><CODE>Initialize</CODE></a>
87            </th>
88<td>Initializes an object.</td>
89          </tr>
90          <tr>
91            <td width="100">  </td>
92            <th>
93<a href="../../../nn/os/CriticalSection/TryInitialize.html"><CODE>TryInitialize</CODE></a>
94            </th>
95<td>Tries to initialize an object.</td>
96          </tr>
97          <tr>
98            <td width="100">  </td>
99            <th>
100<a href="../../../nn/os/CriticalSection/Finalize.html"><CODE>Finalize</CODE></a>
101            </th>
102<td>Destroys a critical section.</td>
103          </tr>
104          <tr>
105            <td width="100">  </td>
106            <th>
107<a href="../../../nn/os/CriticalSection/~CriticalSection.html"><CODE>~CriticalSection</CODE></a>
108            </th>
109<td>Destructor.</td>
110          </tr>
111          <tr>
112            <td width="100">  </td>
113            <th>
114<a href="../../../nn/os/CriticalSection/Enter.html"><CODE>Enter</CODE></a>
115            </th>
116<td>Locks out other threads and prevents them from entering a critical section. This function blocks.</td>
117          </tr>
118          <tr>
119            <td width="100">  </td>
120            <th>
121<a href="../../../nn/os/CriticalSection/TryEnter.html"><CODE>TryEnter</CODE></a>
122            </th>
123<td>Locks out other threads and prevents them from entering a critical section. This function does not block.</td>
124          </tr>
125          <tr>
126            <td width="100">  </td>
127            <th>
128<a href="../../../nn/os/CriticalSection/Leave.html"><CODE>Leave</CODE></a>
129            </th>
130<td>Unlocks and allows other threads to enter a critical section.</td>
131          </tr> </table>
132      </div>
133    </a>
134<h2>Class Hierarchy</h2>
135    <div class="section">
136<p class="hierarchy"><a href="../../../nn/util/NonCopyable/Overview.html">nn::util::NonCopyable</a><br />&nbsp;&nbsp;<b>nn::os::CriticalSection</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