Declares the DtRunnable class for defining a object that can be run in a thread.
More...
Public Member Functions |
| | DtRunnable () |
| | Constructor.
|
| virtual | ~DtRunnable () |
| | Destructor.
|
| virtual void | run ()=0 |
| | Abstract function that will be called when the thread is started.
|
| virtual void | stop () |
| | Function that will be called when the thread is told to stop.
|
| bool | timeToStop () |
| | Time to stop function which returns TRUE if it is time to stop execution.
|
Protected Member Functions |
| void | execute (volatile bool *stopFlag) |
| | Protected execute function which calls run.
|
Protected Attributes |
| volatile bool * | myStopFlag |
| | Pointer to the stop flag.
|
Detailed Description
Declares the DtRunnable class for defining a object that can be run in a thread.
DtRunnable is the defined interface for an object that can be run in a thread. To create a runnable class extend the DtRunnable class and implement the run function. It is important for code that can take considerable time to query the timeToStop() function in all loops, especially infinite loops. There is no safe way to terminate a thread thus to write multi-threading code it is important to allow the controlling thread to safely terminate a child thread.
Constructor & Destructor Documentation
| DtRunnable::DtRunnable |
( |
| ) |
|
| virtual DtRunnable::~DtRunnable |
( |
| ) |
|
|
virtual |
Member Function Documentation
| void DtRunnable::execute |
( |
volatile bool * |
stopFlag | ) |
|
|
protected |
Protected execute function which calls run.
| virtual void DtRunnable::run |
( |
| ) |
|
|
pure virtual |
Abstract function that will be called when the thread is started.
Implemented in DtIoServiceRunnable.
| virtual void DtRunnable::stop |
( |
| ) |
|
|
virtual |
Function that will be called when the thread is told to stop.
Override this function to stop without polling timeToStop.
| bool DtRunnable::timeToStop |
( |
| ) |
|
Time to stop function which returns TRUE if it is time to stop execution.
Friends And Related Function Documentation
Member Data Documentation
| volatile bool* DtRunnable::myStopFlag |
|
protected |
Pointer to the stop flag.
The documentation for this class was generated from the following file: