Home
Sched module

Scheduler

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

Scheduler

#include <icy/sched/scheduler.h>
class Scheduler

Defined 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

NameKindOwner
SchedulerfunctionDeclared here
~SchedulerfunctionDeclared here
schedulefunctionDeclared here
cancelfunctionDeclared here
clearfunctionDeclared here
serializefunctionDeclared here
deserializefunctionDeclared here
printfunctionDeclared here
cancelfunctionDeclared here
getDefaultfunctionDeclared here
factoryfunctionDeclared here
runfunctionDeclared here
updatefunctionDeclared here
IdlevariableInherited from TaskRunner
ShutdownvariableInherited from TaskRunner
TaskRunnerfunctionInherited from TaskRunner
~TaskRunnerfunctionInherited from TaskRunner
TaskRunnerfunctionInherited from TaskRunner
operator=functionInherited from TaskRunner
TaskRunnerfunctionInherited from TaskRunner
operator=functionInherited from TaskRunner
startfunctionInherited from TaskRunner
cancelfunctionInherited from TaskRunner
destroyfunctionInherited from TaskRunner
existsfunctionInherited from TaskRunner
getfunctionInherited from TaskRunner
setRunnerfunctionInherited from TaskRunner
classNamefunctionInherited from TaskRunner
getDefaultfunctionInherited from TaskRunner
_mutexvariableInherited from TaskRunner
_runnervariableInherited from TaskRunner
_tasksvariableInherited from TaskRunner
runfunctionInherited from TaskRunner
addfunctionInherited from TaskRunner
removefunctionInherited from TaskRunner
nextfunctionInherited from TaskRunner
clearfunctionInherited from TaskRunner
onAddfunctionInherited from TaskRunner
onStartfunctionInherited from TaskRunner
onCancelfunctionInherited from TaskRunner
onRemovefunctionInherited from TaskRunner
onRunfunctionInherited from TaskRunner
RunnablefunctionInherited from Runnable
~RunnablefunctionInherited from Runnable
runfunctionInherited from Runnable
cancelfunctionInherited from Runnable
cancelledfunctionInherited from Runnable
exitvariableInherited from Runnable
~ISerializablefunctionInherited from ISerializable
serializefunctionInherited from ISerializable
deserializefunctionInherited from ISerializable

Inherited from TaskRunner

KindNameDescription
variableIdleFires after completing an iteration of all tasks.
variableShutdownSignals when the [TaskRunner](icy-TaskRunner.html#taskrunner-1) is shutting down.
functionTaskRunner
function~TaskRunner virtual
functionTaskRunnerDeleted constructor.
functionoperator=Deleted assignment operator.
functionTaskRunnerDeleted constructor.
functionoperator=Deleted assignment operator.
functionstart virtualStarts a task, adding it if it doesn't exist.
functioncancel virtualCancels a task.
functiondestroy virtualQueues a task for destruction.
functionexists virtual constReturns whether a task exists.
functionget virtual constReturns the task pointer matching the given ID, or nullptr if no task exists.
functionsetRunner virtualSet the asynchronous context for packet processing. This may be a Thread or another derivative of Async. Must be set before the stream is activated.
functionclassName virtual const inline
functiongetDefault staticReturns 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
functionrun virtual overrideCalled by the async context to run the next task.
functionadd virtualAdds a task to the runner.
functionremove virtualRemoves a task from the runner.
functionnext virtual constReturns the next task to be run.
functionclear virtualDestroys and clears all manages tasks.
functiononAdd virtualCalled after a task is added.
functiononStart virtualCalled after a task is started.
functiononCancel virtualCalled after a task is cancelled.
functiononRemove virtualCalled after a task is removed.
functiononRun virtualCalled after a task has run.

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

Inherited from ISerializable

KindNameDescription
function~ISerializable virtualDefaulted destructor.
functionserialize virtualSerializes this object's state into root.
functiondeserialize virtualPopulates this object's state from root.

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 virtual overrideRemoves all scheduled tasks.
voidserialize virtual overrideSerializes all scheduled tasks and their triggers to root.
voiddeserialize virtual overrideReconstructs 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()

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

  • task Task 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

  • task Task to cancel.

clear

virtual override

virtual void clear() override

Defined in src/sched/include/icy/sched/scheduler.h:50

Removes all scheduled tasks.

Reimplements

serialize

virtual override

virtual void serialize(json::Value & root) override

Defined in src/sched/include/icy/sched/scheduler.h:54

Serializes all scheduled tasks and their triggers to root.

Parameters

  • root JSON array to append serialized task entries to.
Reimplements

deserialize

virtual override

virtual void deserialize(json::Value & root) override

Defined 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

Reimplements

print

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

  • ost Output 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

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()

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

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

run

virtual override

virtual void run() override

Defined 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()

Defined in src/sched/include/icy/sched/scheduler.h:75