1. Overview
Periodic task scheduler implementation. Runs each named task in its own stoppable thread, supports replacement of existing tasks and joins all workers during shutdown.
The original source path is:
src/task/TaskRunner.cpp
2. Role in the Daemon
This file participates in the privileged BastionGuard Secure Connection daemon. It uses the shared bsc models and follows the daemon-wide fallback strategy: optional high-fidelity backends are used when available, while portable polling or stub behavior preserves service startup.
3. Namespaces
bsc::task
4. Dependencies and Included Interfaces
bsc/task/TaskRunner.hppthread
5. API and Functions
The file declares or implements the following callable entry points:
TaskRunner::~TaskRunner()TaskRunner::every(const std::string& name, std::chrono::milliseconds interval, std::function<void()> fn)TaskRunner::stop_task(const std::string& name)TaskRunner::has_task(const std::string& name)TaskRunner::stop()
6. External Resources and Protocol Values
Relevant paths, endpoints, command names or policy values referenced by this file include:
bsc/task/TaskRunner.hpp
7. Concurrency and Lifecycle
- Uses one or more worker threads.
8. Implementation Considerations
- Replacing a task with the same name first stops and joins the existing worker.
- Task callbacks execute on independent threads and must be exception-safe.
- The scheduler uses cooperative stop flags rather than forcibly terminating threads.
- Shared state is protected by mutexes; callers should avoid holding external locks while invoking callbacks.
- The file creates or manages worker threads and requires deterministic stop/join behavior during daemon shutdown.
9. Source Metrics
| Metric | Value |
|---|---|
| File size | 1758 bytes |
| Lines | 60 |
| Detected API entries | 5 |
| Detected types | 0 |
