Generic mutation scheduling system

IO adapted to use it
Also, Atoms can now dispatch type-erased requests
This commit is contained in:
2023-09-14 22:54:42 +01:00
parent 8c866967a9
commit 3c0056c2db
51 changed files with 991 additions and 379 deletions

View File

@@ -0,0 +1,32 @@
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
use crate::atomic_inert;
/// A single-fire thread-safe boolean flag with relaxed ordering
#[derive(Debug, Clone)]
pub struct Canceller(Arc<AtomicBool>);
atomic_inert!(Canceller, typestr = "a canceller");
impl Canceller {
/// Create a new canceller
pub fn new() -> Self {
Canceller(Arc::new(AtomicBool::new(false)))
}
/// Check whether the operation has been cancelled
pub fn is_cancelled(&self) -> bool {
self.0.load(Ordering::Relaxed)
}
/// Cancel the operation
pub fn cancel(&self) {
self.0.store(true, Ordering::Relaxed)
}
}
impl Default for Canceller {
fn default() -> Self {
Self::new()
}
}