#include <BasicThread.h>
Inheritance diagram for BasicThread:
Public Member Functions | |
BasicThread () | |
BasicThread (BasicFunctorBase *functor) | |
BasicThread (void *(*startRoutine)(void *)) | |
virtual | ~BasicThread () |
virtual void | run () |
This virtual function should be overriden by inheriting process. | |
bool | start () |
Starts the thread. | |
void | stop () |
Requests the thread stop via the shutdown variable. | |
bool | join () |
This causes the calling thread of execution to block until the thread of this object exits. | |
bool | cancel () |
bool | detach () |
void * | getData () |
void | setData (void *data) |
void | setRunning (bool x) |
This function is not always necessary. | |
bool | isRunning () |
bool | shouldShutdown () |
This function should be called from the thread itself to determine if shutdown has been requested. | |
Static Public Member Functions | |
void | testCancel () |
Protected Attributes | |
bool | shutdown |
bool | running |
Private Member Functions | |
virtual void | onExit () |
This virtual function can be overriden by inheriting classes which would like to do some extra processing on thread exit. | |
virtual void | onEntrance () |
This virtual function can be overriden by inheriting classes which would like to do some extra processing before thread startup. | |
void | init () |
This function does initializations common to all the constructors. | |
Static Private Member Functions | |
void * | starter (void *me) |
This static function should never be called directly. | |
Private Attributes | |
pthread_t | thread |
pthread_attr_t | attr |
BasicFunctorBase * | functor |
void *(* | startRoutine )(void *) |
void * | data |
The user has the ability to set a data variable which will be passed to the user function. This void * is set to point to the BasicThread object itself by default. This gives the user the ability to communicate data to the thread without using global data.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
This function does initializations common to all the constructors. It takes in a special consideration for SunOS to circumvent a bug that occurs when more then one thread is started. |
|
|
|
This causes the calling thread of execution to block until the thread of this object exits.
|
|
This virtual function can be overriden by inheriting classes which would like to do some extra processing before thread startup. It is called by BasicThread just before either the overriden run() or startRoutine function is called. |
|
This virtual function can be overriden by inheriting classes which would like to do some extra processing on thread exit. It is called by BasicThread just after either the overriden run() or startRoutine function returns. |
|
This virtual function should be overriden by inheriting process. This function is called by BasicThread from within the new thread of execution after start() is called. |
|
|
|
This function is not always necessary. When a thread starts up it will automaticly set running to true. However if you are starting a group of threads this function is useful so the starting threads don't mistakenly think a thread has exited when it is actually just starting up. Before starting any threads in the group they can all be set to started. This gives the alusion that all the threads started at once.
|
|
This function should be called from the thread itself to determine if shutdown has been requested. If a thread doesn't monitor this variable stop() will not work!
|
|
Starts the thread.
|
|
This static function should never be called directly. It is used by pthreads in starting the thread.
|
|
Requests the thread stop via the shutdown variable. There is however no guarantee that the thread will actually stop. The running thread must check the shutdown variable and decide to stop. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|