Multi-threaded background safety service executing periodic heartbeat supervision. Automatically verifies monitored task deadlines and dispatches WatchdogTimeoutEvent to the main event bus on violations.
More...
|
| void | beat (uint32_t serviceId) noexcept |
| | Submit a heartbeat for a monitored service.
|
| |
| void | join () noexcept |
| | Join background std::jthread cleanly.
|
| |
| EventSinkT< EventVariant > | mainSink () const noexcept |
| | Get an EventSink handle targeting the main application event queue.
|
| |
| template<typename Handler > |
| bool | on (Handler &&handler) |
| | Register an event handler for incoming events with automatic event type deduction.
|
| |
| bool | processOne () |
| | Process a single incoming event from the service queue.
|
| |
| std::size_t | pump () |
| | Pump all pending incoming events from the queue until empty.
|
| |
| std::size_t | pump (std::size_t maxEvents) |
| | Pump up to maxEvents pending incoming events from the queue.
|
| |
| template<typename EventType , typename Handler > |
| bool | registerHandler (Handler &&handler) |
| | Register an event handler for incoming events with explicit event type parameter.
|
| |
| bool | registerService (uint32_t serviceId, uint64_t timeoutNs) noexcept |
| | Register a service for supervision with maximum timeout in nanoseconds.
|
| |
| void | run (const std::stop_token &stopToken) |
| | Background worker loop executing periodic health supervision.
|
| |
| void | setContext (ServiceContextT< EventVariant > context) noexcept |
| |
| void | setWatchdogKickCallback (KickCallbackFn kickFn, void *userData=nullptr) noexcept |
| | Set callback to refresh the physical hardware watchdog (e.g. STM32 IWDG).
|
| |
| EventSinkT< EventVariant > | sink () noexcept |
| | Get an EventSink handle targeting this service's incoming event queue.
|
| |
| template<typename Derived > |
| void | startThread (Derived *derived) |
| | Start execution loop on dedicated std::jthread.
|
| |
| void | stop () noexcept |
| | Request cancellation on worker std::jthread.
|
| |
| const SupervisorType & | supervisor () const noexcept |
| |
| SupervisorType & | supervisor () noexcept |
| | Access underlying WatchdogSupervisor.
|
| |
| template<typename Rep , typename Period > |
| std::size_t | waitAndPump (const std::stop_token &stopToken, const std::chrono::duration< Rep, Period > &timeout) |
| | Wait for incoming events or timeout, then pump all available incoming events. Safe for use inside worker thread run(std::stop_token).
|
| |
| | WatchdogService (std::chrono::milliseconds checkInterval=std::chrono::milliseconds(20)) |
| |
template<typename
EventVariant = DefaultEvents, std::size_t MaxServices = 16, typename ClockPolicy = ChronoClockPolicy>
class corium::safety::WatchdogService< EventVariant, MaxServices, ClockPolicy >
Multi-threaded background safety service executing periodic heartbeat supervision. Automatically verifies monitored task deadlines and dispatches WatchdogTimeoutEvent to the main event bus on violations.
- Template Parameters
-
| EventVariant | Supported event variant list type. |
| MaxServices | Maximum number of monitored services (default 16). |
| ClockPolicy | Clock source strategy (defaults to ChronoClockPolicy). |
template<typename EventVariantType = DefaultEvents, typename QueuePolicy = BoundedMpscQueuePolicy<EventVariantType, 1024>, typename SignalPolicy = CallbackSignalPolicy, typename StoragePolicy = DefaultStoragePolicy, typename OverflowPolicy = DropNewestOverflowPolicy>
Join background std::jthread cleanly.
template<typename EventVariantType = DefaultEvents, typename QueuePolicy = BoundedMpscQueuePolicy<EventVariantType, 1024>, typename SignalPolicy = CallbackSignalPolicy, typename StoragePolicy = DefaultStoragePolicy, typename OverflowPolicy = DropNewestOverflowPolicy>
Get an EventSink handle targeting the main application event queue.
template<typename EventVariantType = DefaultEvents, typename QueuePolicy = BoundedMpscQueuePolicy<EventVariantType, 1024>, typename SignalPolicy = CallbackSignalPolicy, typename StoragePolicy = DefaultStoragePolicy, typename OverflowPolicy = DropNewestOverflowPolicy>
template<typename Handler >
| bool corium::Service< EventVariantType, QueuePolicy, SignalPolicy, StoragePolicy, OverflowPolicy >::on |
( |
Handler && |
handler | ) |
|
|
inlineinherited |
Register an event handler for incoming events with automatic event type deduction.
template<typename EventVariantType = DefaultEvents, typename QueuePolicy = BoundedMpscQueuePolicy<EventVariantType, 1024>, typename SignalPolicy = CallbackSignalPolicy, typename StoragePolicy = DefaultStoragePolicy, typename OverflowPolicy = DropNewestOverflowPolicy>
template<typename EventType >
Post an event into the main application event queue.
template<typename EventVariantType = DefaultEvents, typename QueuePolicy = BoundedMpscQueuePolicy<EventVariantType, 1024>, typename SignalPolicy = CallbackSignalPolicy, typename StoragePolicy = DefaultStoragePolicy, typename OverflowPolicy = DropNewestOverflowPolicy>
template<typename EventType >
| void corium::Service< EventVariantType, QueuePolicy, SignalPolicy, StoragePolicy, OverflowPolicy >::postHighPriority |
( |
EventType && |
event | ) |
const |
|
inlineprotectedinherited |
Post a high-priority event into the main application event queue.
template<typename EventVariantType = DefaultEvents, typename QueuePolicy = BoundedMpscQueuePolicy<EventVariantType, 1024>, typename SignalPolicy = CallbackSignalPolicy, typename StoragePolicy = DefaultStoragePolicy, typename OverflowPolicy = DropNewestOverflowPolicy>
| bool corium::Service< EventVariantType, QueuePolicy, SignalPolicy, StoragePolicy, OverflowPolicy >::processOne |
( |
| ) |
|
|
inlineinherited |
Process a single incoming event from the service queue.
- Returns
- true if an event was popped and dispatched; false if queue was empty.
template<typename EventVariantType = DefaultEvents, typename QueuePolicy = BoundedMpscQueuePolicy<EventVariantType, 1024>, typename SignalPolicy = CallbackSignalPolicy, typename StoragePolicy = DefaultStoragePolicy, typename OverflowPolicy = DropNewestOverflowPolicy>
| std::size_t corium::Service< EventVariantType, QueuePolicy, SignalPolicy, StoragePolicy, OverflowPolicy >::pump |
( |
| ) |
|
|
inlineinherited |
Pump all pending incoming events from the queue until empty.
- Returns
- Number of events processed.
template<typename EventVariantType = DefaultEvents, typename QueuePolicy = BoundedMpscQueuePolicy<EventVariantType, 1024>, typename SignalPolicy = CallbackSignalPolicy, typename StoragePolicy = DefaultStoragePolicy, typename OverflowPolicy = DropNewestOverflowPolicy>
| std::size_t corium::Service< EventVariantType, QueuePolicy, SignalPolicy, StoragePolicy, OverflowPolicy >::pump |
( |
std::size_t |
maxEvents | ) |
|
|
inlineinherited |
Pump up to maxEvents pending incoming events from the queue.
- Parameters
-
| maxEvents | Maximum number of events to process. |
- Returns
- Number of events processed.
template<typename EventVariantType = DefaultEvents, typename QueuePolicy = BoundedMpscQueuePolicy<EventVariantType, 1024>, typename SignalPolicy = CallbackSignalPolicy, typename StoragePolicy = DefaultStoragePolicy, typename OverflowPolicy = DropNewestOverflowPolicy>
template<typename EventType , typename Handler >
| bool corium::Service< EventVariantType, QueuePolicy, SignalPolicy, StoragePolicy, OverflowPolicy >::registerHandler |
( |
Handler && |
handler | ) |
|
|
inlineinherited |
Register an event handler for incoming events with explicit event type parameter.
template<typename EventVariantType = DefaultEvents, typename QueuePolicy = BoundedMpscQueuePolicy<EventVariantType, 1024>, typename SignalPolicy = CallbackSignalPolicy, typename StoragePolicy = DefaultStoragePolicy, typename OverflowPolicy = DropNewestOverflowPolicy>
template<typename TargetService , typename EventType >
Post an event directly to another registered service.
template<typename EventVariantType = DefaultEvents, typename QueuePolicy = BoundedMpscQueuePolicy<EventVariantType, 1024>, typename SignalPolicy = CallbackSignalPolicy, typename StoragePolicy = DefaultStoragePolicy, typename OverflowPolicy = DropNewestOverflowPolicy>
Get an EventSink handle targeting this service's incoming event queue.
template<typename EventVariantType = DefaultEvents, typename QueuePolicy = BoundedMpscQueuePolicy<EventVariantType, 1024>, typename SignalPolicy = CallbackSignalPolicy, typename StoragePolicy = DefaultStoragePolicy, typename OverflowPolicy = DropNewestOverflowPolicy>
template<typename Derived >
| void corium::BackgroundService< EventVariantType, QueuePolicy, SignalPolicy, StoragePolicy, OverflowPolicy >::startThread |
( |
Derived * |
derived | ) |
|
|
inlineinherited |
Start execution loop on dedicated std::jthread.
template<typename EventVariantType = DefaultEvents, typename QueuePolicy = BoundedMpscQueuePolicy<EventVariantType, 1024>, typename SignalPolicy = CallbackSignalPolicy, typename StoragePolicy = DefaultStoragePolicy, typename OverflowPolicy = DropNewestOverflowPolicy>
Request cancellation on worker std::jthread.
template<typename EventVariantType = DefaultEvents, typename QueuePolicy = BoundedMpscQueuePolicy<EventVariantType, 1024>, typename SignalPolicy = CallbackSignalPolicy, typename StoragePolicy = DefaultStoragePolicy, typename OverflowPolicy = DropNewestOverflowPolicy>
template<typename Rep , typename Period >
| std::size_t corium::BackgroundService< EventVariantType, QueuePolicy, SignalPolicy, StoragePolicy, OverflowPolicy >::waitAndPump |
( |
const std::stop_token & |
stopToken, |
|
|
const std::chrono::duration< Rep, Period > & |
timeout |
|
) |
| |
|
inlineinherited |
Wait for incoming events or timeout, then pump all available incoming events. Safe for use inside worker thread run(std::stop_token).
- Template Parameters
-
| Rep | Duration representation type. |
| Period | Duration period type. |
- Parameters
-
| stopToken | std::stop_token from run(stopToken). |
| timeout | Maximum duration to wait if queue is empty. |
- Returns
- Number of events processed.