Backup commit

My backspace key started ghosting. Nothing works atm.
This commit is contained in:
2024-01-27 14:50:33 +00:00
parent f77e4fd90a
commit a8887227e5
236 changed files with 10946 additions and 8977 deletions

View File

@@ -0,0 +1,23 @@
//! Flag for cancelling scheduled operations
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
/// A single-fire thread-safe boolean flag with relaxed ordering
#[derive(Debug, Clone)]
pub struct CancelFlag(Arc<AtomicBool>);
impl CancelFlag {
/// Create a new canceller
pub fn new() -> Self { CancelFlag(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 CancelFlag {
fn default() -> Self { Self::new() }
}