Base module

Task

Abstract base class for implementing asynchronous tasks.

Task

#include <icy/task.h>

Inherits: Runnable Subclassed by: Task

Abstract base class for implementing asynchronous tasks.

Tasks are designed to be run by a TaskRunner.

Public Methods

ReturnNameDescription
Task#### Parameters
voiddestroy virtualSets the task to destroyed state.
booldestroyed virtual constSignals that the task should be disposed of.
boolrepeating virtual constSignals that the task should be called repeatedly by the TaskRunner. If this returns false the task will be cancelled.
uint32_tid virtual constUnique task ID.
TaskDeleted constructor.
TaskDeleted constructor.

Task

Task(bool repeat)

Parameters

  • repeat If true, the [TaskRunner](icy-TaskRunner.html#taskrunner) will call [run()](#run-5) repeatedly; if false, the task is cancelled after one execution.

destroy

virtual

virtual void destroy()

Sets the task to destroyed state.


destroyed

virtual const

virtual bool destroyed() const

Signals that the task should be disposed of.


repeating

virtual const

virtual bool repeating() const

Signals that the task should be called repeatedly by the TaskRunner. If this returns false the task will be cancelled.


id

virtual const

virtual uint32_t id() const

Unique task ID.


Task

Task(const Task & task) = delete

Deleted constructor.


Task

Task(Task &&) = delete

Deleted constructor.

Protected Attributes

ReturnNameDescription
uint32_t_id
bool_repeating
bool_destroyed

_id

uint32_t _id

_repeating

bool _repeating

_destroyed

bool _destroyed

Protected Methods

ReturnNameDescription
voidrunCalled by the TaskRunner to run the task. Override this method to implement task action. Returning true means the task should be called again, and false will cause the task to be destroyed. The task will similarly be destroyed if destroy() was called during the current task iteration.

run

void run()

Called by the TaskRunner to run the task. Override this method to implement task action. Returning true means the task should be called again, and false will cause the task to be destroyed. The task will similarly be destroyed if destroy() was called during the current task iteration.