1use mio::Registry;
3use std::io;
4use std::time::Duration;
5
6#[derive(Debug)]
8pub struct Poll {
9 poll: mio::Poll,
10 events: mio::Events,
11}
12
13impl Poll {
14 pub fn with_capacity(capacity: usize) -> io::Result<Poll> {
16 let poll = mio::Poll::new()?;
17 Ok(Poll {
18 poll,
19 events: mio::Events::with_capacity(capacity),
20 })
21 }
22
23 pub fn poll<I>(&mut self, timeout: I) -> io::Result<&mio::Events>
25 where
26 I: Into<Option<Duration>>,
27 {
28 self.poll.poll(&mut self.events, timeout.into())?;
29 Ok(&self.events)
30 }
31
32 pub fn clear(&mut self) {
34 self.events.clear()
35 }
36
37 pub fn polled_events(&self) -> &mio::Events {
39 &self.events
40 }
41 pub fn registry(&self) -> &Registry {
43 self.poll.registry()
44 }
45}