#[repr(transparent)]pub struct EventFd(OwnedFd);Expand description
An eventfd file descriptor.
Tuple Fields§
§0: OwnedFdImplementations§
Source§impl EventFd
impl EventFd
Sourcepub fn new() -> Result<Self>
pub fn new() -> Result<Self>
EventFd::from_value_and_flags with init_val = 0 and flags = EfdFlags::empty().
Sourcepub fn from_value_and_flags(init_val: u32, flags: EfdFlags) -> Result<Self>
pub fn from_value_and_flags(init_val: u32, flags: EfdFlags) -> Result<Self>
Constructs EventFd with the given init_val and flags.
Wrapper around libc::eventfd.
Sourcepub fn from_flags(flags: EfdFlags) -> Result<Self>
pub fn from_flags(flags: EfdFlags) -> Result<Self>
EventFd::from_value_and_flags with init_val = 0 and given flags.
Sourcepub fn from_value(init_val: u32) -> Result<Self>
pub fn from_value(init_val: u32) -> Result<Self>
EventFd::from_value_and_flags with given init_val and flags = EfdFlags::empty().
Sourcepub unsafe fn from_owned_fd(fd: OwnedFd) -> Self
pub unsafe fn from_owned_fd(fd: OwnedFd) -> Self
Sourcepub fn write(&self, value: u64) -> Result<usize>
pub fn write(&self, value: u64) -> Result<usize>
Enqueues value triggers, i.e., adds the integer value supplied in value
to the counter.
The next value calls to poll, select or epoll will return immediately.
EventFd::write with value.
Sourcepub fn read(&self) -> Result<u64>
pub fn read(&self) -> Result<u64>
Reads the value from the file descriptor.
-
If
EFD_SEMAPHOREwas not specified and the eventfd counter has a nonzero value, then this function returns anu64containing that value, and the counter’s value is reset to zero. -
If
EFD_SEMAPHOREwas specified and the eventfd counter has a nonzero value, then this function returns anu64containing the value 1, and the counter’s value is decremented by 1. -
If the eventfd counter is zero at the time of this call, then the call either blocks until the counter becomes nonzero (at which time, this function proceeds as described above) or fails with the error
EAGAINif the file descriptor has been made nonblocking withEFD_NONBLOCK.