The Poll module
If you haven’t written or copied the code we presented in the Design and introduction to epoll section, it’s time to do it now. We’ll implement all the functions where we just had todo!()
earlier.
We start by implementing the methods on our Poll
struct. First up is opening the impl Poll
block and implementing the new
function:
ch04/a-epoll/src/poll.rs
impl Poll { pub fn new() -> Result<Self> { let res = unsafe { ffi::epoll_create(1) }; if res < 0 { return Err(io::Error::last_os_error()); } Ok(Self { registry: Registry { raw_fd: res }, ...