Transient Recorder Framework
|
Represents a task submitted to the worker thread. More...
#include <TRWorkerThread.h>
Public Member Functions | |
TRWorkerThreadTask () | |
Default constructor. More... | |
TRWorkerThreadTask (TRWorkerThread *worker, TRWorkerThreadRunnable *runnable, int id) | |
Constructs the task object. More... | |
void | init (TRWorkerThread *worker, TRWorkerThreadRunnable *runnable, int id) |
Complete initization when the default constructor was used. More... | |
~TRWorkerThreadTask () | |
Destructs the task object. More... | |
bool | start () |
Queues the task for execution. More... | |
bool | cancel () |
Dequeues the task. More... | |
Friends | |
class | TRWorkerThread |
Represents a task submitted to the worker thread.
The Transient Recorder framework does not create a worker thread itself but provides this class is provided at the convenience of drivers which need to perform synchronous operations beyond what can be achieved using only TRBaseDriver.
TRWorkerThreadTask::TRWorkerThreadTask | ( | ) |
Default constructor.
If this is used, then other functions must not be called before TRWorkerThreadTask::init is called.
TRWorkerThreadTask::TRWorkerThreadTask | ( | TRWorkerThread * | worker, |
TRWorkerThreadRunnable * | runnable, | ||
int | id | ||
) |
Constructs the task object.
To queue the task for execution, call start.
worker | pointer to the TRWorkerThread |
runnable | the runnable defining the code to run |
id | identifier allowing disambiguation, passed to runnable |
TRWorkerThreadTask::~TRWorkerThreadTask | ( | ) |
Destructs the task object.
Destruction will dequeu the task if it is queued (the same as calling cancel).
WARNING: This does not wait for the task to complete if is currently being executed. It is the responsibility of the user to address that issue. Also note the possibility that the worker thread has dequeued the task but not yet called its runWorkerThreadTask function.
void TRWorkerThreadTask::init | ( | TRWorkerThread * | worker, |
TRWorkerThreadRunnable * | runnable, | ||
int | id | ||
) |
Complete initization when the default constructor was used.
worker | pointer to the TRWorkerThread |
runnable | the runnable defining the code to run |
id | identifier allowing disambiguation, passed to runnable |
bool TRWorkerThreadTask::start | ( | ) |
Queues the task for execution.
This will only queue the task if it is not already queued. Note however that this means the task may be queued when it is being executed.
bool TRWorkerThreadTask::cancel | ( | ) |
Dequeues the task.