Home
Base module

Task

Abstract base class for implementing asynchronous tasks.

Task

#include <icy/task.h>
class Task

Defined in src/base/include/icy/task.h:32

Inherits: Runnable Subclassed by: Task

Abstract base class for implementing asynchronous tasks.

Tasks are designed to be run by a TaskRunner.

List of all members

NameKindOwner
TaskRunnerfriendDeclared here
TaskfunctionDeclared here
destroyfunctionDeclared here
destroyedfunctionDeclared here
repeatingfunctionDeclared here
idfunctionDeclared here
~TaskfunctionDeclared here
TaskfunctionDeclared here
operator=functionDeclared here
TaskfunctionDeclared here
operator=functionDeclared here
_idvariableDeclared here
_repeatingvariableDeclared here
_destroyedvariableDeclared here
runfunctionDeclared here
RunnablefunctionInherited from Runnable
~RunnablefunctionInherited from Runnable
runfunctionInherited from Runnable
cancelfunctionInherited from Runnable
cancelledfunctionInherited from Runnable
exitvariableInherited from Runnable

Inherited from Runnable

KindNameDescription
functionRunnable inline
function~Runnable virtualDefaulted destructor.
functionrun virtualThe run method will be called by the asynchronous context.
functioncancel virtual inlineCancel the current task. The run() method should return ASAP.
functioncancelled virtual const inlineReturns true when the task has been cancelled.
variableexit

Friends

NameDescription
TaskRunnerTasks belong to a TaskRunner instance.

TaskRunner

friend class TaskRunner

Defined in src/base/include/icy/task.h:77

Tasks belong to a TaskRunner instance.

Public Methods

ReturnNameDescription
Task
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 = false)

Defined in src/base/include/icy/task.h:37

Parameters

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

destroy

virtual

virtual void destroy()

Defined in src/base/include/icy/task.h:40

Sets the task to destroyed state.


destroyed

virtual const

virtual bool destroyed() const

Defined in src/base/include/icy/task.h:43

Signals that the task should be disposed of.


repeating

virtual const

virtual bool repeating() const

Defined in src/base/include/icy/task.h:48

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

Defined in src/base/include/icy/task.h:51

Unique task ID.


Task

Task(const Task & task) = delete

Defined in src/base/include/icy/task.h:61

Deleted constructor.


Task

Task(Task &&) = delete

Defined in src/base/include/icy/task.h:63

Deleted constructor.

Protected Attributes

ReturnNameDescription
uint32_t_id
bool_repeating
bool_destroyed

_id

uint32_t _id

Defined in src/base/include/icy/task.h:79


_repeating

bool _repeating

Defined in src/base/include/icy/task.h:80


_destroyed

bool _destroyed

Defined in src/base/include/icy/task.h:81

Protected Methods

ReturnNameDescription
voidrun virtual overrideCalled 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

virtual override

virtual void run() override

Defined in src/base/include/icy/task.h:74

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.

Reimplements
Reimplemented by