use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum LifecycleState {
Created,
Initializing,
Running,
Stopping,
Stopped,
Failed,
}
#[derive(Debug)]
pub struct LifecycleManager {
state: Arc<AtomicBool>,
}
impl LifecycleManager {
pub fn new() -> Self {
Self {
state: Arc::new(AtomicBool::new(false)),
}
}
pub fn is_running(&self) -> bool {
self.state.load(Ordering::SeqCst)
}
pub fn set_running(&self, running: bool) {
self.state.store(running, Ordering::SeqCst);
}
}
impl Default for LifecycleManager {
fn default() -> Self {
Self::new()
}
}