1 //! Both `kqueue(2)` and `epoll(2)` don't need to hold any user space state. 2 3 use std::io; 4 use std::os::fd::RawFd; 5 6 use crate::{Interest, Registry, Token}; 7 8 pub(crate) struct IoSourceState; 9 10 impl IoSourceState { new() -> IoSourceState11 pub(crate) fn new() -> IoSourceState { 12 IoSourceState 13 } 14 do_io<T, F, R>(&self, f: F, io: &T) -> io::Result<R> where F: FnOnce(&T) -> io::Result<R>,15 pub(crate) fn do_io<T, F, R>(&self, f: F, io: &T) -> io::Result<R> 16 where 17 F: FnOnce(&T) -> io::Result<R>, 18 { 19 // We don't hold state, so we can just call the function and 20 // return. 21 f(io) 22 } 23 register( &mut self, registry: &Registry, token: Token, interests: Interest, fd: RawFd, ) -> io::Result<()>24 pub(crate) fn register( 25 &mut self, 26 registry: &Registry, 27 token: Token, 28 interests: Interest, 29 fd: RawFd, 30 ) -> io::Result<()> { 31 // Pass through, we don't have any state. 32 registry.selector().register(fd, token, interests) 33 } 34 reregister( &mut self, registry: &Registry, token: Token, interests: Interest, fd: RawFd, ) -> io::Result<()>35 pub(crate) fn reregister( 36 &mut self, 37 registry: &Registry, 38 token: Token, 39 interests: Interest, 40 fd: RawFd, 41 ) -> io::Result<()> { 42 // Pass through, we don't have any state. 43 registry.selector().reregister(fd, token, interests) 44 } 45 deregister(&mut self, registry: &Registry, fd: RawFd) -> io::Result<()>46 pub(crate) fn deregister(&mut self, registry: &Registry, fd: RawFd) -> io::Result<()> { 47 // Pass through, we don't have any state. 48 registry.selector().deregister(fd) 49 } 50 } 51