[Task]({#ref classicy_1_1Task #}) interface.#include <icy/task.h>Runner for tasks that inherit the [Task](icy-Task.html#task) interface.
The [TaskRunner](#taskrunner) continually loops through each task in the task list calling the task's [run()](#run-6) method.
The [TaskRunner](#taskrunner) is powered by an abstract [Runner](icy-Runner.html#runner) instance, which means that tasks can be executed in a thread or event loop context.
| Return | Name | Description |
|---|---|---|
NullSignal | Idle | Fires after completing an iteration of all tasks. |
NullSignal | Shutdown | Signals when the [TaskRunner](#taskrunner) is shutting down. |
NullSignal IdleFires after completing an iteration of all tasks.
NullSignal ShutdownSignals when the [TaskRunner](#taskrunner) is shutting down.
| Return | Name | Description |
|---|---|---|
TaskRunner | #### Parameters | |
TaskRunner | Deleted constructor. | |
TaskRunner | Deleted constructor. | |
bool | start virtual | Starts a task, adding it if it doesn't exist. |
bool | cancel virtual | Cancels a task. |
bool | destroy virtual | Queues a task for destruction. |
bool | exists virtual const | Returns whether a task exists. |
Task * | get virtual const | Returns the task pointer matching the given ID, or nullptr if no task exists. |
void | setRunner virtual | Set the asynchronous context for packet processing. This may be a Thread or another derivative of Async. Must be set before the stream is activated. |
const char * | className virtual const inline |
TaskRunner(std::shared_ptr< Runner > runner)runner Async runner to drive task execution; defaults to a new [Thread](icy-Thread.html#thread).TaskRunner(const TaskRunner &) = deleteDeleted constructor.
TaskRunner(TaskRunner &&) = deleteDeleted constructor.
virtual
virtual bool start(Task * task)Starts a task, adding it if it doesn't exist.
virtual
virtual bool cancel(Task * task)Cancels a task.
The task reference will be managed by the TaskRunner until the task is destroyed.
virtual
virtual bool destroy(Task * task)Queues a task for destruction.
virtual const
virtual bool exists(Task * task) constReturns whether a task exists.
virtual const
virtual Task * get(uint32_t id) constReturns the task pointer matching the given ID, or nullptr if no task exists.
virtual
virtual void setRunner(std::shared_ptr< Runner > runner)Set the asynchronous context for packet processing. This may be a Thread or another derivative of Async. Must be set before the stream is activated.
virtual const inline
virtual inline const char * className() const| Return | Name | Description |
|---|---|---|
TaskRunner & | getDefault static | Returns the default [TaskRunner](#taskrunner) singleton, although TaskRunner instances may be initialized individually. The default runner should be kept for short running tasks such as timers in order to maintain performance. |
static
static TaskRunner & getDefault()Returns the default [TaskRunner](#taskrunner) singleton, although TaskRunner instances may be initialized individually. The default runner should be kept for short running tasks such as timers in order to maintain performance.
std::mutex _mutexstd::shared_ptr< Runner > _runnerTaskList _tasks| Return | Name | Description |
|---|---|---|
void | run virtual | Called by the async context to run the next task. |
bool | add virtual | Adds a task to the runner. |
bool | remove virtual | Removes a task from the runner. |
Task * | next virtual const | Returns the next task to be run. |
void | clear virtual | Destroys and clears all manages tasks. |
void | onAdd virtual | Called after a task is added. |
void | onStart virtual | Called after a task is started. |
void | onCancel virtual | Called after a task is cancelled. |
void | onRemove virtual | Called after a task is removed. |
void | onRun virtual | Called after a task has run. |
virtual
virtual void run()Called by the async context to run the next task.
virtual
virtual bool add(Task * task)Adds a task to the runner.
virtual
virtual bool remove(Task * task)Removes a task from the runner.
virtual const
virtual Task * next() constReturns the next task to be run.
virtual
virtual void clear()Destroys and clears all manages tasks.
virtual
virtual void onAdd(Task * task)Called after a task is added.
virtual
virtual void onStart(Task * task)Called after a task is started.
virtual
virtual void onCancel(Task * task)Called after a task is cancelled.
virtual
virtual void onRemove(Task * task)Called after a task is removed.
virtual
virtual void onRun(Task * task)Called after a task has run.