Inherited by YGP::OThread< T >.
Public Types | |
typedef void *(* | THREAD_FUNCTION )(void *) |
Public Member Functions | |
virtual | ~Thread () |
void * | getArgs () const |
unsigned long | getID () const |
Static Public Member Functions | |
static Thread * | create (THREAD_FUNCTION fnc, void *pArgs) throw (YGP::ExecError) |
static Thread * | create2 (THREAD_FUNCTION fnc, void *pArgs) throw (YGP::ExecError) |
static unsigned long | currentID () |
Protected Member Functions | |
Thread () | |
Thread (THREAD_FUNCTION fnc, void *pArgs) throw (YGP::ExecError) | |
void | ret (void *rc) const |
void | init (THREAD_FUNCTION fnc, void *pArgs) throw (YGP::ExecError) |
Protected Attributes | |
void * | pArgs_ |
Termination of the thread | |
void | allowCancelation (bool allow=true) |
void | cancel () |
void | isToCancel () const |
static void * | waitForThread (const Thread &id) |
static void * | waitForThread (unsigned long threadID) |
There are two create-functions: The first calles the passed function with the parameters directly; the second passed a pointer to the created thread and enables to get the paramters with its getArgs-method. This enables controlling the thread.
typedef void*(* YGP::Thread::THREAD_FUNCTION)(void *) |
Declaration of prototype of callback.
YGP::Thread::~Thread | ( | ) | [virtual] |
Destructor.
YGP::Thread::Thread | ( | ) | [protected] |
Defaultconstructor; create the object but no actual thread.
YGP::Thread::Thread | ( | THREAD_FUNCTION | fnc, | |
void * | pArgs | |||
) | throw (YGP::ExecError) [protected] |
Constructor; Create object and a thread and passes pArgs as arguments.
fnc | Function to be called in the thread | |
pArgs | Pointer to argument(s) |
YGP::ExecError | describing the error |
void YGP::Thread::allowCancelation | ( | bool | allow = true |
) |
Terminates the thread.
void YGP::Thread::cancel | ( | ) |
Terminates the thread.
static Thread* YGP::Thread::create | ( | THREAD_FUNCTION | fnc, | |
void * | pArgs | |||
) | throw (YGP::ExecError) [inline, static] |
Creates a new thread; the argument is passed directly to the thread function.
fnc | Thread function to execute | |
pArgs | Argument to the thread |
static Thread* YGP::Thread::create2 | ( | THREAD_FUNCTION | fnc, | |
void * | pArgs | |||
) | throw (YGP::ExecError) [inline, static] |
Creates a new thread; a pointer to the thread ID is passed to the thread function.
fnc | Thread function to execute | |
pArgs | Argument to the thread |
static unsigned long YGP::Thread::currentID | ( | ) | [inline, static] |
Get the ID of the currently running thread.
void* YGP::Thread::getArgs | ( | ) | const [inline] |
Returns the argument passed to the thread.
unsigned long YGP::Thread::getID | ( | ) | const [inline] |
Get the ID of the thread.
void YGP::Thread::init | ( | THREAD_FUNCTION | fnc, | |
void * | pArgs | |||
) | throw (YGP::ExecError) [protected] |
Creates the actual thread from the passed function.
fnc | Function to be called in the thread | |
pArgs | Pointer to parameters |
YGP::ExecError | describing the error |
void YGP::Thread::isToCancel | ( | ) | const |
Checks if the thread should be canceled and does so, if yes.
void YGP::Thread::ret | ( | void * | rc | ) | const [protected] |
Sets the return value for the thread.
rc | Returncode |
void * YGP::Thread::waitForThread | ( | unsigned long | id | ) | [static] |
Waits for the thread with the passed ID to terminate.
id | Thread to wait for |
void * YGP::Thread::waitForThread | ( | const Thread & | id | ) | [static] |
Waits for the passed thread to terminate.
id | Thread to wait for |
void* YGP::Thread::pArgs_ [protected] |
Pointer to (array of) arguments to the thread.