Struct nix::sys::eventfd::EventFd

source ·
pub struct EventFd(/* private fields */);
Expand description

An eventfd file descriptor.

Implementations§

source§

impl EventFd

source

pub fn new() -> Result<Self>

EventFd::from_value_and_flags with init_val = 0 and flags = EfdFlags::empty().

source

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.

source

pub fn from_flags(flags: EfdFlags) -> Result<Self>

EventFd::from_value_and_flags with init_val = 0 and given flags.

source

pub fn from_value(init_val: u32) -> Result<Self>

EventFd::from_value_and_flags with given init_val and flags = EfdFlags::empty().

source

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.

source

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 an u64 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 an u64 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 with EFD_NONBLOCK.

Trait Implementations§

source§

impl AsFd for EventFd

source§

fn as_fd(&self) -> BorrowedFd<'_>

Borrows the file descriptor. Read more
source§

impl AsRawFd for EventFd

source§

fn as_raw_fd(&self) -> RawFd

Extracts the raw file descriptor. Read more
source§

impl Debug for EventFd

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl From<EventFd> for OwnedFd

source§

fn from(x: EventFd) -> OwnedFd

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.