22 lines
427 B
Rust
22 lines
427 B
Rust
use std::sync::atomic::{AtomicBool, Ordering};
|
|
|
|
#[derive(Default)]
|
|
pub struct LiveKeyState {
|
|
fill: AtomicBool,
|
|
}
|
|
|
|
impl LiveKeyState {
|
|
pub fn new() -> Self {
|
|
Self::default()
|
|
}
|
|
|
|
pub fn fill(&self) -> bool {
|
|
self.fill.load(Ordering::Relaxed)
|
|
}
|
|
|
|
pub fn flip_fill(&self) {
|
|
let current = self.fill.load(Ordering::Relaxed);
|
|
self.fill.store(!current, Ordering::Relaxed);
|
|
}
|
|
}
|