pub(crate) struct EventFd {
event_handle: SafeDescriptor,
}
Expand description
A safe wrapper around a Linux eventfd (man 2 eventfd).
An eventfd is useful because it is sendable across processes and can be used for signaling in and out of the KVM API. They can also be polled like any other file descriptor.
Fields
event_handle: SafeDescriptor
Implementations
sourceimpl EventFd
impl EventFd
sourcepub fn write(&self, v: u64) -> Result<()>
pub fn write(&self, v: u64) -> Result<()>
Adds v
to the eventfd’s count, blocking until this won’t overflow the count.
sourcepub fn read(&self) -> Result<u64>
pub fn read(&self) -> Result<u64>
Blocks until the the eventfd’s count is non-zero, then resets the count to zero.
sourcepub fn read_timeout(&self, timeout: Duration) -> Result<EventReadResult>
pub fn read_timeout(&self, timeout: Duration) -> Result<EventReadResult>
Blocks for a maximum of timeout
duration until the the eventfd’s count is non-zero. If
a timeout does not occur then the count is returned as a EventReadResult::Count(count),
and the count is reset to 0. If a timeout does occur then this function will return
EventReadResult::Timeout.
Trait Implementations
sourceimpl AsRawDescriptor for EventFd
impl AsRawDescriptor for EventFd
sourcefn as_raw_descriptor(&self) -> RawDescriptor
fn as_raw_descriptor(&self) -> RawDescriptor
Returns the underlying raw descriptor. Read more
sourceimpl<'de> Deserialize<'de> for EventFd
impl<'de> Deserialize<'de> for EventFd
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl From<EventFd> for SafeDescriptor
impl From<EventFd> for SafeDescriptor
sourceimpl FromRawDescriptor for EventFd
impl FromRawDescriptor for EventFd
sourceunsafe fn from_raw_descriptor(descriptor: RawDescriptor) -> Self
unsafe fn from_raw_descriptor(descriptor: RawDescriptor) -> Self
Safety Read more
sourceimpl IntoRawDescriptor for EventFd
impl IntoRawDescriptor for EventFd
fn into_raw_descriptor(self) -> RawDescriptor
impl Eq for EventFd
impl StructuralEq for EventFd
impl StructuralPartialEq for EventFd
Auto Trait Implementations
impl RefUnwindSafe for EventFd
impl Send for EventFd
impl Sync for EventFd
impl Unpin for EventFd
impl UnwindSafe for EventFd
Blanket Implementations
sourceimpl<T> AsRawDescriptors for T where
T: AsRawDescriptor,
impl<T> AsRawDescriptors for T where
T: AsRawDescriptor,
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more