| VRS - The Virtual Rendering System |
| version 3.3 |
#include <vrs/mt/taskmanager.h>

Public Types | |
| enum | State { State_Queued, State_Running, State_Canceling, State_Finished, State_Canceled, State_Exception } |
| Defines the possible states of a task. More... | |
Public Member Functions | |
| VRS_TYPEINFO (TaskBase, VRS::SharedObj) | |
| virtual State | state () const |
| Returns the current state of the task. | |
| virtual bool | ended () const |
| Returns true if the task is in finished, canceled or exception state; otherwise false. | |
| virtual double | priority () const |
| Returns the priority of the task. | |
| virtual void | changePriority (double newPriority) |
| Allows to change the priority of the task. | |
| virtual void | wait () const |
| If the task is in state finished, canceled or exception the call to wait() will return immediately. | |
| virtual bool | wait (double seconds) const |
| If the task is in state finished, canceled or exception the call to wait() will return immediately. | |
| virtual void | cancel () |
| If the task is in queued state it will be set immediately to canceled state. | |
| virtual | ~TaskBase () |
| Virtual destructor. | |
Static Public Member Functions | |
| static void | Sleep (double seconds) |
| Puts the current task into sleep for at least the given amount of seconds. | |
| static void | Yield () |
| Reschedules the current task. | |
| static bool | ShouldBeCanceled () |
| Tests, if the running task has been signaled for cancelation. | |
| static void | DoCancelation () |
| Performes the task cancelation (throws a corresponding exception). | |
Public Attributes | |
| Impl *const | m_impl |
Protected Member Functions | |
| TaskBase (double priority, double cancelIfNotStartedWithinSecond, bool finished) | |
| Protected constructor. | |
| virtual void | work ()=0 |
| A subclass has to implement this method. | |
| void | workImpl () |
| Implements the state changes around the actual work. | |
Friends | |
| class | TaskManager |
Defines the possible states of a task.
| VRS::MT::TaskBase::TaskBase | ( | double | priority, | |
| double | cancelIfNotStartedWithinSecond, | |||
| bool | finished | |||
| ) | [protected] |
Protected constructor.
| virtual VRS::MT::TaskBase::~TaskBase | ( | ) | [virtual] |
Virtual destructor.
| VRS::MT::TaskBase::VRS_TYPEINFO | ( | TaskBase | , | |
| VRS::SharedObj | ||||
| ) |
| virtual State VRS::MT::TaskBase::state | ( | ) | const [virtual] |
Returns the current state of the task.
| virtual bool VRS::MT::TaskBase::ended | ( | ) | const [virtual] |
Returns true if the task is in finished, canceled or exception state; otherwise false.
| virtual double VRS::MT::TaskBase::priority | ( | ) | const [virtual] |
Returns the priority of the task.
| virtual void VRS::MT::TaskBase::changePriority | ( | double | newPriority | ) | [virtual] |
Allows to change the priority of the task.
This method has only effect if the computation has not been started, i.e., the task is in queued state. The priority must be between 0.0 (= lowest priority) and 1.0 (highest priority).
| virtual void VRS::MT::TaskBase::wait | ( | ) | const [virtual] |
If the task is in state finished, canceled or exception the call to wait() will return immediately.
Otherwise it will be waited until one of these states are reached.
| virtual bool VRS::MT::TaskBase::wait | ( | double | seconds | ) | const [virtual] |
If the task is in state finished, canceled or exception the call to wait() will return immediately.
Otherwise it will be waited until one of these states are reached or the given amount of seconds has been elapsed. The return value indicates whether the waiting was successful (true), i.e., the task is not running anymore.
| virtual void VRS::MT::TaskBase::cancel | ( | ) | [virtual] |
If the task is in queued state it will be set immediately to canceled state.
If the task is in running state it will be signaled, that cancelation should take place. The running task has to call cancelationPoint() in order to support cancelation. In all other cases nothing is done at all. Note: the call to cancel() is not blocking and will return immediately. If you want to wait for the cancelation of the task call wait() in addition.
| static void VRS::MT::TaskBase::Sleep | ( | double | seconds | ) | [static] |
Puts the current task into sleep for at least the given amount of seconds.
| static void VRS::MT::TaskBase::Yield | ( | ) | [static] |
Reschedules the current task.
| static bool VRS::MT::TaskBase::ShouldBeCanceled | ( | ) | [static] |
Tests, if the running task has been signaled for cancelation.
If the current task schould be canceled (return value = true), the task should do some cleanup (if necessary) and then call DoCancelation().
| static void VRS::MT::TaskBase::DoCancelation | ( | ) | [static] |
Performes the task cancelation (throws a corresponding exception).
| virtual void VRS::MT::TaskBase::work | ( | ) | [protected, pure virtual] |
| void VRS::MT::TaskBase::workImpl | ( | ) | [protected] |
Implements the state changes around the actual work.
friend class TaskManager [friend] |
Reimplemented in VRS::MT::Task< RESULT_TYPE >.
| Impl* const VRS::MT::TaskBase::m_impl |