[−][src]Struct vmm_sys_util::eventfd::EventFd
A safe wrapper around Linux
eventfd.
Methods
impl EventFd[src]
pub fn new(flag: i32) -> Result<EventFd, Error>[src]
Create a new EventFd with an initial value.
Arguments
flag: The initial value used for creating theEventFd. Refer to Linuxeventfd.
Examples
extern crate vmm_sys_util; use vmm_sys_util::eventfd::{EventFd, EFD_NONBLOCK}; EventFd::new(EFD_NONBLOCK).unwrap();
pub fn write(&self, v: u64) -> Result<(), Error>[src]
Add a value to the eventfd's counter.
When the addition causes the counter overflow, this would either block
until a read is
performed on the file descriptor, or fail with the
error EAGAIN if the file descriptor has been made nonblocking.
Arguments
v: the value to be added to the eventfd's counter.
Examples
extern crate vmm_sys_util; use vmm_sys_util::eventfd::{EventFd, EFD_NONBLOCK}; let evt = EventFd::new(EFD_NONBLOCK).unwrap(); evt.write(55).unwrap();
pub fn read(&self) -> Result<u64, Error>[src]
Read a value from the eventfd.
If the counter is zero, this would either block until the counter becomes nonzero, or fail with the error EAGAIN if the file descriptor has been made nonblocking.
Examples
extern crate vmm_sys_util; use vmm_sys_util::eventfd::{EventFd, EFD_NONBLOCK}; let evt = EventFd::new(EFD_NONBLOCK).unwrap(); evt.write(55).unwrap(); assert_eq!(evt.read().unwrap(), 55);
pub fn try_clone(&self) -> Result<EventFd, Error>[src]
Clone this EventFd.
This internally creates a new file descriptor and it will share the same underlying count within the kernel.
Examples
extern crate vmm_sys_util; use vmm_sys_util::eventfd::{EventFd, EFD_NONBLOCK}; let evt = EventFd::new(EFD_NONBLOCK).unwrap(); let evt_clone = evt.try_clone().unwrap(); evt.write(923).unwrap(); assert_eq!(evt_clone.read().unwrap(), 923);
Trait Implementations
impl AsRawFd for EventFd[src]
impl FromRawFd for EventFd[src]
unsafe fn from_raw_fd(fd: RawFd) -> Self[src]
Auto Trait Implementations
impl Send for EventFd
impl Sync for EventFd
impl Unpin for EventFd
impl UnwindSafe for EventFd
impl RefUnwindSafe for EventFd
Blanket Implementations
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 = !
The type returned in the event of a conversion error.
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>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,