use std::sync::atomic::{AtomicU8, Ordering};
cfg_select! {
windows => {
mod iocp;
pub use iocp::*;
}
fusion => {
mod fusion;
mod poll;
mod iour;
pub use fusion::*;
}
io_uring => {
mod iour;
pub use iour::*;
}
stub => {
mod stub;
pub use stub::*;
}
unix => {
mod poll;
pub use poll::*;
}
_ => {}
}
crate::assert_not_impl!(Driver, Send);
crate::assert_not_impl!(Driver, Sync);
pub trait PollFirst {
fn poll_first(&mut self);
}
const IDLE: u8 = 0b00;
const NOTIFIED: u8 = 0b01;
const AWAKE: u8 = 0b10;
#[derive(Debug)]
struct AwakeFlag(AtomicU8);
impl AwakeFlag {
pub fn new() -> Self {
Self(AtomicU8::new(IDLE))
}
pub fn set(&self) {
self.0.store(AWAKE, Ordering::Release);
}
pub fn reset(&self) -> bool {
(self.0.swap(IDLE, Ordering::AcqRel) & NOTIFIED) != 0
}
pub fn wake(&self) -> bool {
self.0.fetch_or(NOTIFIED, Ordering::AcqRel) != 0
}
}