FThread wraps threads for each platform. More...
#include <fthread.h>
Public Member Functions | |
FThread (const char8 *name="FThread") | |
Thread constructor. | |
virtual | ~FThread () |
Destructor. | |
void | run () |
Starts the thread. | |
void | terminate () |
Terminates the thread. | |
bool | isRunning () |
Checks if thread is (still) running. | |
bool | waitDead (int32 timeOut) |
Waits for thread dead. | |
virtual bool | setPriority (int32 priority) |
Sets thread priority. | |
int32 | getPriority () |
Gets the current priority of this thread. | |
virtual void | cleanup () |
Override this method for any cleanup code. | |
virtual uint32 | entry () |
Override this method for the thread loop. | |
const String & | getName () const |
Gets the name of this thread. | |
void * | getThreadReference () const |
Gets the reference of this thread. | |
bool | setCpuAffinity (int32 cpu) |
Sets cpu affinity. | |
bool | isInThreadContext () const |
Check if current execution is in the thread context. | |
Static Public Member Functions | |
static void | setSpy (IThreadSpy *spy) |
Sets a thread spy which gets informed about new or removed threads. | |
Protected Attributes | |
int32 | priority |
Priority of thread. | |
int32 | cpu |
Cpu used by this thread. | |
bool | running |
Running state. | |
Static Protected Attributes | |
static IThreadSpy * | gSpy = 0 |
Global thread spy. |
FThread wraps threads for each platform.
termination is best with waitDead and flags in the run loop....
FThread | ( | const char8 * | name = "FThread" |
) |
Thread constructor.
name | the name of the thread (can be seen in debugger) |
~FThread | ( | ) | [virtual] |
Destructor.
void run | ( | ) |
Starts the thread.
void terminate | ( | ) |
Terminates the thread.
bool isRunning | ( | ) | [inline] |
Checks if thread is (still) running.
bool waitDead | ( | int32 | timeOut | ) |
Waits for thread dead.
This is the best to terminate this thread.
timeOut | timeout in ms |
bool setPriority | ( | int32 | prio | ) | [virtual] |
Sets thread priority.
To boost priority a little bit permit a temporary raised task priority .
Permit temporary raise of task priority.
priority | thread priority, see FThreadPriority |
.... taskPriority defaults to static taskPriority if not set
int32 getPriority | ( | ) | [inline] |
Gets the current priority of this thread.
void cleanup | ( | ) | [virtual] |
Override this method for any cleanup code.
uint32 entry | ( | ) | [virtual] |
Override this method for the thread loop.
const String& getName | ( | ) | const [inline] |
Gets the name of this thread.
void * getThreadReference | ( | ) | const |
Gets the reference of this thread.
bool setCpuAffinity | ( | int32 | cpu | ) |
Sets cpu affinity.
Binds thread to a specific cpu.
cpu | cpu id |
bool isInThreadContext | ( | ) | const |
Check if current execution is in the thread context.
void setSpy | ( | IThreadSpy * | spy | ) | [static] |
Sets a thread spy which gets informed about new or removed threads.
There is only one spy allowed and it works without reference couting.
spy | a thread spy |
int32 priority [protected] |
Priority of thread.
int32 cpu [protected] |
Cpu used by this thread.
bool running [protected] |
Running state.
IThreadSpy * gSpy = 0 [static, protected] |
Global thread spy.