scirs2_core/profiling/
continuousmonitoring.rs1use std::sync::atomic::{AtomicBool, Ordering};
4use std::sync::Arc;
5use std::time::Duration;
6
7pub struct ContinuousMonitor {
9 running: Arc<AtomicBool>,
10 interval: Duration,
11}
12
13impl ContinuousMonitor {
14 pub fn new(interval: Duration) -> Self {
16 Self {
17 running: Arc::new(AtomicBool::new(false)),
18 interval,
19 }
20 }
21
22 pub fn start(&self) {
24 self.running.store(true, Ordering::SeqCst);
25 }
26
27 pub fn stop(&self) {
29 self.running.store(false, Ordering::SeqCst);
30 }
31
32 pub fn is_running(&self) -> bool {
34 self.running.load(Ordering::SeqCst)
35 }
36}