Function flush_sq [src]
Sync internal state with kernel ring state on the SQ side.
Returns the number of all pending events in the SQ ring, for the shared ring.
This return value includes previously flushed SQEs, as per liburing.
The rationale is to suggest that an io_uring_enter() call is needed rather than not.
Matches the implementation of __io_uring_flush_sq() in liburing.
Prototype
pub fn flush_sq(self: *IoUring) u32
Parameters
self: *IoUring
Source
pub fn flush_sq(self: *IoUring) u32 {
if (self.sq.sqe_head != self.sq.sqe_tail) {
// Fill in SQEs that we have queued up, adding them to the kernel ring.
const to_submit = self.sq.sqe_tail -% self.sq.sqe_head;
var tail = self.sq.tail.*;
var i: usize = 0;
while (i < to_submit) : (i += 1) {
self.sq.array[tail & self.sq.mask] = self.sq.sqe_head & self.sq.mask;
tail +%= 1;
self.sq.sqe_head +%= 1;
}
// Ensure that the kernel can actually see the SQE updates when it sees the tail update.
@atomicStore(u32, self.sq.tail, tail, .release);
}
return self.sq_ready();
}