pub struct CompletionStatus { /* private fields */ }Expand description
A read-only view of whether the completion queue has entries pending.
Obtained from CompletionQueue::status. Unlike the queue itself this
borrows nothing, so it can be captured once at startup and consulted from
anywhere afterwards. The check costs two loads, with no system call, no
locking, and no access to the ring — which is what a thread-per-core runtime
needs on its preemption check, where reaching the queue would cost more than
the comparison does.
§Staleness
The answer is stale as soon as it is returned: the kernel may post a
completion immediately after the load. This is inherent — any check that
does not enter the kernel is a snapshot — and it makes this suitable for
hints such as “should I stop what I am doing and poll?”, where being one
iteration late costs nothing. It is not a synchronization primitive, and
CompletionQueue::is_empty carries exactly the same caveat.