Scheduler
Scheduler
#include <icy/sched/scheduler.h>class SchedulerDefined in src/sched/include/icy/sched/scheduler.h:31
Inherits:
TaskRunner,ISerializable
The Scheduler manages and runs tasks that need to be executed at specific times.
List of all members
| Name | Kind | Owner |
|---|---|---|
Scheduler | function | Declared here |
~Scheduler | function | Declared here |
schedule | function | Declared here |
cancel | function | Declared here |
clear | function | Declared here |
serialize | function | Declared here |
deserialize | function | Declared here |
print | function | Declared here |
cancel | function | Declared here |
getDefault | function | Declared here |
factory | function | Declared here |
run | function | Declared here |
update | function | Declared here |
Idle | variable | Inherited from TaskRunner |
Shutdown | variable | Inherited from TaskRunner |
TaskRunner | function | Inherited from TaskRunner |
~TaskRunner | function | Inherited from TaskRunner |
TaskRunner | function | Inherited from TaskRunner |
operator= | function | Inherited from TaskRunner |
TaskRunner | function | Inherited from TaskRunner |
operator= | function | Inherited from TaskRunner |
start | function | Inherited from TaskRunner |
cancel | function | Inherited from TaskRunner |
destroy | function | Inherited from TaskRunner |
exists | function | Inherited from TaskRunner |
get | function | Inherited from TaskRunner |
setRunner | function | Inherited from TaskRunner |
className | function | Inherited from TaskRunner |
getDefault | function | Inherited from TaskRunner |
_mutex | variable | Inherited from TaskRunner |
_runner | variable | Inherited from TaskRunner |
_tasks | variable | Inherited from TaskRunner |
run | function | Inherited from TaskRunner |
add | function | Inherited from TaskRunner |
remove | function | Inherited from TaskRunner |
next | function | Inherited from TaskRunner |
clear | function | Inherited from TaskRunner |
onAdd | function | Inherited from TaskRunner |
onStart | function | Inherited from TaskRunner |
onCancel | function | Inherited from TaskRunner |
onRemove | function | Inherited from TaskRunner |
onRun | function | Inherited from TaskRunner |
Runnable | function | Inherited from Runnable |
~Runnable | function | Inherited from Runnable |
run | function | Inherited from Runnable |
cancel | function | Inherited from Runnable |
cancelled | function | Inherited from Runnable |
exit | variable | Inherited from Runnable |
~ISerializable | function | Inherited from ISerializable |
serialize | function | Inherited from ISerializable |
deserialize | function | Inherited from ISerializable |
Inherited from TaskRunner
| Kind | Name | Description |
|---|---|---|
variable | Idle | Fires after completing an iteration of all tasks. |
variable | Shutdown | Signals when the [TaskRunner](icy-TaskRunner.html#taskrunner-1) is shutting down. |
function | TaskRunner | |
function | ~TaskRunner virtual | |
function | TaskRunner | Deleted constructor. |
function | operator= | Deleted assignment operator. |
function | TaskRunner | Deleted constructor. |
function | operator= | Deleted assignment operator. |
function | start virtual | Starts a task, adding it if it doesn't exist. |
function | cancel virtual | Cancels a task. |
function | destroy virtual | Queues a task for destruction. |
function | exists virtual const | Returns whether a task exists. |
function | get virtual const | Returns the task pointer matching the given ID, or nullptr if no task exists. |
function | 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. |
function | className virtual const inline | |
function | getDefault static | Returns the default [TaskRunner](icy-TaskRunner.html#taskrunner-1) 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. |
variable | _mutex | |
variable | _runner | |
variable | _tasks | |
function | run virtual override | Called by the async context to run the next task. |
function | add virtual | Adds a task to the runner. |
function | remove virtual | Removes a task from the runner. |
function | next virtual const | Returns the next task to be run. |
function | clear virtual | Destroys and clears all manages tasks. |
function | onAdd virtual | Called after a task is added. |
function | onStart virtual | Called after a task is started. |
function | onCancel virtual | Called after a task is cancelled. |
function | onRemove virtual | Called after a task is removed. |
function | onRun virtual | Called after a task has run. |
Inherited from Runnable
| Kind | Name | Description |
|---|---|---|
function | Runnable inline | |
function | ~Runnable virtual | Defaulted destructor. |
function | run virtual | The run method will be called by the asynchronous context. |
function | cancel virtual inline | Cancel the current task. The run() method should return ASAP. |
function | cancelled virtual const inline | Returns true when the task has been cancelled. |
variable | exit |
Inherited from ISerializable
| Kind | Name | Description |
|---|---|---|
function | ~ISerializable virtual | Defaulted destructor. |
function | serialize virtual | Serializes this object's state into root. |
function | deserialize virtual | Populates this object's state from root. |
Public Methods
| Return | Name | Description |
|---|---|---|
Scheduler | ||
void | schedule virtual | Adds task to the scheduler and starts running it on its configured trigger. The scheduler takes ownership of the task. |
void | cancel virtual | Removes task from the scheduler and cancels any pending execution. |
void | clear virtual override | Removes all scheduled tasks. |
void | serialize virtual override | Serializes all scheduled tasks and their triggers to root. |
void | deserialize virtual override | Reconstructs the task list from root using the TaskFactory. Skips entries that fail to deserialize and logs the error. |
void | print virtual | Writes a pretty-printed JSON representation of all tasks to ost. |
bool | cancel | Cancels a task. |
Scheduler
Scheduler()Defined in src/sched/include/icy/sched/scheduler.h:35
schedule
virtual
virtual void schedule(sched::Task * task)Defined in src/sched/include/icy/sched/scheduler.h:41
Adds task to the scheduler and starts running it on its configured trigger. The scheduler takes ownership of the task.
Parameters
taskTask to schedule; must have a trigger set.
cancel
virtual
virtual void cancel(sched::Task * task)Defined in src/sched/include/icy/sched/scheduler.h:47
Removes task from the scheduler and cancels any pending execution.
Parameters
taskTask to cancel.
clear
virtual override
virtual void clear() overrideDefined in src/sched/include/icy/sched/scheduler.h:50
Removes all scheduled tasks.
Reimplements
serialize
virtual override
virtual void serialize(json::Value & root) overrideDefined in src/sched/include/icy/sched/scheduler.h:54
Serializes all scheduled tasks and their triggers to root.
Parameters
rootJSON array to append serialized task entries to.
Reimplements
deserialize
virtual override
virtual void deserialize(json::Value & root) overrideDefined in src/sched/include/icy/sched/scheduler.h:59
Reconstructs the task list from root using the TaskFactory. Skips entries that fail to deserialize and logs the error.
Parameters
rootJSON array previously produced by serialize().
Reimplements
virtual
virtual void print(std::ostream & ost)Defined in src/sched/include/icy/sched/scheduler.h:63
Writes a pretty-printed JSON representation of all tasks to ost.
Parameters
ostOutput stream to write to.
cancel
bool cancel(Task * task)Defined in src/sched/include/icy/sched/scheduler.h:43
Cancels a task.
The task reference will be managed by the TaskRunner until the task is destroyed.
Public Static Methods
| Return | Name | Description |
|---|---|---|
Scheduler & | getDefault static | Returns the default Scheduler singleton, although Scheduler instances may also be initialized individually. |
sched::TaskFactory & | factory static | Returns the TaskFactory singleton. |
getDefault
static
static Scheduler & getDefault()Defined in src/sched/include/icy/sched/scheduler.h:68
Returns the default Scheduler singleton, although Scheduler instances may also be initialized individually.
factory
static
static sched::TaskFactory & factory()Defined in src/sched/include/icy/sched/scheduler.h:71
Returns the TaskFactory singleton.
Protected Methods
| Return | Name | Description |
|---|---|---|
void | run virtual override | The run method will be called by the asynchronous context. |
void | update virtual |
run
virtual override
virtual void run() overrideDefined in src/sched/include/icy/sched/scheduler.h:74
The run method will be called by the asynchronous context.
Reimplements
update
virtual
virtual void update()