#include <Runnable.h>
Inheritance diagram for util::Thread:

A thread works in the same environment as its parent. Mutexes must be used to protect access to shared variables.
Public Methods | |
| Thread (int detachState=PTHREAD_CREATE_JOINABLE) | |
| Create a new thread. | |
| ~Thread () | |
| void | start (void) throw (RunException&) |
| Start the thread. | |
| void | join (void) throw (RunException&) |
| Wait this thread to die. | |
| void | detach (void) throw (RunException&) |
| Detach this thread from its parent so that no one needs to "join" it to release the reserved resources. | |
| void | kill (int signal=SIGKILL) throw (RunException&) |
| Send a signal to a thread. | |
| void | addThreadListener (ThreadListener *l) |
| Add a listener that gets notified when the thread has finished its execution. | |
| void | removeThreadListener (ThreadListener *l) |
| Remove a listener. | |
| bool | isRunning (void) const |
| Check if the thread is currently running. | |
Protected Methods | |
| void | sleep (double secs) throw (RunException&) |
| Suspend the execution of this thread for the specified number of seconds. | |
| void | sleep (unsigned int secs, unsigned int nanosecs) throw (RunException&) |
| Suspend the execution of this thread for the specified number of seconds and nanoseconds. | |
Protected Attributes | |
| bool | _bRunning |
| A flag that indicates whether the thread is currently executing or not. | |
|
|
Create a new thread.
|
|
|
Add a listener that gets notified when the thread has finished its execution.
|
|
|
Check if the thread is currently running. Note that this method may return false when the thread is just being started. One should not rely on the return value exclusively when starting a thread, but catch the RunException& thrown by start() instead.
|
|
|
Wait this thread to die. The calling thread will be blocked until this thread exists. |
|
|
Send a signal to a thread. The default signal to be sent is SIGKILL which - by default - causes the thread to exit. One must ensure that the resources reserved by the killed thread are released. Especially mutexes must be handled with extreme care. Typically, however, it is not safe to kill any thread. Instead, one should consider setting an internal "cancellation" flag that is checked every now and then.
|
|
||||||||||||
|
Suspend the execution of this thread for the specified number of seconds and nanoseconds.
|
|
|
Suspend the execution of this thread for the specified number of seconds.
|
|
|
Start the thread.
Implements util::Runnable. |