Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > bad97183153701b09df5fae1052b1c30 > files > 3992

crystalspace-doc-1.2.1-5mdv2010.0.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Crystal Space 1.2.1: csutil/threading/thread.h Source File (Crystal Space 1.2.1 Public API Reference)</title>
<link href="tabs.css" rel="stylesheet" type="text/css">
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<table border="0" cellpadding="0" cellspacing="0" width="100%" class="head">
 <tr height="59">
  <td class="head" width="202" valign="bottom" style="padding-left:0;"><a href="http://www.crystalspace3d.org/"><img src="csblur.png" width="236" height="59" alt="CrystalSpace" border="0"></a></td>
  <td class="head"><h2>Public API Reference</h2></td>
 </tr>
 <tr height="11">
  <td colspan="2" class="headshadow" valign="top" style="padding-left:0;"><img src="csblurb.png" width="236" height="11" alt="" border="0"></td>
 </tr>
</table>
<div class="content">
<!-- Generated by Doxygen 1.5.3 -->
<div class="tabs">
  <ul>
    <li><a href="index.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><a href="classes.html"><span>Classes</span></a></li>
    <li class="current"><a href="files.html"><span>Files</span></a></li>
    <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
  </ul>
</div>
<h1>csutil/threading/thread.h</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment">  Copyright (C) 2006 by Marten Svanfeldt</span>
<a name="l00003"></a>00003 <span class="comment"></span>
<a name="l00004"></a>00004 <span class="comment">  This library is free software; you can redistribute it and/or</span>
<a name="l00005"></a>00005 <span class="comment">  modify it under the terms of the GNU Lesser General Public</span>
<a name="l00006"></a>00006 <span class="comment">  License as published by the Free Software Foundation; either</span>
<a name="l00007"></a>00007 <span class="comment">  version 2 of the License, or (at your option) any later version.</span>
<a name="l00008"></a>00008 <span class="comment"></span>
<a name="l00009"></a>00009 <span class="comment">  This library is distributed in the hope that it will be useful,</span>
<a name="l00010"></a>00010 <span class="comment">  but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00011"></a>00011 <span class="comment">  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU</span>
<a name="l00012"></a>00012 <span class="comment">  Library General Public License for more details.</span>
<a name="l00013"></a>00013 <span class="comment"></span>
<a name="l00014"></a>00014 <span class="comment">  You should have received a copy of the GNU Library General Public</span>
<a name="l00015"></a>00015 <span class="comment">  License along with this library; if not, write to the Free</span>
<a name="l00016"></a>00016 <span class="comment">  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.</span>
<a name="l00017"></a>00017 <span class="comment">*/</span>
<a name="l00018"></a>00018 
<a name="l00019"></a>00019 <span class="preprocessor">#ifndef __CS_CSUTIL_THREADING_THREAD_H__</span>
<a name="l00020"></a>00020 <span class="preprocessor"></span><span class="preprocessor">#define __CS_CSUTIL_THREADING_THREAD_H__</span>
<a name="l00021"></a>00021 <span class="preprocessor"></span>
<a name="l00022"></a>00022 <span class="preprocessor">#include "csutil/noncopyable.h"</span>
<a name="l00023"></a>00023 <span class="preprocessor">#include "<a class="code" href="refcount_8h.html" title="Reference Counting Interface.">csutil/refcount.h</a>"</span>
<a name="l00024"></a>00024 <span class="preprocessor">#include "<a class="code" href="refarr_8h.html" title="Smart Pointer array.">csutil/refarr.h</a>"</span>
<a name="l00025"></a>00025 
<a name="l00026"></a>00026 <span class="preprocessor">#include "<a class="code" href="mutex_8h.html" title="Mutual-exclusion object.">csutil/threading/mutex.h</a>"</span>
<a name="l00027"></a>00027 
<a name="l00028"></a>00028 <span class="keyword">namespace </span>CS
<a name="l00029"></a>00029 {
<a name="l00030"></a>00030 <span class="keyword">namespace </span>Threading
<a name="l00031"></a>00031 {
<a name="l00038"></a><a class="code" href="namespaceCS_1_1Threading.html#785461563cc5ad5580177ae429bbb239">00038</a>   <span class="keyword">enum</span> <a class="code" href="namespaceCS_1_1Threading.html#785461563cc5ad5580177ae429bbb239" title="Priority values indicate how frequently a thread runs compared to other threads.">ThreadPriority</a>
<a name="l00039"></a>00039   {
<a name="l00041"></a><a class="code" href="namespaceCS_1_1Threading.html#785461563cc5ad5580177ae429bbb2398186b75ecc38a7b0c8aaf34a9809bd24">00041</a>     <a class="code" href="namespaceCS_1_1Threading.html#785461563cc5ad5580177ae429bbb2398186b75ecc38a7b0c8aaf34a9809bd24" title="Reduced thread priority. Useful for background tasks.">THREAD_PRIO_LOW</a>,
<a name="l00042"></a>00042 
<a name="l00044"></a><a class="code" href="namespaceCS_1_1Threading.html#785461563cc5ad5580177ae429bbb239c39edebc95da17ce08b6a8c1234177ae">00044</a>     <a class="code" href="namespaceCS_1_1Threading.html#785461563cc5ad5580177ae429bbb239c39edebc95da17ce08b6a8c1234177ae" title="Normal thread priority.">THREAD_PRIO_NORMAL</a>,
<a name="l00045"></a>00045 
<a name="l00050"></a><a class="code" href="namespaceCS_1_1Threading.html#785461563cc5ad5580177ae429bbb239c2ad92a96167409696c9ad05c77c5706">00050</a>     <a class="code" href="namespaceCS_1_1Threading.html#785461563cc5ad5580177ae429bbb239c2ad92a96167409696c9ad05c77c5706" title="Increased thread priority.">THREAD_PRIO_HIGH</a>
<a name="l00051"></a>00051   };
<a name="l00052"></a>00052 
<a name="l00058"></a><a class="code" href="classCS_1_1Threading_1_1Runnable.html">00058</a>   <span class="keyword">class </span><a class="code" href="classCS_1_1Threading_1_1Runnable.html" title="Abstract base class for objects to be run in threads.">Runnable</a> : <span class="keyword">public</span> <a class="code" href="classcsRefCount.html" title="This is a class which provides basic reference-counting semantics.">csRefCount</a>, <span class="keyword">private</span> CS::<a class="code" href="classCS_1_1Implementation_1_1NonCopyable__.html" title="Base-class which ensures that derived classes are not copy-constructible or assignable...">NonCopyable</a>
<a name="l00059"></a>00059   {
<a name="l00060"></a>00060   <span class="keyword">public</span>:
<a name="l00066"></a>00066     <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classCS_1_1Threading_1_1Runnable.html#6a8cbf3365f61f29a7a5eb22fa202ad2" title="Main method for thread.">Run</a> () = 0;
<a name="l00067"></a>00067   };
<a name="l00068"></a>00068 
<a name="l00070"></a><a class="code" href="namespaceCS_1_1Threading.html#040b603ebb091edd68db17f7b4f1f988">00070</a>   <span class="keyword">typedef</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="namespaceCS_1_1Threading.html#040b603ebb091edd68db17f7b4f1f988" title="OS specific thread identifier.">ThreadID</a>;
<a name="l00071"></a>00071 
<a name="l00072"></a>00072 }
<a name="l00073"></a>00073 }
<a name="l00074"></a>00074 
<a name="l00075"></a>00075 <span class="comment">// Include implementation specific versions</span>
<a name="l00076"></a>00076 <span class="preprocessor">#if defined(CS_PLATFORM_WIN32)</span>
<a name="l00077"></a>00077 <span class="preprocessor"></span><span class="preprocessor"># include "csutil/threading/win32_thread.h"</span>
<a name="l00078"></a>00078 <span class="preprocessor">#elif defined(CS_PLATFORM_UNIX) || \</span>
<a name="l00079"></a>00079 <span class="preprocessor">  defined(CS_PLATFORM_MACOSX)</span>
<a name="l00080"></a>00080 <span class="preprocessor"></span><span class="preprocessor"># include "csutil/threading/pthread_thread.h"</span>
<a name="l00081"></a>00081 <span class="preprocessor">#else</span>
<a name="l00082"></a>00082 <span class="preprocessor"></span><span class="preprocessor">#error "No threading implementation for your platform"</span>
<a name="l00083"></a>00083 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
<a name="l00084"></a>00084 <span class="preprocessor"></span>
<a name="l00085"></a>00085 
<a name="l00086"></a>00086 <span class="keyword">namespace </span>CS
<a name="l00087"></a>00087 {
<a name="l00088"></a>00088 <span class="keyword">namespace </span>Threading
<a name="l00089"></a>00089 {
<a name="l00090"></a>00090   
<a name="l00091"></a>00091   
<a name="l00096"></a><a class="code" href="classCS_1_1Threading_1_1Thread.html">00096</a>   <span class="keyword">class </span><a class="code" href="classCS_1_1Threading_1_1Thread.html" title="Object representing a separate execution thread.">Thread</a> : <span class="keyword">public</span> <a class="code" href="classcsRefCount.html" title="This is a class which provides basic reference-counting semantics.">csRefCount</a>, <span class="keyword">private</span> CS::<a class="code" href="classCS_1_1Implementation_1_1NonCopyable__.html" title="Base-class which ensures that derived classes are not copy-constructible or assignable...">NonCopyable</a>, 
<a name="l00097"></a>00097     <span class="keyword">private</span> Implementation::ThreadBase
<a name="l00098"></a>00098   {
<a name="l00099"></a>00099   <span class="keyword">public</span>:
<a name="l00100"></a>00100 
<a name="l00107"></a><a class="code" href="classCS_1_1Threading_1_1Thread.html#b40af15a1d2a0ecd379cd0b9b54e31cb">00107</a>     <a class="code" href="classCS_1_1Threading_1_1Thread.html#b40af15a1d2a0ecd379cd0b9b54e31cb" title="Initialize a new thread object.">Thread</a> (<a class="code" href="classCS_1_1Threading_1_1Runnable.html" title="Abstract base class for objects to be run in threads.">Runnable</a>* runnable, <span class="keywordtype">bool</span> start = <span class="keyword">false</span>)
<a name="l00108"></a>00108       : ThreadBase (runnable)
<a name="l00109"></a>00109     {
<a name="l00110"></a>00110       <span class="keywordflow">if</span> (start)
<a name="l00111"></a>00111         <a class="code" href="classCS_1_1Threading_1_1Thread.html#4f8faa0dc54ad247f46664759bc20ec8" title="Start the thread.">Start</a> ();
<a name="l00112"></a>00112     }
<a name="l00113"></a>00113 
<a name="l00119"></a><a class="code" href="classCS_1_1Threading_1_1Thread.html#e89625f13d8408f860470aa8b8d1fbc1">00119</a>     <a class="code" href="classCS_1_1Threading_1_1Thread.html#b40af15a1d2a0ecd379cd0b9b54e31cb" title="Initialize a new thread object.">Thread</a> (<a class="code" href="classCS_1_1Threading_1_1Runnable.html" title="Abstract base class for objects to be run in threads.">Runnable</a>* runnable, <a class="code" href="namespaceCS_1_1Threading.html#785461563cc5ad5580177ae429bbb239" title="Priority values indicate how frequently a thread runs compared to other threads.">ThreadPriority</a> prio)
<a name="l00120"></a>00120       : ThreadBase (runnable)
<a name="l00121"></a>00121     {
<a name="l00122"></a>00122       <a class="code" href="classCS_1_1Threading_1_1Thread.html#eedcf5ea513846f6df99d270e82e52e1" title="Set the current execution priority of this thread.">SetPriority</a> (prio);
<a name="l00123"></a>00123     }
<a name="l00124"></a>00124 
<a name="l00132"></a><a class="code" href="classCS_1_1Threading_1_1Thread.html#ce9e07c95633cf5c6ea2853f2c8a5af5">00132</a>     <a class="code" href="classCS_1_1Threading_1_1Thread.html#b40af15a1d2a0ecd379cd0b9b54e31cb" title="Initialize a new thread object.">Thread</a> (<a class="code" href="classCS_1_1Threading_1_1Runnable.html" title="Abstract base class for objects to be run in threads.">Runnable</a>* runnable, <span class="keywordtype">bool</span> start, <a class="code" href="namespaceCS_1_1Threading.html#785461563cc5ad5580177ae429bbb239" title="Priority values indicate how frequently a thread runs compared to other threads.">ThreadPriority</a> prio)
<a name="l00133"></a>00133       : ThreadBase (runnable)
<a name="l00134"></a>00134     {
<a name="l00135"></a>00135       <a class="code" href="classCS_1_1Threading_1_1Thread.html#eedcf5ea513846f6df99d270e82e52e1" title="Set the current execution priority of this thread.">SetPriority</a> (prio);
<a name="l00136"></a>00136 
<a name="l00137"></a>00137       <span class="keywordflow">if</span> (start)
<a name="l00138"></a>00138         <a class="code" href="classCS_1_1Threading_1_1Thread.html#4f8faa0dc54ad247f46664759bc20ec8" title="Start the thread.">Start</a> ();
<a name="l00139"></a>00139     }
<a name="l00140"></a>00140   
<a name="l00141"></a><a class="code" href="classCS_1_1Threading_1_1Thread.html#3c82cd91989c75e641e0a18c89600df5">00141</a>     <a class="code" href="classCS_1_1Threading_1_1Thread.html#3c82cd91989c75e641e0a18c89600df5">~Thread</a> ()
<a name="l00142"></a>00142     {
<a name="l00143"></a>00143       <span class="keywordflow">if</span> (<a class="code" href="classCS_1_1Threading_1_1Thread.html#3c1a385d800c5f8e98e184f7c53d6681" title="Return whether thread is running or not.">IsRunning</a> ())
<a name="l00144"></a>00144         <a class="code" href="classCS_1_1Threading_1_1Thread.html#55ac5876b0b8814493ec2886618ce2ba" title="Unmercifully stop the thread as soon as possible.">Stop</a> ();
<a name="l00145"></a>00145     }
<a name="l00146"></a>00146 
<a name="l00150"></a><a class="code" href="classCS_1_1Threading_1_1Thread.html#4f8faa0dc54ad247f46664759bc20ec8">00150</a>     <span class="keywordtype">void</span> <a class="code" href="classCS_1_1Threading_1_1Thread.html#4f8faa0dc54ad247f46664759bc20ec8" title="Start the thread.">Start</a> ()
<a name="l00151"></a>00151     {
<a name="l00152"></a>00152       ThreadBase::Start ();
<a name="l00153"></a>00153     }
<a name="l00154"></a>00154 
<a name="l00163"></a><a class="code" href="classCS_1_1Threading_1_1Thread.html#55ac5876b0b8814493ec2886618ce2ba">00163</a>     <span class="keywordtype">void</span> <a class="code" href="classCS_1_1Threading_1_1Thread.html#55ac5876b0b8814493ec2886618ce2ba" title="Unmercifully stop the thread as soon as possible.">Stop</a> ()
<a name="l00164"></a>00164     {
<a name="l00165"></a>00165       ThreadBase::Stop ();
<a name="l00166"></a>00166     }
<a name="l00167"></a>00167 
<a name="l00171"></a><a class="code" href="classCS_1_1Threading_1_1Thread.html#3c1a385d800c5f8e98e184f7c53d6681">00171</a>     <span class="keywordtype">bool</span> <a class="code" href="classCS_1_1Threading_1_1Thread.html#3c1a385d800c5f8e98e184f7c53d6681" title="Return whether thread is running or not.">IsRunning</a> ()<span class="keyword"> const</span>
<a name="l00172"></a>00172 <span class="keyword">    </span>{
<a name="l00173"></a>00173       <span class="keywordflow">return</span> ThreadBase::IsRunning ();
<a name="l00174"></a>00174     }
<a name="l00175"></a>00175 
<a name="l00183"></a><a class="code" href="classCS_1_1Threading_1_1Thread.html#eedcf5ea513846f6df99d270e82e52e1">00183</a>     <span class="keywordtype">bool</span> <a class="code" href="classCS_1_1Threading_1_1Thread.html#eedcf5ea513846f6df99d270e82e52e1" title="Set the current execution priority of this thread.">SetPriority</a> (<a class="code" href="namespaceCS_1_1Threading.html#785461563cc5ad5580177ae429bbb239" title="Priority values indicate how frequently a thread runs compared to other threads.">ThreadPriority</a> prio)
<a name="l00184"></a>00184     {      
<a name="l00185"></a>00185       <span class="keywordflow">return</span> ThreadBase::SetPriority (prio);          
<a name="l00186"></a>00186     }
<a name="l00187"></a>00187 
<a name="l00191"></a><a class="code" href="classCS_1_1Threading_1_1Thread.html#017309d6afe89b0aca82f4e2b4d1a380">00191</a>     <a class="code" href="namespaceCS_1_1Threading.html#785461563cc5ad5580177ae429bbb239" title="Priority values indicate how frequently a thread runs compared to other threads.">ThreadPriority</a> <a class="code" href="classCS_1_1Threading_1_1Thread.html#017309d6afe89b0aca82f4e2b4d1a380" title="Get current execution priority for this thread.">GetPriority</a> ()<span class="keyword"> const</span>
<a name="l00192"></a>00192 <span class="keyword">    </span>{
<a name="l00193"></a>00193       <span class="keywordflow">return</span> ThreadBase::GetPriority ();
<a name="l00194"></a>00194     }
<a name="l00195"></a>00195 
<a name="l00200"></a><a class="code" href="classCS_1_1Threading_1_1Thread.html#d3188de0c90be2d4f700a76c638c78f1">00200</a>     <span class="keywordtype">void</span> <a class="code" href="classCS_1_1Threading_1_1Thread.html#d3188de0c90be2d4f700a76c638c78f1" title="Wait for thread to finish its execution.">Wait</a> ()<span class="keyword"> const</span>
<a name="l00201"></a>00201 <span class="keyword">    </span>{
<a name="l00202"></a>00202       ThreadBase::Wait ();
<a name="l00203"></a>00203     }
<a name="l00204"></a>00204 
<a name="l00211"></a><a class="code" href="classCS_1_1Threading_1_1Thread.html#e4677e099d747e76715e22a5cb24e7bd">00211</a>     <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classCS_1_1Threading_1_1Thread.html#e4677e099d747e76715e22a5cb24e7bd" title="Yield Thread frees CPU time if nothing to do.">Yield</a> ()
<a name="l00212"></a>00212     {
<a name="l00213"></a>00213       ThreadBase::Yield ();
<a name="l00214"></a>00214     }
<a name="l00215"></a>00215 
<a name="l00221"></a><a class="code" href="classCS_1_1Threading_1_1Thread.html#b28b1025f19b6750d3d6ca12fc528be6">00221</a>     <span class="keyword">static</span> <a class="code" href="namespaceCS_1_1Threading.html#040b603ebb091edd68db17f7b4f1f988" title="OS specific thread identifier.">ThreadID</a> <a class="code" href="classCS_1_1Threading_1_1Thread.html#b28b1025f19b6750d3d6ca12fc528be6" title="Get an OS specific thread identifier.">GetThreadID</a> ()
<a name="l00222"></a>00222     {
<a name="l00223"></a>00223       <span class="keywordflow">return</span> ThreadBase::GetThreadID ();
<a name="l00224"></a>00224     }
<a name="l00225"></a>00225   };
<a name="l00226"></a>00226 
<a name="l00227"></a>00227 
<a name="l00231"></a><a class="code" href="classCS_1_1Threading_1_1ThreadGroup.html">00231</a>   <span class="keyword">class </span><a class="code" href="classCS_1_1Threading_1_1ThreadGroup.html" title="A group of threads handled as one unit.">ThreadGroup</a> : <span class="keyword">private</span> CS::<a class="code" href="classCS_1_1Implementation_1_1NonCopyable__.html" title="Base-class which ensures that derived classes are not copy-constructible or assignable...">NonCopyable</a>
<a name="l00232"></a>00232   {
<a name="l00233"></a>00233   <span class="keyword">public</span>:
<a name="l00234"></a>00234 
<a name="l00240"></a><a class="code" href="classCS_1_1Threading_1_1ThreadGroup.html#ba2a15329d6f104d1d7b5c20be3ea6ef">00240</a>     <span class="keywordtype">void</span> <a class="code" href="classCS_1_1Threading_1_1ThreadGroup.html#ba2a15329d6f104d1d7b5c20be3ea6ef" title="Add a thread to the group.">Add</a> (<a class="code" href="classCS_1_1Threading_1_1Thread.html" title="Object representing a separate execution thread.">Thread</a>* thread)
<a name="l00241"></a>00241     {
<a name="l00242"></a>00242       <a class="code" href="classCS_1_1Threading_1_1ScopedLock.html" title="This is a utility class for locking a Mutex.">ScopedLock&lt;Mutex&gt;</a> lock (mutex);
<a name="l00243"></a>00243       allThreads.PushSmart (thread);
<a name="l00244"></a>00244     }
<a name="l00245"></a>00245 
<a name="l00249"></a><a class="code" href="classCS_1_1Threading_1_1ThreadGroup.html#c699e578b17ae9b70cc58d614bbea469">00249</a>     <span class="keywordtype">void</span> <a class="code" href="classCS_1_1Threading_1_1ThreadGroup.html#c699e578b17ae9b70cc58d614bbea469" title="Remove thread from group.">Remove</a> (<a class="code" href="classCS_1_1Threading_1_1Thread.html" title="Object representing a separate execution thread.">Thread</a>* thread)
<a name="l00250"></a>00250     {
<a name="l00251"></a>00251       <a class="code" href="classCS_1_1Threading_1_1ScopedLock.html" title="This is a utility class for locking a Mutex.">ScopedLock&lt;Mutex&gt;</a> lock (mutex);
<a name="l00252"></a>00252       allThreads.Delete (thread);
<a name="l00253"></a>00253     }
<a name="l00254"></a>00254     
<a name="l00258"></a><a class="code" href="classCS_1_1Threading_1_1ThreadGroup.html#0979401738730891e7248d8251ebf147">00258</a>     <a class="code" href="classCS_1_1Threading_1_1Thread.html" title="Object representing a separate execution thread.">Thread</a>* <a class="code" href="classCS_1_1Threading_1_1ThreadGroup.html#0979401738730891e7248d8251ebf147" title="Get thread with specific index.">GetThread</a> (<span class="keywordtype">size_t</span> index)<span class="keyword"> const</span>
<a name="l00259"></a>00259 <span class="keyword">    </span>{
<a name="l00260"></a>00260       <a class="code" href="classCS_1_1Threading_1_1ScopedLock.html" title="This is a utility class for locking a Mutex.">ScopedLock&lt;Mutex&gt;</a> lock (mutex);
<a name="l00261"></a>00261       <span class="keywordflow">return</span> allThreads.Get (index);
<a name="l00262"></a>00262     }
<a name="l00263"></a>00263     
<a name="l00267"></a><a class="code" href="classCS_1_1Threading_1_1ThreadGroup.html#3613548b3e848eee2c2d64cf3184c6c6">00267</a>     <span class="keywordtype">size_t</span> <a class="code" href="classCS_1_1Threading_1_1ThreadGroup.html#3613548b3e848eee2c2d64cf3184c6c6" title="Get number of threads in group.">GetSize</a> ()<span class="keyword"> const</span>
<a name="l00268"></a>00268 <span class="keyword">    </span>{
<a name="l00269"></a>00269       <span class="keywordflow">return</span> allThreads.GetSize ();
<a name="l00270"></a>00270     }
<a name="l00271"></a>00271 
<a name="l00276"></a><a class="code" href="classCS_1_1Threading_1_1ThreadGroup.html#8d8e8e8037bb39e9c93b11d1b8c10004">00276</a>     <span class="keywordtype">void</span> <a class="code" href="classCS_1_1Threading_1_1ThreadGroup.html#8d8e8e8037bb39e9c93b11d1b8c10004" title="Start all threads in the group.">StartAll</a> ()
<a name="l00277"></a>00277     {
<a name="l00278"></a>00278       <a class="code" href="classCS_1_1Threading_1_1ScopedLock.html" title="This is a utility class for locking a Mutex.">ScopedLock&lt;Mutex&gt;</a> lock (mutex);
<a name="l00279"></a>00279 
<a name="l00280"></a>00280       <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i = 0; i &lt; allThreads.GetSize (); ++i)
<a name="l00281"></a>00281       {
<a name="l00282"></a>00282         allThreads[i]-&gt;Start ();
<a name="l00283"></a>00283       }
<a name="l00284"></a>00284     }
<a name="l00285"></a>00285 
<a name="l00290"></a><a class="code" href="classCS_1_1Threading_1_1ThreadGroup.html#934a90c25ab8e45c421f0a4a14bd0828">00290</a>     <span class="keywordtype">void</span> <a class="code" href="classCS_1_1Threading_1_1ThreadGroup.html#934a90c25ab8e45c421f0a4a14bd0828" title="Stop all threads in the group.">StopAll</a> ()
<a name="l00291"></a>00291     {
<a name="l00292"></a>00292       <a class="code" href="classCS_1_1Threading_1_1ScopedLock.html" title="This is a utility class for locking a Mutex.">ScopedLock&lt;Mutex&gt;</a> lock (mutex);
<a name="l00293"></a>00293 
<a name="l00294"></a>00294       <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i = 0; i &lt; allThreads.GetSize (); ++i)
<a name="l00295"></a>00295       {
<a name="l00296"></a>00296         allThreads[i]-&gt;Stop ();
<a name="l00297"></a>00297       }
<a name="l00298"></a>00298     }
<a name="l00299"></a>00299 
<a name="l00304"></a><a class="code" href="classCS_1_1Threading_1_1ThreadGroup.html#c440785265a585a6fd38c3ac7b9413de">00304</a>     <span class="keywordtype">void</span> <a class="code" href="classCS_1_1Threading_1_1ThreadGroup.html#c440785265a585a6fd38c3ac7b9413de" title="Wait for all threads in the group.">WaitAll</a> ()
<a name="l00305"></a>00305     {
<a name="l00306"></a>00306       <a class="code" href="classCS_1_1Threading_1_1ScopedLock.html" title="This is a utility class for locking a Mutex.">ScopedLock&lt;Mutex&gt;</a> lock (mutex);
<a name="l00307"></a>00307       
<a name="l00308"></a>00308       <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i = 0; i &lt; allThreads.GetSize (); ++i)
<a name="l00309"></a>00309       {
<a name="l00310"></a>00310         allThreads[i]-&gt;Wait ();
<a name="l00311"></a>00311       }
<a name="l00312"></a>00312     }
<a name="l00313"></a>00313 
<a name="l00314"></a>00314   <span class="keyword">private</span>:
<a name="l00315"></a>00315     <a class="code" href="classcsRefArray.html" title="An array of smart pointers.">csRefArray&lt;Thread&gt;</a> allThreads;
<a name="l00316"></a>00316     <span class="keyword">mutable</span> <a class="code" href="classCS_1_1Threading_1_1MutexImpl.html" title="General mutex class.">Mutex</a> mutex;
<a name="l00317"></a>00317   };
<a name="l00318"></a>00318 }
<a name="l00319"></a>00319 }
<a name="l00320"></a>00320 
<a name="l00321"></a>00321 
<a name="l00322"></a>00322 
<a name="l00323"></a>00323 <span class="preprocessor">#endif</span>
</pre></div><hr size="1"><address><small>Generated for Crystal Space 1.2.1 by 
<a href="http://www.doxygen.org/index.html">doxygen</a> 1.5.3 
</small></address> </div></body> </html>