mod error;
#[doc(inline)]
pub use error::Error;
mod runtime;
#[doc(inline)]
pub use runtime::{Events, IoToken, TimerToken, ProcessHandle, Runtime, RuntimeHandle};
mod timeouts;
pub use popol::{interest, Interest};
use std::io;
use std::sync::Arc;
#[derive(Clone)]
pub struct Waker(Arc<popol::Waker>);
impl Waker {
fn new<K: Eq + Clone>(sources: &mut popol::Sources<K>, key: K) -> Result<Waker, io::Error> {
let w = popol::Waker::new(sources, key)?;
Ok(Waker(Arc::new(w)))
}
pub fn wake(&self) {
let _ = self.0.wake();
}
}
pub struct Exit;
impl<E: std::error::Error> From<E> for Exit {
fn from(_: E) -> Exit {
Exit
}
}
pub trait Process: Send + 'static {
fn wakeup(&mut self, handle: &RuntimeHandle, events: Events) -> Result<(), Exit>;
fn setup(&mut self, _handle: &RuntimeHandle) -> Result<(), Exit> { Ok(()) }
fn shutdown(&mut self) {}
}