1. Overview
Periodic task scheduler interface. Declares named recurring tasks, replacement, cancellation, existence checks and global shutdown.
The original source path is:
include/bsc/task/TaskRunner.hpp
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
atomicchronofunctionalmemorythreadmutexstringunordered_map
5. Declared Types
class TaskRunnerstruct TaskState
6. State and Data Members
The interface declares the following relevant state members:
std::thread threadmutable std::mutex mutex_std::unordered_map<std::string, std::unique_ptr<TaskState>> tasks_
7. API and Functions
The file declares or implements the following callable entry points:
public: ~TaskRunner()void every(const std::string& name, std::chrono::milliseconds interval, std::function<void()> fn)bool stop_task(const std::string& name)bool has_task(const std::string& name) constvoid stop()
8. Concurrency and Lifecycle
- Uses one or more worker threads.
- Protects mutable shared data with std::mutex.
- Uses atomic flags for lifecycle or activity state.
9. Implementation Considerations
- 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.
- Atomic flags are used for low-cost lifecycle or activity state coordination.
10. Source Metrics
| Metric | Value |
|---|---|
| File size | 821 bytes |
| Lines | 35 |
| Detected API entries | 5 |
| Detected types | 2 |
