Sched module

Scheduler

The [Scheduler]({#ref classicy_1_1sched_1_1Scheduler #}) manages and runs tasks that need to be executed at specific tim

Scheduler

#include <icy/sched/scheduler.h>

Inherits: TaskRunner, ISerializable

The Scheduler manages and runs tasks that need to be executed at specific times.

Public Methods

ReturnNameDescription
Scheduler
voidschedule virtualAdds task to the scheduler and starts running it on its configured trigger. The scheduler takes ownership of the task.
voidcancel virtualRemoves task from the scheduler and cancels any pending execution.
voidclear virtualRemoves all scheduled tasks.
voidserialize virtualSerializes all scheduled tasks and their triggers to root.
voiddeserialize virtualReconstructs the task list from root using the TaskFactory. Skips entries that fail to deserialize and logs the error.
voidprint virtualWrites a pretty-printed JSON representation of all tasks to ost.
boolcancelCancels a task.

Scheduler

Scheduler()

schedule

virtual

virtual void schedule(sched::Task * task)

Adds task to the scheduler and starts running it on its configured trigger. The scheduler takes ownership of the task.

Parameters

  • task Task to schedule; must have a trigger set.

cancel

virtual

virtual void cancel(sched::Task * task)

Removes task from the scheduler and cancels any pending execution.

Parameters

  • task Task to cancel.

clear

virtual

virtual void clear()

Removes all scheduled tasks.


serialize

virtual

virtual void serialize(json::Value & root)

Serializes all scheduled tasks and their triggers to root.

Parameters

  • root JSON array to append serialized task entries to.

deserialize

virtual

virtual void deserialize(json::Value & root)

Reconstructs the task list from root using the TaskFactory. Skips entries that fail to deserialize and logs the error.

Parameters


print

virtual

virtual void print(std::ostream & ost)

Writes a pretty-printed JSON representation of all tasks to ost.

Parameters

  • ost Output stream to write to.

cancel

bool cancel(Task * task)

Cancels a task.

The task reference will be managed by the TaskRunner until the task is destroyed.

Public Static Methods

ReturnNameDescription
Scheduler &getDefault staticReturns the default Scheduler singleton, although Scheduler instances may also be initialized individually.
sched::TaskFactory &factory staticReturns the TaskFactory singleton.

getDefault

static

static Scheduler & getDefault()

Returns the default Scheduler singleton, although Scheduler instances may also be initialized individually.


factory

static

static sched::TaskFactory & factory()

Returns the TaskFactory singleton.

Protected Methods

ReturnNameDescription
voidrun virtualThe run method will be called by the asynchronous context.
voidupdate virtual

run

virtual

virtual void run()

The run method will be called by the asynchronous context.


update

virtual

virtual void update()