SatDump 2.0.0-alpha-76a915210
Loading...
Searching...
No Matches
satdump::TaskScheduler Class Reference

SatDump's internal task scheduler. More...

#include <task_scheduler.h>

Public Member Functions

template<typename T>
void add_task (std::string task_name, std::shared_ptr< T > evt, time_t last_run, time_t run_interval)
 Add a new scheduled task.
void del_task (std::string task_name)
 Remove a scheduled task. Does nothing if no task by the given name is registered.

Detailed Description

SatDump's internal task scheduler.

Upon creation, this class creates a single thread that runs scheduled tasks as registered by other parts of the program. Developers can add and remove scheduled tasks by adding an EventBus event struct, along with the last run time and the run interval. Only one task is run at a time. By design, only one instance of this class is shared throughout the program.

Parameters
runninginternal; should the task scheduler thread still be running
needs_updateinternal; a task has just been added/removed
scheduled_tasksa map of the scheduled task name as defined by the user, and the associated ScheduledTask struct
task_threadthe std::thread that runs scheduled tasks
task_mtxa mutex to protect the scheduled_tasks map from cross-thread operation
cva condition_variable that controls waiting for a task in the task_thread

Member Function Documentation

◆ add_task()

template<typename T>
void satdump::TaskScheduler::add_task ( std::string task_name,
std::shared_ptr< T > evt,
time_t last_run,
time_t run_interval )
inline

Add a new scheduled task.

If a task is added with a name that already exists, the old task will be overwritten.

Parameters
task_namethe name of the scheduled task. Arbitrary, but must be used to delete the task later
evta shared pointer to the EventBus event struct you want to schedule
last_runtimestamp of the last time the task was run
run_intervaltime, in seconds, between task runs

◆ del_task()

void satdump::TaskScheduler::del_task ( std::string task_name)
inline

Remove a scheduled task. Does nothing if no task by the given name is registered.

Parameters
task_namethe name of the scheduled task. Arbitrary, but must match the name used to add the task

The documentation for this class was generated from the following files: