use mio::Registry;
use std::io;
use std::time::Duration;
#[derive(Debug)]
pub struct Poll {
poll: mio::Poll,
events: mio::Events,
}
impl Poll {
pub fn with_capacity(capacity: usize) -> io::Result<Poll> {
let poll = mio::Poll::new()?;
Ok(Poll {
poll,
events: mio::Events::with_capacity(capacity),
})
}
pub fn poll<I>(&mut self, timeout: I) -> io::Result<&mio::Events>
where
I: Into<Option<Duration>>,
{
self.poll.poll(&mut self.events, timeout.into())?;
Ok(&self.events)
}
pub fn clear(&mut self) {
self.events.clear()
}
pub fn polled_events(&self) -> &mio::Events {
&self.events
}
pub fn registry(&self) -> &Registry {
self.poll.registry()
}
}