sched
May 15, 2026 ยท View on GitHub
{#schedmodule}
sched
Task scheduler for deferred and periodic jobs.
Namespaces
| Name | Description |
|---|---|
sched | Deferred and periodic job scheduling primitives. |
{#sched}
sched
Deferred and periodic job scheduling primitives.
Classes
| Name | Description |
|---|---|
Scheduler | The Scheduler manages and runs tasks that need to be executed at specific times. |
Task | Scheduled task with an attached trigger and scheduler association. |
TaskFactory | The TaskFactory can dynamically instantiate registered sched::Task and sched::Trigger classes from named strings. |
DailyTrigger | Trigger that fires once per day at a configured time, with optional day-of-week exclusions. |
IntervalTrigger | Trigger that fires repeatedly at a fixed time interval. |
OnceOnlyTrigger | Trigger that fires exactly once at the scheduled time and then expires. |
Trigger | Base class for scheduled task triggers that determine when a task should run. |
Enumerations
| Name | Description |
|---|---|
DaysOfTheWeek | Days of the week. |
MonthOfTheYeay | Months of the year. |
{#daysoftheweek}
DaysOfTheWeek
enum DaysOfTheWeek
Days of the week.
| Value | Description |
|---|---|
Sunday | |
Monday | |
Tuesday | |
Wednesday | |
Thursday | |
Friday | |
Saturday |
{#monthoftheyeay}
MonthOfTheYeay
enum MonthOfTheYeay
Months of the year.
| Value | Description |
|---|---|
January | |
February | |
March | |
April | |
May | |
June | |
July | |
August | |
September | |
October | |
November | |
December |
Typedefs
| Return | Name | Description |
|---|---|---|
std::vector< sched::Task * > | TaskList | Ordered list of task pointers used by the scheduler. |
{#tasklist}
TaskList
using TaskList = std::vector< sched::Task * >
Ordered list of task pointers used by the scheduler.
Functions
| Return | Name | Description |
|---|---|---|
std::unique_ptr< sched::Task > | instantiateTask | Instantiate a registered Task subtype using its default constructor. |
std::unique_ptr< sched::Trigger > | instantiateTrigger | Instantiate a registered Trigger subtype using its default constructor. |
{#instantiatetask}
instantiateTask
template<typename T> std::unique_ptr< sched::Task > instantiateTask()
Instantiate a registered Task subtype using its default constructor.
{#instantiatetrigger}
instantiateTrigger
template<typename T> std::unique_ptr< sched::Trigger > instantiateTrigger()
Instantiate a registered Trigger subtype using its default constructor.
{#scheduler}
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
| Name | Kind | Owner |
|---|---|---|
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 |
cancel | function | Declared here |
getDefault | function | Declared here |
factory | function | Declared here |
run | function | Declared here |
update | function | Declared here |
TaskList | typedef | Inherited from TaskRunner |
Idle | variable | Inherited from TaskRunner |
Shutdown | variable | Inherited from TaskRunner |
_mutex | variable | Inherited from TaskRunner |
_runner | variable | Inherited from TaskRunner |
_tasks | 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 |
cancel | function | Inherited from TaskRunner |
getDefault | function | 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 |
run | function | Inherited from Runnable |
cancel | function | Inherited from Runnable |
cancelled | function | Inherited from Runnable |
exit | variable | Inherited from Runnable |
serialize | function | Inherited from ISerializable |
deserialize | function | Inherited from ISerializable |
Inherited from TaskRunner
| Kind | Name | Description |
|---|---|---|
typedef | TaskList | |
variable | Idle | Fires after completing an iteration of all tasks. |
variable | Shutdown | Signals when the [TaskRunner](base.md#taskrunner) is shutting down. |
variable | _mutex | |
variable | _runner | |
variable | _tasks | |
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 | cancel virtual inline | Cancel the current task. The run() method should return ASAP. |
function | getDefault static | Returns the default [TaskRunner](base.md#taskrunner) 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. |
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 | 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 | 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 virtual | Cancels a task. |
void | cancel virtual inline | Cancel the current task. The run() method should return ASAP. |
{#scheduler-1}
Scheduler
Scheduler()
Defined in src/sched/include/icy/sched/scheduler.h:35
{#schedule}
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-4}
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-2}
clear
virtual override
virtual void clear() override
Defined in src/sched/include/icy/sched/scheduler.h:50
Removes all scheduled tasks.
Reimplements
{#serialize-3}
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
rootJSON array to append serialized task entries to.
Reimplements
{#deserialize-3}
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
rootJSON array previously produced by serialize().
Reimplements
{#print-14}
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-5}
cancel
virtual
virtual 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.
Reimplements
{#cancel-6}
cancel
virtual inline
virtual inline void cancel(bool flag = true)
Defined in src/sched/include/icy/sched/scheduler.h:43
Cancel the current task. The run() method should return ASAP.
Reimplements
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-2}
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-1}
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-6}
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-5}
update
virtual
virtual void update()
Defined in src/sched/include/icy/sched/scheduler.h:75
{#task-1}
Task
#include <icy/sched/task.h>
class Task
Defined in src/sched/include/icy/sched/task.h:32
Inherits:
Task,ISerializable
Scheduled task with an attached trigger and scheduler association.
List of all members
| Name | Kind | Owner |
|---|---|---|
Scheduler | friend | Declared here |
Task | function | Declared here |
Task | function | Declared here |
serialize | function | Declared here |
deserialize | function | Declared here |
createTrigger | function | Declared here |
setTrigger | function | Declared here |
trigger | function | Declared here |
scheduler | function | Declared here |
remaining | function | Declared here |
type | function | Declared here |
name | function | Declared here |
setName | function | Declared here |
_type | variable | Declared here |
_name | variable | Declared here |
_scheduler | variable | Declared here |
_trigger | variable | Declared here |
_mutex | variable | Declared here |
beforeRun | function | Declared here |
run | function | Declared here |
afterRun | function | Declared here |
TaskRunner | friend | Inherited from Task |
_id | variable | Inherited from Task |
_repeating | variable | Inherited from Task |
_destroyed | variable | Inherited from Task |
Task | function | Inherited from Task |
destroy | function | Inherited from Task |
destroyed | function | Inherited from Task |
repeating | function | Inherited from Task |
id | function | Inherited from Task |
~Task | function | Inherited from Task |
Task | function | Inherited from Task |
operator= | function | Inherited from Task |
Task | function | Inherited from Task |
operator= | function | Inherited from Task |
run | function | Inherited from Task |
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 |
serialize | function | Inherited from ISerializable |
deserialize | function | Inherited from ISerializable |
Inherited from Task
| Kind | Name | Description |
|---|---|---|
friend | TaskRunner | Tasks belong to a TaskRunner instance. |
variable | _id | |
variable | _repeating | |
variable | _destroyed | |
function | Task | |
function | destroy virtual | Sets the task to destroyed state. |
function | destroyed virtual const | Signals that the task should be disposed of. |
function | repeating virtual const | Signals that the task should be called repeatedly by the TaskRunner. If this returns false the task will be cancelled. |
function | id virtual const | Unique task ID. |
function | ~Task virtual | |
function | Task | Deleted constructor. |
function | operator= | Deleted assignment operator. |
function | Task | Deleted constructor. |
function | operator= | Deleted assignment operator. |
function | run virtual override | 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. |
Inherited from Runnable
| Kind | Name | Description |
|---|---|---|
function | Runnable inline | |
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 | serialize virtual | Serializes this object's state into root. |
function | deserialize virtual | Populates this object's state from root. |
Friends
| Name | Description |
|---|---|
Scheduler |
{#scheduler-2}
Scheduler
friend class Scheduler
Defined in src/sched/include/icy/sched/task.h:111
Public Methods
| Return | Name | Description |
|---|---|---|
Task | Constructs a detached task without an associated scheduler. A trigger must be set before scheduling. | |
Task | Constructs a task associated with the given scheduler. | |
void | serialize virtual override | Serializes the task to JSON. |
void | deserialize virtual override | Deserializes the task from JSON. |
T * | createTrigger inline | Creates a trigger of type T, attaches it to this task, and returns a raw pointer to it. Ownership of the trigger is transferred to this task. |
void | setTrigger | Replaces the current trigger with trigger. |
sched::Trigger & | trigger | Returns a reference to the associated sched::Trigger or throws an exception. |
Scheduler & | scheduler | Returns a reference to the associated Scheduler or throws an exception. |
std::int64_t | remaining const | Returns the milliseconds remaining until the next scheduled timeout. An sched::Trigger must be associated or an exception will be thrown. |
std::string | type const | Returns the registered type string for this task. |
std::string | name const | Returns the human-readable display name of this task. |
void | setName | Sets the human-readable display name. |
{#task-2}
Task
Task(const std::string & type = "", const std::string & name = "")
Defined in src/sched/include/icy/sched/task.h:40
Constructs a detached task without an associated scheduler. A trigger must be set before scheduling.
Parameters
-
typeRegistered type name used by TaskFactory. -
nameHuman-readable display name.
{#task-3}
Task
Task(Scheduler & scheduler, const std::string & type, const std::string & name = "")
Defined in src/sched/include/icy/sched/task.h:46
Constructs a task associated with the given scheduler.
Parameters
-
schedulerScheduler that will own and run this task. -
typeRegistered type name used by TaskFactory. -
nameHuman-readable display name.
{#serialize-4}
serialize
virtual override
virtual void serialize(json::Value & root) override
Defined in src/sched/include/icy/sched/task.h:51
Serializes the task to JSON.
Reimplements
{#deserialize-4}
deserialize
virtual override
virtual void deserialize(json::Value & root) override
Defined in src/sched/include/icy/sched/task.h:54
Deserializes the task from JSON.
Reimplements
{#createtrigger}
createTrigger
inline
template<typename T> inline T * createTrigger()
Defined in src/sched/include/icy/sched/task.h:61
Creates a trigger of type T, attaches it to this task, and returns a raw pointer to it. Ownership of the trigger is transferred to this task.
Parameters
TA concrete subclass of sched::Trigger.
Returns
Raw pointer to the newly created trigger (still owned by this task).
{#settrigger}
setTrigger
void setTrigger(std::unique_ptr< sched::Trigger > trigger)
Defined in src/sched/include/icy/sched/task.h:71
Replaces the current trigger with trigger.
Parameters
triggerOwning pointer to the new trigger; must not be null before calling.
{#trigger}
trigger
sched::Trigger & trigger()
Defined in src/sched/include/icy/sched/task.h:75
Returns a reference to the associated sched::Trigger or throws an exception.
{#scheduler-3}
scheduler
Scheduler & scheduler()
Defined in src/sched/include/icy/sched/task.h:79
Returns a reference to the associated Scheduler or throws an exception.
{#remaining}
remaining
const
std::int64_t remaining() const
Defined in src/sched/include/icy/sched/task.h:85
Returns the milliseconds remaining until the next scheduled timeout. An sched::Trigger must be associated or an exception will be thrown.
{#type-16}
type
const
std::string type() const
Defined in src/sched/include/icy/sched/task.h:88
Returns the registered type string for this task.
{#name-9}
name
const
std::string name() const
Defined in src/sched/include/icy/sched/task.h:91
Returns the human-readable display name of this task.
{#setname-1}
setName
void setName(const std::string & name)
Defined in src/sched/include/icy/sched/task.h:95
Sets the human-readable display name.
Parameters
nameNew display name.
Protected Attributes
| Return | Name | Description |
|---|---|---|
std::string | _type | |
std::string | _name | |
sched::Scheduler * | _scheduler | |
std::unique_ptr< sched::Trigger > | _trigger | |
std::mutex | _mutex |
{#_type-2}
_type
std::string _type
Defined in src/sched/include/icy/sched/task.h:113
{#_name-1}
_name
std::string _name
Defined in src/sched/include/icy/sched/task.h:114
{#_scheduler}
_scheduler
sched::Scheduler * _scheduler
Defined in src/sched/include/icy/sched/task.h:115
{#_trigger}
_trigger
std::unique_ptr< sched::Trigger > _trigger
Defined in src/sched/include/icy/sched/task.h:116
{#_mutex-14}
_mutex
std::mutex _mutex
Defined in src/sched/include/icy/sched/task.h:117
Protected Methods
| Return | Name | Description |
|---|---|---|
bool | beforeRun virtual | |
void | run virtual override | 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. |
bool | afterRun virtual |
{#beforerun}
beforeRun
virtual
virtual bool beforeRun()
Defined in src/sched/include/icy/sched/task.h:100
{#run-7}
run
virtual override
virtual void run() override
Defined in src/sched/include/icy/sched/task.h:101
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
{#afterrun}
afterRun
virtual
virtual bool afterRun()
Defined in src/sched/include/icy/sched/task.h:102
{#taskfactory}
TaskFactory
#include <icy/sched/taskfactory.h>
class TaskFactory
Defined in src/sched/include/icy/sched/taskfactory.h:49
The TaskFactory can dynamically instantiate registered sched::Task and sched::Trigger classes from named strings.
List of all members
| Name | Kind | Owner |
|---|---|---|
createTask | function | Declared here |
registerTask | function | Declared here |
unregisterTask | function | Declared here |
tasks | function | Declared here |
createTrigger | function | Declared here |
registerTrigger | function | Declared here |
unregisterTrigger | function | Declared here |
triggers | function | Declared here |
getDefault | function | Declared here |
_mutex | variable | Declared here |
_tasks | variable | Declared here |
_triggers | variable | Declared here |
TaskMap | typedef | Declared here |
TriggerMap | typedef | Declared here |
Public Methods
| Return | Name | Description |
|---|---|---|
std::unique_ptr< sched::Task > | createTask inline | Instantiates and returns a registered task by type name. |
void | registerTask inline | Registers a task type T under the given name. Subsequent calls to createTask() with this type will return a T instance. |
void | unregisterTask inline | Removes the task registration for type. No-op if not registered. |
TaskMap | tasks const inline | Returns a snapshot copy of the registered task map. |
std::unique_ptr< sched::Trigger > | createTrigger inline | Instantiates and returns a registered trigger by type name. |
void | registerTrigger inline | Registers a trigger type T under the given name. |
void | unregisterTrigger inline | Removes the trigger registration for type. No-op if not registered. |
TriggerMap | triggers const inline | Returns a snapshot copy of the registered trigger map. |
{#createtask}
createTask
inline
inline std::unique_ptr< sched::Task > createTask(const std::string & type)
Defined in src/sched/include/icy/sched/taskfactory.h:67
Instantiates and returns a registered task by type name.
Parameters
typeRegistered type name.
Returns
Owning pointer to the new task instance.
Exceptions
std::runtime_erroriftypeis not registered.
{#registertask}
registerTask
inline
template<typename T> inline void registerTask(const std::string & type)
Defined in src/sched/include/icy/sched/taskfactory.h:81
Registers a task type T under the given name. Subsequent calls to createTask() with this type will return a T instance.
Parameters
TConcrete subclass of sched::Task with a default constructor.
Parameters
typeType name string to register.
{#unregistertask}
unregisterTask
inline
inline void unregisterTask(const std::string & type)
Defined in src/sched/include/icy/sched/taskfactory.h:89
Removes the task registration for type. No-op if not registered.
Parameters
typeType name to deregister.
{#tasks-2}
tasks
const inline
inline TaskMap tasks() const
Defined in src/sched/include/icy/sched/taskfactory.h:99
Returns a snapshot copy of the registered task map.
{#createtrigger-1}
createTrigger
inline
inline std::unique_ptr< sched::Trigger > createTrigger(const std::string & type)
Defined in src/sched/include/icy/sched/taskfactory.h:114
Instantiates and returns a registered trigger by type name.
Parameters
typeRegistered type name.
Returns
Owning pointer to the new trigger instance.
Exceptions
std::runtime_erroriftypeis not registered.
{#registertrigger}
registerTrigger
inline
template<typename T> inline void registerTrigger(const std::string & type)
Defined in src/sched/include/icy/sched/taskfactory.h:127
Registers a trigger type T under the given name.
Parameters
TConcrete subclass of sched::Trigger with a default constructor.
Parameters
typeType name string to register.
{#unregistertrigger}
unregisterTrigger
inline
inline void unregisterTrigger(const std::string & type)
Defined in src/sched/include/icy/sched/taskfactory.h:135
Removes the trigger registration for type. No-op if not registered.
Parameters
typeType name to deregister.
{#triggers}
triggers
const inline
inline TriggerMap triggers() const
Defined in src/sched/include/icy/sched/taskfactory.h:145
Returns a snapshot copy of the registered trigger map.
Public Static Methods
| Return | Name | Description |
|---|---|---|
TaskFactory & | getDefault static inline | Returns the default TaskFactory singleton. |
{#getdefault-3}
getDefault
static inline
static inline TaskFactory & getDefault()
Defined in src/sched/include/icy/sched/taskfactory.h:53
Returns the default TaskFactory singleton.
Protected Attributes
| Return | Name | Description |
|---|---|---|
std::mutex | _mutex | |
TaskMap | _tasks | |
TriggerMap | _triggers |
{#_mutex-15}
_mutex
std::mutex _mutex
Defined in src/sched/include/icy/sched/taskfactory.h:152
{#_tasks-2}
_tasks
TaskMap _tasks
Defined in src/sched/include/icy/sched/taskfactory.h:154
{#_triggers}
_triggers
TriggerMap _triggers
Defined in src/sched/include/icy/sched/taskfactory.h:155
Public Types
| Name | Description |
|---|---|
TaskMap | Scheduled Tasks. |
TriggerMap | Schedule Triggers. |
{#taskmap}
TaskMap
using TaskMap = std::map< std::string, std::unique_ptr< sched::Task >(*)()>
Defined in src/sched/include/icy/sched/taskfactory.h:61
Scheduled Tasks.
{#triggermap}
TriggerMap
using TriggerMap = std::map< std::string, std::unique_ptr< sched::Trigger >(*)()>
Defined in src/sched/include/icy/sched/taskfactory.h:108
Schedule Triggers.
{#dailytrigger}
DailyTrigger
#include <icy/sched/trigger.h>
struct DailyTrigger
Defined in src/sched/include/icy/sched/trigger.h:167
Inherits:
Trigger
Trigger that fires once per day at a configured time, with optional day-of-week exclusions.
List of all members
| Name | Kind | Owner |
|---|---|---|
timeOfDay | variable | Declared here |
daysExcluded | variable | Declared here |
DailyTrigger | function | Declared here |
update | function | Declared here |
type | variable | Inherited from Trigger |
name | variable | Inherited from Trigger |
timesRun | variable | Inherited from Trigger |
createdAt | variable | Inherited from Trigger |
scheduleAt | variable | Inherited from Trigger |
lastRunAt | variable | Inherited from Trigger |
Trigger | function | Inherited from Trigger |
update | function | Inherited from Trigger |
remaining | function | Inherited from Trigger |
timeout | function | Inherited from Trigger |
expired | function | Inherited from Trigger |
serialize | function | Inherited from Trigger |
deserialize | function | Inherited from Trigger |
serialize | function | Inherited from ISerializable |
deserialize | function | Inherited from ISerializable |
Inherited from Trigger
| Kind | Name | Description |
|---|---|---|
variable | type | The type of this trigger class. |
variable | name | The display name of this trigger class. |
variable | timesRun | The number of times the task has run since creation; |
variable | createdAt | The time the task was created. |
variable | scheduleAt | The time the task is scheduled to run. |
variable | lastRunAt | The time the task was last run. |
function | Trigger | |
function | update virtual | Updates the scheduleAt value to the next scheduled time. |
function | remaining virtual | Returns the milliseconds remaining until the next scheduled timeout. |
function | timeout virtual | Returns true if the task is ready to be run, false otherwise. |
function | expired virtual | Returns true if the task is expired and should be destroyed. Returns false by default. |
function | serialize virtual override | Serializes timing state (type, name, createdAt, scheduleAt, lastRunAt, timesRun) to root. |
function | deserialize virtual override | Deserializes timing state from root. |
Inherited from ISerializable
| Kind | Name | Description |
|---|---|---|
function | serialize virtual | Serializes this object's state into root. |
function | deserialize virtual | Populates this object's state from root. |
Public Attributes
| Return | Name | Description |
|---|---|---|
DateTime | timeOfDay | This value represents the time of day the task will trigger. The date part of the timestamp is redundant. |
std::vector< DaysOfTheWeek > | daysExcluded | Days of the week can be excluded by adding the appropriate bit flag here. |
{#timeofday}
timeOfDay
DateTime timeOfDay
Defined in src/sched/include/icy/sched/trigger.h:179
This value represents the time of day the task will trigger. The date part of the timestamp is redundant.
{#daysexcluded}
daysExcluded
std::vector< DaysOfTheWeek > daysExcluded
Defined in src/sched/include/icy/sched/trigger.h:183
Days of the week can be excluded by adding the appropriate bit flag here.
Public Methods
| Return | Name | Description |
|---|---|---|
DailyTrigger | Constructs the trigger with type "DailyTrigger". | |
void | update virtual override | Computes the next scheduleAt value by advancing to the next non-excluded weekday at the configured timeOfDay. |
{#dailytrigger-1}
DailyTrigger
DailyTrigger()
Defined in src/sched/include/icy/sched/trigger.h:170
Constructs the trigger with type "DailyTrigger".
{#update-2}
update
virtual override
virtual void update() override
Defined in src/sched/include/icy/sched/trigger.h:174
Computes the next scheduleAt value by advancing to the next non-excluded weekday at the configured timeOfDay.
Reimplements
{#intervaltrigger}
IntervalTrigger
#include <icy/sched/trigger.h>
struct IntervalTrigger
Defined in src/sched/include/icy/sched/trigger.h:133
Inherits:
Trigger
Trigger that fires repeatedly at a fixed time interval.
List of all members
| Name | Kind | Owner |
|---|---|---|
interval | variable | Declared here |
maxTimes | variable | Declared here |
IntervalTrigger | function | Declared here |
update | function | Declared here |
expired | function | Declared here |
serialize | function | Declared here |
deserialize | function | Declared here |
type | variable | Inherited from Trigger |
name | variable | Inherited from Trigger |
timesRun | variable | Inherited from Trigger |
createdAt | variable | Inherited from Trigger |
scheduleAt | variable | Inherited from Trigger |
lastRunAt | variable | Inherited from Trigger |
Trigger | function | Inherited from Trigger |
update | function | Inherited from Trigger |
remaining | function | Inherited from Trigger |
timeout | function | Inherited from Trigger |
expired | function | Inherited from Trigger |
serialize | function | Inherited from Trigger |
deserialize | function | Inherited from Trigger |
serialize | function | Inherited from ISerializable |
deserialize | function | Inherited from ISerializable |
Inherited from Trigger
| Kind | Name | Description |
|---|---|---|
variable | type | The type of this trigger class. |
variable | name | The display name of this trigger class. |
variable | timesRun | The number of times the task has run since creation; |
variable | createdAt | The time the task was created. |
variable | scheduleAt | The time the task is scheduled to run. |
variable | lastRunAt | The time the task was last run. |
function | Trigger | |
function | update virtual | Updates the scheduleAt value to the next scheduled time. |
function | remaining virtual | Returns the milliseconds remaining until the next scheduled timeout. |
function | timeout virtual | Returns true if the task is ready to be run, false otherwise. |
function | expired virtual | Returns true if the task is expired and should be destroyed. Returns false by default. |
function | serialize virtual override | Serializes timing state (type, name, createdAt, scheduleAt, lastRunAt, timesRun) to root. |
function | deserialize virtual override | Deserializes timing state from root. |
Inherited from ISerializable
| Kind | Name | Description |
|---|---|---|
function | serialize virtual | Serializes this object's state into root. |
function | deserialize virtual | Populates this object's state from root. |
Public Attributes
| Return | Name | Description |
|---|---|---|
Timespan | interval | This value represents the interval to wait before running the task. |
int | maxTimes | The maximum number of times the task will be run before it is destroyed. 0 for no effect. |
{#interval}
interval
Timespan interval
Defined in src/sched/include/icy/sched/trigger.h:155
This value represents the interval to wait before running the task.
{#maxtimes}
maxTimes
int maxTimes
Defined in src/sched/include/icy/sched/trigger.h:160
The maximum number of times the task will be run before it is destroyed. 0 for no effect.
Public Methods
| Return | Name | Description |
|---|---|---|
IntervalTrigger | Constructs the trigger with type "IntervalTrigger" and maxTimes = 0 (unlimited). | |
void | update virtual override | Advances scheduleAt by one [interval](#interval) period. |
bool | expired virtual override | Returns true when maxTimes > 0 and timesRun >= maxTimes. |
void | serialize virtual override | Serializes interval fields (days, hours, minutes, seconds) in addition to base fields. |
void | deserialize virtual override | Deserializes interval fields from root. Throws if the resulting interval is zero. |
{#intervaltrigger-1}
IntervalTrigger
IntervalTrigger()
Defined in src/sched/include/icy/sched/trigger.h:136
Constructs the trigger with type "IntervalTrigger" and maxTimes = 0 (unlimited).
{#update-3}
update
virtual override
virtual void update() override
Defined in src/sched/include/icy/sched/trigger.h:139
Advances scheduleAt by one [interval](#interval) period.
Reimplements
{#expired-2}
expired
virtual override
virtual bool expired() override
Defined in src/sched/include/icy/sched/trigger.h:142
Returns true when maxTimes > 0 and timesRun >= maxTimes.
Reimplements
{#serialize-2}
serialize
virtual override
virtual void serialize(json::Value & root) override
Defined in src/sched/include/icy/sched/trigger.h:146
Serializes interval fields (days, hours, minutes, seconds) in addition to base fields.
Parameters
rootJSON object to populate.
Reimplements
{#deserialize-2}
deserialize
virtual override
virtual void deserialize(json::Value & root) override
Defined in src/sched/include/icy/sched/trigger.h:151
Deserializes interval fields from root. Throws if the resulting interval is zero.
Parameters
rootJSON object previously produced by serialize().
Reimplements
{#onceonlytrigger}
OnceOnlyTrigger
#include <icy/sched/trigger.h>
struct OnceOnlyTrigger
Defined in src/sched/include/icy/sched/trigger.h:113
Inherits:
Trigger
Trigger that fires exactly once at the scheduled time and then expires.
List of all members
| Name | Kind | Owner |
|---|---|---|
OnceOnlyTrigger | function | Declared here |
update | function | Declared here |
expired | function | Declared here |
type | variable | Inherited from Trigger |
name | variable | Inherited from Trigger |
timesRun | variable | Inherited from Trigger |
createdAt | variable | Inherited from Trigger |
scheduleAt | variable | Inherited from Trigger |
lastRunAt | variable | Inherited from Trigger |
Trigger | function | Inherited from Trigger |
update | function | Inherited from Trigger |
remaining | function | Inherited from Trigger |
timeout | function | Inherited from Trigger |
expired | function | Inherited from Trigger |
serialize | function | Inherited from Trigger |
deserialize | function | Inherited from Trigger |
serialize | function | Inherited from ISerializable |
deserialize | function | Inherited from ISerializable |
Inherited from Trigger
| Kind | Name | Description |
|---|---|---|
variable | type | The type of this trigger class. |
variable | name | The display name of this trigger class. |
variable | timesRun | The number of times the task has run since creation; |
variable | createdAt | The time the task was created. |
variable | scheduleAt | The time the task is scheduled to run. |
variable | lastRunAt | The time the task was last run. |
function | Trigger | |
function | update virtual | Updates the scheduleAt value to the next scheduled time. |
function | remaining virtual | Returns the milliseconds remaining until the next scheduled timeout. |
function | timeout virtual | Returns true if the task is ready to be run, false otherwise. |
function | expired virtual | Returns true if the task is expired and should be destroyed. Returns false by default. |
function | serialize virtual override | Serializes timing state (type, name, createdAt, scheduleAt, lastRunAt, timesRun) to root. |
function | deserialize virtual override | Deserializes timing state from root. |
Inherited from ISerializable
| Kind | Name | Description |
|---|---|---|
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 |
|---|---|---|
OnceOnlyTrigger | Constructs the trigger with type "OnceOnlyTrigger". | |
void | update virtual inline override | No-op; scheduleAt is set once at construction and never advanced. |
bool | expired virtual override | Returns true after the task has run at least once. |
{#onceonlytrigger-1}
OnceOnlyTrigger
OnceOnlyTrigger()
Defined in src/sched/include/icy/sched/trigger.h:116
Constructs the trigger with type "OnceOnlyTrigger".
{#update-4}
update
virtual inline override
virtual inline void update() override
Defined in src/sched/include/icy/sched/trigger.h:119
No-op; scheduleAt is set once at construction and never advanced.
Reimplements
{#expired-3}
expired
virtual override
virtual bool expired() override
Defined in src/sched/include/icy/sched/trigger.h:126
Returns true after the task has run at least once.
Reimplements
{#trigger-1}
Trigger
#include <icy/sched/trigger.h>
struct Trigger
Defined in src/sched/include/icy/sched/trigger.h:58
Inherits:
ISerializableSubclassed by:DailyTrigger,IntervalTrigger,OnceOnlyTrigger
Base class for scheduled task triggers that determine when a task should run.
List of all members
| Name | Kind | Owner |
|---|---|---|
type | variable | Declared here |
name | variable | Declared here |
timesRun | variable | Declared here |
createdAt | variable | Declared here |
scheduleAt | variable | Declared here |
lastRunAt | variable | Declared here |
Trigger | function | Declared here |
update | function | Declared here |
remaining | function | Declared here |
timeout | function | Declared here |
expired | function | Declared here |
serialize | function | Declared here |
deserialize | function | Declared here |
serialize | function | Inherited from ISerializable |
deserialize | function | Inherited from ISerializable |
Inherited from ISerializable
| Kind | Name | Description |
|---|---|---|
function | serialize virtual | Serializes this object's state into root. |
function | deserialize virtual | Populates this object's state from root. |
Public Attributes
| Return | Name | Description |
|---|---|---|
std::string | type | The type of this trigger class. |
std::string | name | The display name of this trigger class. |
int | timesRun | The number of times the task has run since creation; |
DateTime | createdAt | The time the task was created. |
DateTime | scheduleAt | The time the task is scheduled to run. |
DateTime | lastRunAt | The time the task was last run. |
{#type-17}
type
std::string type
Defined in src/sched/include/icy/sched/trigger.h:90
The type of this trigger class.
{#name-10}
name
std::string name
Defined in src/sched/include/icy/sched/trigger.h:93
The display name of this trigger class.
{#timesrun}
timesRun
int timesRun
Defined in src/sched/include/icy/sched/trigger.h:97
The number of times the task has run since creation;
{#createdat}
createdAt
DateTime createdAt
Defined in src/sched/include/icy/sched/trigger.h:100
The time the task was created.
{#scheduleat}
scheduleAt
DateTime scheduleAt
Defined in src/sched/include/icy/sched/trigger.h:103
The time the task is scheduled to run.
{#lastrunat}
lastRunAt
DateTime lastRunAt
Defined in src/sched/include/icy/sched/trigger.h:106
The time the task was last run.
Public Methods
| Return | Name | Description |
|---|---|---|
Trigger | ||
void | update virtual | Updates the scheduleAt value to the next scheduled time. |
std::int64_t | remaining virtual | Returns the milliseconds remaining until the next scheduled timeout. |
bool | timeout virtual | Returns true if the task is ready to be run, false otherwise. |
bool | expired virtual | Returns true if the task is expired and should be destroyed. Returns false by default. |
void | serialize virtual override | Serializes timing state (type, name, createdAt, scheduleAt, lastRunAt, timesRun) to root. |
void | deserialize virtual override | Deserializes timing state from root. |
{#trigger-2}
Trigger
Trigger(const std::string & type = "", const std::string & name = "")
Defined in src/sched/include/icy/sched/trigger.h:62
Parameters
-
typeRegistered type name used by TaskFactory. -
nameHuman-readable display name.
{#update-6}
update
virtual
virtual void update()
Defined in src/sched/include/icy/sched/trigger.h:66
Updates the scheduleAt value to the next scheduled time.
Reimplemented by
{#remaining-1}
remaining
virtual
virtual std::int64_t remaining()
Defined in src/sched/include/icy/sched/trigger.h:70
Returns the milliseconds remaining until the next scheduled timeout.
{#timeout-4}
timeout
virtual
virtual bool timeout()
Defined in src/sched/include/icy/sched/trigger.h:74
Returns true if the task is ready to be run, false otherwise.
{#expired-4}
expired
virtual
virtual bool expired()
Defined in src/sched/include/icy/sched/trigger.h:79
Returns true if the task is expired and should be destroyed. Returns false by default.
Reimplemented by
{#serialize-5}
serialize
virtual override
virtual void serialize(json::Value & root) override
Defined in src/sched/include/icy/sched/trigger.h:83
Serializes timing state (type, name, createdAt, scheduleAt, lastRunAt, timesRun) to root.
Parameters
rootJSON object to populate.
Reimplements
Reimplemented by
{#deserialize-5}
deserialize
virtual override
virtual void deserialize(json::Value & root) override
Defined in src/sched/include/icy/sched/trigger.h:87
Deserializes timing state from root.
Parameters
rootJSON object previously produced by serialize().