pub struct InOrderCompletion { /* private fields */ }Expand description
Enforces in-order used-ring publication for a single VirtioQueue.
Consume descriptors via try_next and complete them via
complete instead of calling the queue’s methods
directly. Completions may be issued in any order; the used ring is always
published in consumption (available) order.
Implementations§
Source§impl InOrderCompletion
impl InOrderCompletion
Sourcepub fn new(queue_size: u16) -> Self
pub fn new(queue_size: u16) -> Self
Creates an in-order completion tracker for a queue of the given size.
Sourcepub fn try_next(
&mut self,
queue: &mut VirtioQueue,
) -> Result<Option<VirtioQueueCallbackWork>, Error>
pub fn try_next( &mut self, queue: &mut VirtioQueue, ) -> Result<Option<VirtioQueueCallbackWork>, Error>
Consumes the next available descriptor from queue, recording it for
in-order completion. Returns Ok(None) if no work is available.
Use this in place of VirtioQueue::try_next.
Sourcepub fn complete(
&mut self,
queue: &mut VirtioQueue,
completion: QueueCompletion,
bytes_written: u32,
)
pub fn complete( &mut self, queue: &mut VirtioQueue, completion: QueueCompletion, bytes_written: u32, )
Records a completion for the descriptor identified by completion and
publishes the contiguous run of completed descriptors at the front of
the consumption order to the used ring, in order.
completion is the lightweight token obtained from
VirtioQueueCallbackWork::into_completion, so callers that buffer
outstanding descriptors can retain only the token rather than the full
work (and its payload).
Use this in place of VirtioQueue::complete_prepared.
Each completion must be for a descriptor still outstanding from
try_next, completed once. Some violations panic (an
out-of-range index, or a collision with a still-buffered slot); a
completion for a no-longer-outstanding descriptor is not caught and
would strand an entry in completed, eventually stalling publication.
Sourcepub fn outstanding(&self) -> usize
pub fn outstanding(&self) -> usize
Returns the number of descriptors consumed but not yet published.