[−][src]Struct vmm_sys_util::epoll::Epoll
Wrapper over epoll functionality.
Implementations
impl Epoll
[src]
pub fn new() -> Result<Self>
[src]
Create a new epoll file descriptor.
pub fn ctl(
&self,
operation: ControlOperation,
fd: RawFd,
event: EpollEvent
) -> Result<()>
[src]
&self,
operation: ControlOperation,
fd: RawFd,
event: EpollEvent
) -> Result<()>
Wrapper for libc::epoll_ctl
.
This can be used for adding, modifying or removing a file descriptor in the interest list of the epoll instance.
Arguments
operation
- refers to the action to be performed on the file descriptor.fd
- the file descriptor on which we want to performoperation
.event
- refers to theepoll_event
instance that is linked tofd
.
Examples
extern crate vmm_sys_util; use std::os::unix::io::AsRawFd; use vmm_sys_util::epoll::{ControlOperation, Epoll, EpollEvent, EventSet}; use vmm_sys_util::eventfd::EventFd; let epoll = Epoll::new().unwrap(); let event_fd = EventFd::new(libc::EFD_NONBLOCK).unwrap(); epoll .ctl( ControlOperation::Add, event_fd.as_raw_fd() as i32, EpollEvent::new(EventSet::OUT, event_fd.as_raw_fd() as u64), ) .unwrap(); epoll .ctl( ControlOperation::Modify, event_fd.as_raw_fd() as i32, EpollEvent::new(EventSet::IN, 4), ) .unwrap();
pub fn wait(
&self,
max_events: usize,
timeout: i32,
events: &mut [EpollEvent]
) -> Result<usize>
[src]
&self,
max_events: usize,
timeout: i32,
events: &mut [EpollEvent]
) -> Result<usize>
Wrapper for libc::epoll_wait
.
Returns the number of file descriptors in the interest list that became ready
for I/O or errno
if an error occurred.
Arguments
max_events
- the maximum number of events that we want to be returned inevents
buffer.timeout
- specifies for how long theepoll_wait
system call will block (measured in milliseconds).events
- points to a memory area that will be used for storing the events returned byepoll_wait()
call.
Examples
extern crate vmm_sys_util; use std::os::unix::io::AsRawFd; use vmm_sys_util::epoll::{ControlOperation, Epoll, EpollEvent, EventSet}; use vmm_sys_util::eventfd::EventFd; let epoll = Epoll::new().unwrap(); let event_fd = EventFd::new(libc::EFD_NONBLOCK).unwrap(); let mut ready_events = vec![EpollEvent::default(); 10]; epoll .ctl( ControlOperation::Add, event_fd.as_raw_fd() as i32, EpollEvent::new(EventSet::OUT, 4), ) .unwrap(); let ev_count = epoll.wait(10, -1, &mut ready_events[..]).unwrap(); assert_eq!(ev_count, 1);
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Epoll
impl Send for Epoll
impl Sync for Epoll
impl Unpin for Epoll
impl UnwindSafe for Epoll
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,