MCPcopy Create free account
hub / github.com/bytecodealliance/rustix / kevent

Function kevent

src/event/kqueue.rs:448–466  ·  view source on GitHub ↗

`kevent(kqueue, changelist, eventlist, timeout)`—Wait for events on a `kqueue`. This is a wrapper around [`kevent_timespec`] which takes a `Duration` instead of a `Timespec` for the timemout value. `Timespec` has a signed `i64` seconds field; if converting `Duration` to `Timespec` overflows, `None` is passed as the timeout instead, such such a large timeout would be effectively infinite in practi

(
    kqueue: Fd,
    changelist: &[Event],
    eventlist: Buf,
    timeout: Option<Duration>,
)

Source from the content-addressed store, hash-verified

446/// The file descriptors referred to by the `Event` structs must be valid for
447/// the lifetime of the `kqueue` file descriptor.
448pub unsafe fn kevent<Fd: AsFd, Buf: Buffer<Event>>(
449 kqueue: Fd,
450 changelist: &[Event],
451 eventlist: Buf,
452 timeout: Option<Duration>,
453) -> io::Result<Buf::Output> {
454 let timeout = match timeout {
455 Some(timeout) => match timeout.as_secs().try_into() {
456 Ok(tv_sec) => Some(Timespec {
457 tv_sec,
458 tv_nsec: timeout.subsec_nanos() as _,
459 }),
460 Err(_) => None,
461 },
462 None => None,
463 };
464
465 kevent_timespec(kqueue, changelist, eventlist, timeout.as_ref())
466}

Callers 2

kevent_timespecFunction · 0.70
mainFunction · 0.50

Calls 2

kevent_timespecFunction · 0.85
as_refMethod · 0.45

Tested by

no test coverage detected