use std::io::Result;
use registrar::Registrar;
use notification::Notification;
#[cfg(any(target_os = "linux", target_os = "android"))]
use epoll::KernelPoller;
#[cfg(any(target_os = "bitrig", target_os = "dragonfly",
target_os = "freebsd", target_os = "ios", target_os = "macos",
target_os = "netbsd", target_os = "openbsd"))]
pub use kqueue::KernelPoller;
pub struct Poller {
registrar: Registrar,
inner: KernelPoller
}
impl Poller {
pub fn new() -> Result<Poller> {
let inner = KernelPoller::new()?;
Ok(Poller {
registrar: Registrar::new(inner.get_registrar()),
inner: inner
})
}
pub fn get_registrar(&self) -> Registrar {
self.registrar.clone()
}
pub fn wait(&mut self, timeout_ms: usize) -> Result<Vec<Notification>> {
self.inner.wait(timeout_ms)
}
}