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
22      span.virtual_style
23      {
24        font-size			 : 8pt;
25        color				 : white;
26        font-weight			: bold;
27        background			: #0a0;
28        border-left			: solid 1px #0f0;
29        border-top			: solid 1px #0f0;
30        border-right		: solid 1px #060;
31        border-bottom		: solid 1px #060;
32        padding-left		: 2px;
33        padding-right		: 2px;
34      }
35
36      span.protected_style
37      {
38        font-size			 : 8pt;
39        color				 : white;
40        font-weight			: bold;
41        background			: #444;
42        border-left			: solid 1px #ccc;
43        border-top			: solid 1px #ccc;
44        border-right		: solid 1px #222;
45        border-bottom		: solid 1px #222;
46        padding-left		: 2px;
47        padding-right		: 2px;
48      }
49        --></style>
50<title>nn::os::Thread</title>
51  </head>
52  <body>
53<h1><CODE><a href="../../../nn/Overview.html">nn</a>::<a href="../../../nn/os/Overview.html">os</a>::Thread</CODE> Class</h1>
54    <div class="section">
55<b>Header file: </b>nn/os.h</div>
56<h2>Syntax</h2>
57    <div class="section">
58      <pre class="definition">class Thread : public <a href="../../../nn/os/WaitObject/Overview.html">nn::os::WaitObject</a></pre>
59    </div>
60<h2>Description</h2>
61    <div class="section">
62<p>Class for representing threads.</p><p>Threads have priorities. The thread priority is specified as an integer from 0 to 31, with 0 indicating the highest priority. Standard threads specify the <CODE>DEFAULT_THREAD_PRIORITY</CODE> of <CODE>16</CODE>.</p><p>A stack region is needed for thread operation. You can either directly specify a memory region for this stack region, or you can use <CODE><a href="../../../nn/os/AutoStackManager/Overview.html">AutoStackManager</a></CODE>.</p><p>To directly specify a memory region, pass the stack region to the <CODE><a href="../../../nn/os/Thread/Start.html">Start</a></CODE> function when you start the thread. Pass a stack region that is an instance of a class that has a function similar to <CODE>uptr GetStackBottom()</CODE>. The <CODE><a href="../../../nn/os/StackMemoryBlock/Overview.html">StackMemoryBlock</a></CODE> and <CODE><a href="../../../nn/os/StackBuffer/Overview.html">StackBuffer</a></CODE> classes meet these requirements, so they can pass the stack region directly. <BR><B>Note:</B> If you are directly specifying a memory region, be careful that the stack region does not get invalidated before the thread is destroyed. (For example, releasing it will invalidate it.)</p><p>To use <CODE><a href="../../../nn/os/AutoStackManager/Overview.html">AutoStackManager</a></CODE> to manage the stack region, pass the stack size to the <CODE><a href="../../../nn/os/Thread/StartUsingAutoStack.html">StartUsingAutoStack</a></CODE> function when you start the thread.</p><p>Thread objects become valid once <CODE>Start</CODE>-series functions have been left. Note that it is not at the point when a thread starts running. The <CODE>IsValid</CODE> function can be used to check whether an object is valid.</p><p>You must always call <CODE><a href="../../../nn/os/Thread/Join.html">Join</a></CODE> explicitly before destroying <CODE><a href="../../../nn/os/Thread/Overview.html">Thread</a></CODE> objects that were started using the <CODE><a href="../../../nn/os/Thread/Start.html">Start</a></CODE> function. You cannot call <CODE><a href="../../../nn/os/Thread/Detach.html">Detach</a></CODE>.</p><p>You must always call either <CODE><a href="../../../nn/os/Thread/Join.html">Join</a></CODE> or <CODE><a href="../../../nn/os/Thread/Detach.html">Detach</a></CODE> explicitly before destroying <CODE><a href="../../../nn/os/Thread/Overview.html">Thread</a></CODE> objects that were started using the <CODE><a href="../../../nn/os/Thread/StartUsingAutoStack.html">StartUsingAutoStack</a></CODE> function.</p><p><CODE><a href="../../../nn/os/Thread/Overview.html">Thread</a></CODE> objects inherit <CODE><a href="../../../nn/os/WaitObject/Overview.html">WaitObject</a></CODE> objects; when a thread is released from waiting, it means that the thread has exited. When it's necessary to perform non-blocking <CODE><a href="../../../nn/os/Thread/Join.html">Join</a></CODE> operations, call a function like <CODE><a href="../../../nn/os/WaitObject/WaitOne.html">WaitOne</a></CODE> or <CODE><a href="../../../nn/os/WaitObject/WaitAny.html">WaitObject::WaitAny</a></CODE> first to verify that the thread has been released from waiting.</p><p>You can create up to 32 <a href="../../../nn/os/Thread/Overview.html"><CODE>Thread</CODE></a> objects. Note also that different functions might use up resources that count against this limit.</p><!-- write here --></div>
63    <a name="function" id="function">
64<h2>Member Functions</h2>
65      <div class="section">
66        <table class="members">
67          <tr>
68<th class="category" colspan="3">Constructors/Destructors</th>
69          </tr>
70          <tr>
71            <td width="100">  </td>
72            <th>
73<a href="../../../nn/os/Thread/Thread.html"><CODE>Thread</CODE></a>
74            </th>
75<td>Constructor.</td>
76          </tr>
77          <tr>
78            <td width="100">  </td>
79            <th>
80<a href="../../../nn/os/Thread/~Thread.html"><CODE>~Thread</CODE></a>
81            </th>
82<td>Destructor.</td>
83          </tr>
84          <tr>
85<th class="category" colspan="3">Starting Threads</th>
86          </tr>
87          <tr>
88            <td width="100">  </td>
89            <th>
90<a href="../../../nn/os/Thread/Start.html"><CODE>Start</CODE></a>
91            </th>
92<td>Initializes and runs a thread.</td>
93          </tr>
94          <tr>
95            <td width="100">  </td>
96            <th>
97<a href="../../../nn/os/Thread/TryStart.html"><CODE>TryStart</CODE></a>
98            </th>
99<td>Tries to initialize and run a thread.</td>
100          </tr>
101          <tr>
102            <td width="100">  </td>
103            <th>
104<a href="../../../nn/os/Thread/StartUsingAutoStack.html"><CODE>StartUsingAutoStack</CODE></a>
105            </th>
106<td>Initializes and runs a thread.</td>
107          </tr>
108          <tr>
109            <td width="100">  </td>
110            <th>
111<a href="../../../nn/os/Thread/TryStartUsingAutoStack.html"><CODE>TryStartUsingAutoStack</CODE></a>
112            </th>
113<td>Tries to initialize and run a thread.</td>
114          </tr>
115          <tr>
116<th class="category" colspan="3">Waiting for Termination and Releasing Resources</th>
117          </tr>
118          <tr>
119            <td width="100">  </td>
120            <th>
121<a href="../../../nn/os/Thread/Finalize.html"><CODE>Finalize</CODE></a>
122            </th>
123<td>Destroys a thread object.</td>
124          </tr>
125          <tr>
126            <td width="100">  </td>
127            <th>
128<a href="../../../nn/os/Thread/Join.html"><CODE>Join</CODE></a>
129            </th>
130<td>Waits for a thread to exit.</td>
131          </tr>
132          <tr>
133            <td width="100">  </td>
134            <th>
135<a href="../../../nn/os/Thread/Detach.html"><CODE>Detach</CODE></a>
136            </th>
137<td>Detaches thread so it is no longer subject to management.</td>
138          </tr>
139          <tr>
140            <td width="100">  </td>
141            <th>
142<a href="../../../nn/os/Thread/IsAlive.html"><CODE>IsAlive</CODE></a>
143            </th>
144<td>Gets whether the thread has completed.</td>
145          </tr>
146          <tr>
147<th class="category" colspan="3">Getters/Setters</th>
148          </tr>
149          <tr>
150            <td width="100">  </td>
151            <th>
152<a href="../../../nn/os/Thread/GetId.html"><CODE>GetId</CODE></a>
153            </th>
154<td>Gets the thread ID of an instance's thread.</td>
155          </tr>
156          <tr>
157            <td width="100">  </td>
158            <th>
159<a href="../../../nn/os/Thread/GetPriority.html"><CODE>GetPriority</CODE></a>
160            </th>
161<td>Gets the thread priority of an instance.</td>
162          </tr>
163          <tr>
164            <td width="100">  </td>
165            <th>
166<a href="../../../nn/os/Thread/ChangePriority.html"><CODE>ChangePriority</CODE></a>
167            </th>
168<td>Sets the thread priority of an instance.</td>
169          </tr>
170          <tr>
171            <td width="100">  </td>
172            <th>
173<a href="../../../nn/os/Thread/GetIdealProcessor.html"><CODE>GetIdealProcessor</CODE></a>
174            </th>
175<td>Gets the preferred processor number of an instance.</td>
176          </tr>
177          <tr>
178            <td width="100">
179<span class="static_style" title="static">S</span> </td>
180            <th>
181<a href="../../../nn/os/Thread/GetCurrentId.html"><CODE>GetCurrentId</CODE></a>
182            </th>
183<td>Gets the thread ID of the current thread.</td>
184          </tr>
185          <tr>
186            <td width="100">
187<span class="static_style" title="static">S</span> </td>
188            <th>
189<a href="../../../nn/os/Thread/GetCurrentPriority.html"><CODE>GetCurrentPriority</CODE></a>
190            </th>
191<td>Gets the priority of the current thread.</td>
192          </tr>
193          <tr>
194            <td width="100">
195<span class="static_style" title="static">S</span> </td>
196            <th>
197<a href="../../../nn/os/Thread/ChangeCurrentPriority.html"><CODE>ChangeCurrentPriority</CODE></a>
198            </th>
199<td>Sets the priority of the current thread.</td>
200          </tr>
201          <tr>
202            <td width="100">
203<span class="static_style" title="static">S</span> </td>
204            <th>
205<a href="../../../nn/os/Thread/GetCurrentProcessorNumber.html"><CODE>GetCurrentProcessorNumber</CODE></a>
206            </th>
207<td>Gets the number of the processor that the current thread is running on.</td>
208          </tr>
209          <tr>
210<th class="category" colspan="3">Current Thread Control</th>
211          </tr>
212          <tr>
213            <td width="100">
214<span class="static_style" title="static">S</span> </td>
215            <th>
216<a href="../../../nn/os/Thread/Sleep.html"><CODE>Sleep</CODE></a>
217            </th>
218<td>Puts the current thread to sleep for the time specified.</td>
219          </tr>
220          <tr>
221            <td width="100">
222<span class="static_style" title="static">S</span> </td>
223            <th>
224<a href="../../../nn/os/Thread/Yield.html"><CODE>Yield</CODE></a>
225            </th>
226<td>Gives threads with the same priority level as the current thread a chance to run.</td>
227          </tr>
228          <tr>
229<th class="category" colspan="3">Other</th>
230          </tr>
231          <tr>
232            <td width="100">
233<span class="static_style" title="static">S</span> </td>
234            <th>
235<a href="../../../nn/os/Thread/GetMainThread.html"><CODE>GetMainThread</CODE></a>
236            </th>
237<td>Gets the object that represents the main thread.</td>
238          </tr>
239          <tr>
240            <td width="100">
241<span class="static_style" title="static">S</span> </td>
242            <th>
243<a href="../../../nn/os/Thread/SetAutoStackManager.html"><CODE>SetAutoStackManager</CODE></a>
244            </th>
245<td>Changes the <CODE><a href="../../../nn/os/AutoStackManager/Overview.html">AutoStackManager</a></CODE>.</td>
246          </tr>
247          <tr>
248            <td width="100">
249<span class="static_style" title="static">S</span> </td>
250            <th>
251<a href="../../../nn/os/Thread/GetCurrentCount.html">GetCurrentCount</a>
252            </th>
253<td>Gets the number of <CODE><a href="../../../nn/os/Thread/Overview.html">Thread</a></CODE> objects that are currently being used.</td>
254          </tr>
255          <tr>
256            <td width="100">
257<span class="static_style" title="static">S</span> </td>
258            <th>
259<a href="../../../nn/os/Thread/GetMaxCount.html">GetMaxCount</a>
260            </th>
261<td>Gets the maximum number of <CODE><a href="../../../nn/os/Thread/Overview.html">Thread</a></CODE> objects being used simultaneously.</td>
262          </tr> </table>
263      </div>
264    </a>
265<h2>Class Hierarchy</h2>
266    <div class="section">
267<p class="hierarchy"><a href="../../../nn/util/NonCopyable/Overview.html">nn::util::NonCopyable</a><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::Thread</b>
268      </p>
269    </div>
270<h2>Revision History</h2>
271    <div class="section">
272      <dl class="history">
273        <dt>2010/01/07</dt>
274<dd>Initial version.<br />
275        </dd>
276      </dl>
277    </div>
278  <hr><p>CONFIDENTIAL</p></body>
279</html>