use std::time::Duration;
mod event;
pub use event::{Event, Fd, Interval, Oneshot};
mod base;
pub use base::{
Base, EventCallbackCtx, EventCallbackFlags, EventFlags, EvutilSocket, ExitReason, LoopFlags,
};
pub(crate) struct EventCallbackWrapper<S, T, F> {
inner: F,
event: Option<Event<S>>,
_phantom: std::marker::PhantomData<T>,
}
impl Base {
pub fn turn(&self) -> ExitReason {
self.loop_(LoopFlags::NONBLOCK)
}
pub fn run_timeout(&self, timeout: Duration) -> ExitReason {
if self.loopexit(timeout) != 0 {
return ExitReason::Error;
};
self.loop_(LoopFlags::empty())
}
pub fn run_until_event(&self, timeout: Option<Duration>) -> ExitReason {
if let Some(timeout) = timeout {
if self.loopexit(timeout) != 0 {
return ExitReason::Error;
}
}
self.loop_(LoopFlags::ONCE)
}
pub fn run(&self) -> ExitReason {
self.loop_(LoopFlags::empty())
}
}