SatDump's internal task scheduler.
More...
#include <task_scheduler.h>
|
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.
|
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
-
running | internal; should the task scheduler thread still be running |
needs_update | internal; a task has just been added/removed |
scheduled_tasks | a map of the scheduled task name as defined by the user, and the associated ScheduledTask struct |
task_thread | the std::thread that runs scheduled tasks |
task_mtx | a mutex to protect the scheduled_tasks map from cross-thread operation |
cv | a condition_variable that controls waiting for a task in the task_thread |
◆ 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_name | the name of the scheduled task. Arbitrary, but must be used to delete the task later |
evt | a shared pointer to the EventBus event struct you want to schedule |
last_run | timestamp of the last time the task was run |
run_interval | time, 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_name | the 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: