pub struct EventFd(/* private fields */);
Expand description
An eventfd file descriptor.
Implementations§
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 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_SEMAPHORE
was not specified and the eventfd counter has a nonzero value, then this function returns anu64
containing that value, and the counter’s value is reset to zero. -
If
EFD_SEMAPHORE
was specified and the eventfd counter has a nonzero value, then this function returns anu64
containing 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
EAGAIN
if the file descriptor has been made nonblocking withEFD_NONBLOCK
.