#include <gxThread.h>
Inheritance diagram for gxThread:
Public Types | |
enum | priority_t { PRIORITY_IDLE, PRIORITY_LOWEST, PRIORITY_BELOW_NORMAL, PRIORITY_NORMAL, PRIORITY_ABOVE_NORMAL, PRIORITY_HIGHEST, PRIORITY_TIME_CRITICAL } |
Thread priority levels. More... | |
enum | states_t { STATE_STOPPED = 0, STATE_STARTING = 1, STATE_STARTED = 2, STATE_STOPPING = 3 } |
Public Member Functions | |
gxThread (gxThreadRunnable *runnable, priority_t priority=PRIORITY_NORMAL) | |
virtual | ~gxThread () |
void | start (bool wait=true) |
Start the thread. | |
void | stop () |
Stops the thread by invoking "stopRequest" and then waiting for the thread to terminate. | |
virtual void | run () |
Override to provide the code which will execute within the thread. | |
virtual void | onStopThreadRequest () |
This overridable method is invoked when the caller invokes stop. | |
bool | isStopping () |
Specifies whether a stop request is pending. | |
states_t | getState () |
Returns the threads start/stop state. | |
Static Public Member Functions | |
static void | sleep (long milliseconds) |
Causes the current thread to sleep for the specified number of milliseconds. |
To use this class effectively, you must implement a "run" method containing the code to be executed in the thread. The run method may be implemented in a subclass of gxThread by overriding the existing run method. Alternatively, the run method may be implemented in another class, providing that class implements the gxThreadRunnable interface and overrides the pure virtual run method.
|
Thread priority levels. These names look suspiciously similar to the Win32 thread priorities, but don't count on them having the same value. |
|
|
|
|
|
|
|
Returns the threads start/stop state.
|
|
Specifies whether a stop request is pending.
|
|
This overridable method is invoked when the caller invokes stop. The default implementation just notifies this object. The thread can invoke the isStopping method to determine whether the most recent notification was caused by "stop". If so, the thread should exit the run method so that the application does not stall. |
|
Override to provide the code which will execute within the thread. This method will *not* execute if a gxThreadRunnable was provided in the constructor. |
|
Causes the current thread to sleep for the specified number of milliseconds.
|
|
Start the thread. If wait is true, then wait until the thread has actually started. |
|
Stops the thread by invoking "stopRequest" and then waiting for the thread to terminate. The precise shutdown mechanism is provided by the specific implementation of "run" and "stopRequest". |