pub struct EventFdTrigger(/* private fields */);
Expand description
Newtype for implementing the trigger functionality for EventFd
.
The trigger is used for handling events in the legacy devices.
Implementations§
Methods from Deref<Target = EventFd>§
Sourcepub fn write(&self, v: u64) -> Result<(), Error>
pub fn write(&self, v: u64) -> Result<(), Error>
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();
Sourcepub fn read(&self) -> Result<u64, Error>
pub fn read(&self) -> Result<u64, Error>
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);
Sourcepub fn try_clone(&self) -> Result<EventFd, Error>
pub fn try_clone(&self) -> Result<EventFd, Error>
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§
Source§impl Deref for EventFdTrigger
impl Deref for EventFdTrigger
Auto Trait Implementations§
impl Freeze for EventFdTrigger
impl RefUnwindSafe for EventFdTrigger
impl Send for EventFdTrigger
impl Sync for EventFdTrigger
impl Unpin for EventFdTrigger
impl UnwindSafe for EventFdTrigger
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more