RSC
0.16.0
|
A Task subclass which maintains interruption through a volatile boolean flag which should be processed by the user code. More...
#include <SimpleTask.h>
Public Member Functions | |
SimpleTask () | |
virtual | ~SimpleTask () |
virtual void | cancel () |
Interrupts the task as soon as possible. More... | |
virtual bool | isCancelRequested () |
Tells whether the task was interrupted by a call to cancel. More... | |
virtual void | waitDone () |
Waits for the execution of this task to finish. More... | |
virtual bool | isDone () |
Indicates whether the task finished execution, either through being canceled or through successfully ending. More... | |
Public Member Functions inherited from rsc::threading::Task | |
virtual | ~Task () |
virtual void | run ()=0 |
Performs the real task work. More... | |
Protected Member Functions | |
void | markDone () |
Private Attributes | |
boost::recursive_mutex | mutex |
boost::condition | condition |
volatile bool | canceled |
volatile bool | done |
A Task subclass which maintains interruption through a volatile boolean flag which should be processed by the user code.
Implementations of run must call markDone whenever they stop working. This is either because their job finished or they were canceled.
Definition at line 47 of file SimpleTask.h.
rsc::threading::SimpleTask::SimpleTask | ( | ) |
Definition at line 32 of file SimpleTask.cpp.
|
virtual |
Definition at line 36 of file SimpleTask.cpp.
|
virtual |
Interrupts the task as soon as possible.
Will, at some time, wake up waiting threads in waitDone.
Implements rsc::threading::Task.
Definition at line 39 of file SimpleTask.cpp.
|
virtual |
Tells whether the task was interrupted by a call to cancel.
true
if cancel was called, else false
Implements rsc::threading::Task.
Definition at line 44 of file SimpleTask.cpp.
|
virtual |
Indicates whether the task finished execution, either through being canceled or through successfully ending.
If true
is returned, the run method of this task will not perform anything anymore.
true
if run will not perform anything anymore Implements rsc::threading::Task.
Definition at line 64 of file SimpleTask.cpp.
|
protected |
Definition at line 56 of file SimpleTask.cpp.
|
virtual |
Waits for the execution of this task to finish.
This may either be caused by a successful completion of the task or by being canceled. This method must block until run exits or it is sure that run will not be called anymore.
Undefined behavior might occur if this method is called before the task is scheduled. I.e. a calling thread might block infinitely.
Implements rsc::threading::Task.
Definition at line 49 of file SimpleTask.cpp.
|
private |
Definition at line 69 of file SimpleTask.h.
Referenced by cancel(), and isCancelRequested().
|
private |
Definition at line 67 of file SimpleTask.h.
Referenced by markDone(), and waitDone().
|
private |
Definition at line 70 of file SimpleTask.h.
Referenced by isDone(), markDone(), and waitDone().
|
mutableprivate |
Definition at line 66 of file SimpleTask.h.
Referenced by cancel(), isCancelRequested(), isDone(), markDone(), and waitDone().