pub struct GuardSignals { /* private fields */ }Expand description
Signal controller for guard-style tick loops.
Sets up SIGINT/SIGTERM handling with double-tap support and exposes
a should_stop() flag that the loop checks between ticks.
Dropping GuardSignals stops the listener thread and joins it.
§Example
use std::time::Duration;
use sysprims_core::guard_signals::GuardSignals;
use sysprims_core::time::Tick;
let signals = GuardSignals::start().unwrap();
let mut tick = Tick::new(Duration::from_secs(5)).unwrap();
while !signals.should_stop() {
// do guard work …
tick.sleep_until_next();
}Implementations§
Source§impl GuardSignals
impl GuardSignals
Sourcepub fn start() -> SysprimsResult<Self>
pub fn start() -> SysprimsResult<Self>
Set up signal handlers and start the listener thread.
Registers SIGINT and SIGTERM handlers that set the stop flag,
enables double-tap (catalog defaults), and spawns a background
thread running SignalManager::listen().
If the listener exits early (error or unexpected return), the stop flag is set so the guard loop does not run without signal responsiveness.
Sourcepub fn should_stop(&self) -> bool
pub fn should_stop(&self) -> bool
Check whether a shutdown signal has been received.
Sourcepub fn request_stop(&self)
pub fn request_stop(&self)
Request stop (useful for programmatic shutdown, e.g. max-iterations).
Sourcepub fn manager(&self) -> &SignalManager
pub fn manager(&self) -> &SignalManager
Access the underlying SignalManager (for shutdown hooks or test injection).
Sourcepub fn stop_flag_handle(&self) -> StopFlagHandle
pub fn stop_flag_handle(&self) -> StopFlagHandle
Get a write handle to the shared stop flag.
Used by GuardStopHandle to request stop from another thread
without holding a reference to GuardSignals.