19 lines
384 B
Rust
19 lines
384 B
Rust
use std::sync::{
|
|
Arc,
|
|
atomic::{AtomicBool, Ordering},
|
|
};
|
|
|
|
/// A shared stop signal for one native compilation.
|
|
#[derive(Clone, Debug, Default)]
|
|
pub struct Cancellation(Arc<AtomicBool>);
|
|
|
|
impl Cancellation {
|
|
pub fn cancel(&self) {
|
|
self.0.store(true, Ordering::Release);
|
|
}
|
|
|
|
pub fn is_cancelled(&self) -> bool {
|
|
self.0.load(Ordering::Acquire)
|
|
}
|
|
}
|