Transient Recorder Framework
Public Member Functions | Friends | List of all members
TRWorkerThreadTask Class Reference

Represents a task submitted to the worker thread. More...

#include <TRWorkerThread.h>

Inheritance diagram for TRWorkerThreadTask:

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
 

Detailed Description

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.

Constructor & Destructor Documentation

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.

Parameters
workerpointer to the TRWorkerThread
runnablethe runnable defining the code to run
ididentifier 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.

Member Function Documentation

void TRWorkerThreadTask::init ( TRWorkerThread worker,
TRWorkerThreadRunnable runnable,
int  id 
)

Complete initization when the default constructor was used.

Parameters
workerpointer to the TRWorkerThread
runnablethe runnable defining the code to run
ididentifier 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.

Returns
True if queued, false if it was already queued.
bool TRWorkerThreadTask::cancel ( )

Dequeues the task.

Returns
True if dequeued, false if it was not queued.

The documentation for this class was generated from the following file: