nitinol_process/context/status.rs
1use std::sync::Arc;
2use tokio::sync::RwLock;
3
4pub struct Status(Arc<RwLock<bool>>);
5
6impl Clone for Status {
7 fn clone(&self) -> Self {
8 Self(Arc::clone(&self.0))
9 }
10}
11
12impl Status {
13 pub fn new(is_active: bool) -> Self {
14 Self(Arc::new(RwLock::new(is_active)))
15 }
16
17 pub async fn is_active(&self) -> bool {
18 *self.0.read().await
19 }
20
21 pub async fn poison(&self) {
22 let mut guard = self.0.write().await;
23 *guard = false;
24 }
25}