Struct eventfd::EventFD
[−]
[src]
pub struct EventFD { /* fields omitted */ }
Methods
impl EventFD
[src]
pub fn new(initval: u32, flags: u32) -> Result<EventFD>
[src]
Create a new EventFD. Flags is the bitwise OR of EFD_* constants, or 0 for no flags. The underlying file descriptor is closed when the EventFD instance's lifetime ends.
TODO: work out how to integrate this FD into the wider world of fds. There's currently no way to poll/select on the fd.
pub fn read(&self) -> Result<u64>
[src]
Read the current value of the eventfd. This will block until the value is non-zero. In semaphore mode this will only ever decrement the count by 1 and return 1; otherwise it atomically returns the current value and sets it to zero.
pub fn write(&self, val: u64) -> Result<()>
[src]
Add to the current value. Blocks if the value would wrap u64.
pub fn events(&self) -> Receiver<u64>
[src]
Return a stream of events. The channel has a synchronous sender because there's no point in building up a queue of events; if this task blocks on send, the event state will still update.
The task will exit if the receiver end is shut down.
This will be a CPU-spin loop if the EventFD is created non-blocking.
XXX FIXME This has no way of terminating except if the other end closes the connection, and only then if we're not blocked in the read()...
Trait Implementations
impl Send for EventFD
[src]
impl Sync for EventFD
[src]
impl AsRawFd for EventFD
[src]
fn as_raw_fd(&self) -> RawFd
[src]
Return the raw underlying fd. The caller must make sure self's lifetime is longer than any users of the fd.
impl Drop for EventFD
[src]
impl Clone for EventFD
[src]
Construct a linked clone of an existing EventFD. Once created, the new instance interacts with the original in a way that's indistinguishable from the original.