in include/unifex/linux/io_uring_context.hpp [291:326]
bool io_uring_context::try_submit_io(PopulateFn populateSqe) noexcept {
UNIFEX_ASSERT(is_running_on_io_thread());
if (pending_operation_count() < cqEntryCount_) {
// Haven't reached limit of completion-queue yet.
const auto tail = sqTail_->load(std::memory_order_relaxed);
const auto head = sqHead_->load(std::memory_order_acquire);
const auto usedCount = (tail - head);
UNIFEX_ASSERT(usedCount <= sqEntryCount_);
if (usedCount < sqEntryCount_) {
// There is space in the submission-queue.
const auto index = tail & sqMask_;
auto& sqe = sqEntries_[index];
static_assert(noexcept(populateSqe(sqe)));
// nullify the struct
std::memset(&sqe, 0, sizeof(sqe));
if constexpr (std::is_void_v<decltype(populateSqe(sqe))>) {
populateSqe(sqe);
} else {
if (!populateSqe(sqe)) {
return false;
}
}
sqIndexArray_[index] = index;
sqTail_->store(tail + 1, std::memory_order_release);
++sqUnflushedCount_;
return true;
}
}
return false;
}