rosrust/api/
mod.rs

1pub use self::clock::{Clock, Delay, Rate};
2pub use self::master::{Master, SystemState, Topic};
3pub use self::ros::{Parameter, Ros};
4use std::sync::atomic::{AtomicBool, Ordering};
5
6mod clock;
7pub mod error;
8pub mod handlers;
9mod master;
10mod naming;
11pub mod raii;
12pub mod resolve;
13mod ros;
14mod slave;
15
16pub struct ShutdownManager {
17    handler: Box<dyn Fn() + Send + Sync>,
18    should_shutdown: AtomicBool,
19}
20
21impl ShutdownManager {
22    pub fn new(handler: impl Fn() + Send + Sync + 'static) -> Self {
23        Self {
24            handler: Box::new(handler),
25            should_shutdown: AtomicBool::new(false),
26        }
27    }
28
29    pub fn awaiting_shutdown(&self) -> bool {
30        self.should_shutdown.load(Ordering::Relaxed)
31    }
32
33    pub fn shutdown(&self) {
34        (*self.handler)();
35        self.should_shutdown.store(true, Ordering::Relaxed)
36    }
37}