Something went wrong. Try again.
A hardware-accelerated GPU terminal emulator focusing to run in desktops and browsers.
Something went wrong. Try again.
846 B · 35 lines
Rust
at main
123456789101112131415161718192021222324252627282930313233343536use std::cell::RefCell;use std::ops::Deref;use std::task::Waker;
#[derive(Debug)]pub struct AtomicWaker(RefCell<Option<Waker>>);
impl AtomicWaker { pub const fn new() -> Self { Self(RefCell::new(None)) }
pub fn register(&self, waker: &Waker) { let mut this = self.0.borrow_mut();
if let Some(old_waker) = this.deref() { if old_waker.will_wake(waker) { return; } }
*this = Some(waker.clone()); }
pub fn wake(&self) { if let Some(waker) = self.0.borrow_mut().take() { waker.wake(); } }}
// SAFETY: Wasm without the `atomics` target feature is single-threaded.unsafe impl Send for AtomicWaker {}// SAFETY: Wasm without the `atomics` target feature is single-threaded.unsafe impl Sync for AtomicWaker {}