Skip to main content

Module completion_queue

Module completion_queue 

Source
Expand description

Completion queue — polling for completed work requests.

A CompletionQueue (CQ) is the mechanism used to receive notifications about completed Work Requests (WR) from a Queue Pair (QP). When a Send or Receive operation finishes, the hardware writes a “Work Completion” (WC) entry into the CQ.

§Polling

This library uses direct polling for maximum performance. You must manually call CompletionQueue::poll to check for completions. This operation bypasses the kernel and reads directly from the hardware queue, ensuring minimal latency.

§Example: Polling for Completions

use ibverbs_rs::ibverbs;
use ibverbs_rs::ibverbs::completion_queue::PollSlot;

let context = ibverbs::open_device("mlx5_0")?;
let cq = context.create_cq(16)?;

// Pre-allocate a buffer for polling multiple completions at once
let mut slots = [PollSlot::default(); 16];

// Poll for completions (non-blocking)
let completions = cq.poll(&mut slots)?;

for wc in completions {
    println!("Work completion result: {:?}", wc.result());
}

Structs§

CompletionQueue
A shared handle to a Completion Queue (CQ).
PollSlot
A pre-allocated slot for receiving a work completion.
PolledCompletions
An iterator over completions retrieved from a poll operation.