[][src]Struct vmm_sys_util::eventfd::EventFd

pub struct EventFd { /* fields omitted */ }

A safe wrapper around Linux eventfd.

Implementations

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 the EventFd. Refer to Linux eventfd.

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]

Auto Trait Implementations

impl RefUnwindSafe for EventFd

impl Send for EventFd

impl Sync for EventFd

impl Unpin for EventFd

impl UnwindSafe for EventFd

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.