#include <Synchronization.h>
Inheritance diagram for rwil::Thread::
Public Methods | |
Thread () | |
Constructs a thread. More... | |
virtual | ~Thread () |
Destructs a thread. More... | |
void | Start () |
Start the thread. More... | |
void | Go () |
Begins the execution of the function in THIS thread. More... | |
void | Join () |
Join the thread. More... | |
Protected Methods | |
void | Yield () |
Yield timeslice. More... | |
virtual void | Function ()=0 |
This is the function that implements the thread of execution. More... | |
Protected Attributes | |
Mutex | m_mutex |
Mutex used to ensure that this is only executing one thread of execution. More... |
This class encapsulates a single thread of execution. Call Start() to start the thread.
Definition at line 160 of file Synchronization.h.
|
Constructs a thread. Essentially does nothing. Definition at line 199 of file Synchronization.cpp.
00199 {} |
|
Destructs a thread. Ensures that the mutex is not held anymore. Definition at line 200 of file Synchronization.cpp. References m_mutex.
00201 { 00202 m_mutex.Release(); 00203 } |
|
This is the function that implements the thread of execution. This function must be implemented by all deriving classes. Reimplemented in rwil::RWIL. Referenced by Go(). |
|
Begins the execution of the function in THIS thread. This function is used internally to start execution in the new thread of execution. Definition at line 214 of file Synchronization.cpp. References Function(), and m_mutex.
|
|
Join the thread. Wait for the thread to finish. Definition at line 229 of file Synchronization.cpp. References NULL.
00230 { 00231 if(pthread_join(m_threadHandle, NULL)) 00232 assert(0); 00233 } |
|
Start the thread. Begins the thread of execution. Ensures that this thread does not start again until this one dies. Definition at line 204 of file Synchronization.cpp.
|
|
Yield timeslice. This should be used inside of the thread instead of something os-dependent. Definition at line 220 of file Synchronization.cpp.
00221 { 00222 #ifdef _WIN32 00223 Sleep(0); 00224 #endif 00225 #ifdef LINUX 00226 sched_yield(); 00227 #endif 00228 } |
|
Mutex used to ensure that this is only executing one thread of execution.
Reimplemented in rwil::RWIL. Definition at line 201 of file Synchronization.h. |