modality_trace_recorder_plugin/
interruptor.rs1use std::sync::atomic::{AtomicBool, Ordering::SeqCst};
2use std::sync::Arc;
3
4#[derive(Clone, Debug)]
5#[repr(transparent)]
6pub struct Interruptor(Arc<AtomicBool>);
7
8impl Interruptor {
9 pub fn new() -> Self {
10 Interruptor(Arc::new(AtomicBool::new(false)))
11 }
12
13 pub fn set(&self) {
14 self.0.store(true, SeqCst);
15 }
16
17 pub fn is_set(&self) -> bool {
18 self.0.load(SeqCst)
19 }
20}
21
22impl Default for Interruptor {
23 fn default() -> Self {
24 Self::new()
25 }
26}