use std::io;
use std::os::fd::RawFd;
use std::sync::atomic::{AtomicBool, Ordering::Relaxed};
#[derive(Debug)]
pub(crate) struct Waker {
woken: AtomicBool,
}
impl Waker {
pub(crate) fn new_unregistered() -> io::Result<Waker> {
Ok(Waker {
woken: AtomicBool::new(false),
})
}
pub(crate) fn wake(&self) -> io::Result<()> {
self.woken.store(true, Relaxed);
Ok(())
}
pub(crate) fn fd(&self) -> Option<RawFd> {
None
}
pub(crate) fn woken(&self) -> bool {
self.woken.load(Relaxed)
}
pub(crate) fn ack_and_reset(&self) {
self.woken.store(false, Relaxed);
}
}