Skip to main content

zond_engine/core/
handle.rs

1use std::sync::Arc;
2use std::sync::atomic::{AtomicBool, Ordering};
3
4#[derive(Debug, Clone)]
5pub struct ScanHandle {
6    abort: Arc<AtomicBool>,
7}
8
9impl Default for ScanHandle {
10    fn default() -> Self {
11        Self::new()
12    }
13}
14
15impl ScanHandle {
16    pub fn new() -> Self {
17        let abort = Arc::new(AtomicBool::new(false));
18        Self { abort }
19    }
20
21    pub fn abort(&self) {
22        self.abort.store(true, Ordering::SeqCst);
23    }
24
25    pub fn should_stop(&self) -> bool {
26        self.abort.load(Ordering::SeqCst)
27    }
28}