io/uring/Queue: add DispatchCompletions() overload using io_uring_for_each_cqe()
This commit is contained in:
parent
a9bee1c64b
commit
2276ebd70f
@ -51,8 +51,8 @@ Queue::AddPending(struct io_uring_sqe &sqe,
|
||||
io_uring_sqe_set_data(&sqe, c);
|
||||
}
|
||||
|
||||
void
|
||||
Queue::DispatchOneCompletion(struct io_uring_cqe &cqe) noexcept
|
||||
inline void
|
||||
Queue::_DispatchOneCompletion(const struct io_uring_cqe &cqe) noexcept
|
||||
{
|
||||
void *data = io_uring_cqe_get_data(&cqe);
|
||||
if (data != nullptr) {
|
||||
@ -64,7 +64,12 @@ Queue::DispatchOneCompletion(struct io_uring_cqe &cqe) noexcept
|
||||
delete c;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Queue::DispatchOneCompletion(struct io_uring_cqe &cqe) noexcept
|
||||
{
|
||||
_DispatchOneCompletion(cqe);
|
||||
ring.SeenCompletion(cqe);
|
||||
}
|
||||
|
||||
@ -79,6 +84,14 @@ Queue::DispatchOneCompletion()
|
||||
return true;
|
||||
}
|
||||
|
||||
inline unsigned
|
||||
Queue::DispatchCompletions(struct io_uring_cqe &_cqe) noexcept
|
||||
{
|
||||
return ring.VisitCompletions(&_cqe, [](const struct io_uring_cqe &cqe){
|
||||
_DispatchOneCompletion(cqe);
|
||||
});
|
||||
}
|
||||
|
||||
bool
|
||||
Queue::WaitDispatchOneCompletion()
|
||||
{
|
||||
|
@ -104,7 +104,13 @@ public:
|
||||
bool SubmitAndWaitDispatchOneCompletion(struct __kernel_timespec &timeout);
|
||||
|
||||
private:
|
||||
static void _DispatchOneCompletion(const struct io_uring_cqe &cqe) noexcept;
|
||||
void DispatchOneCompletion(struct io_uring_cqe &cqe) noexcept;
|
||||
|
||||
/**
|
||||
* Dispatch all completions using io_uring_for_each_cqe().
|
||||
*/
|
||||
unsigned DispatchCompletions(struct io_uring_cqe &cqe) noexcept;
|
||||
};
|
||||
|
||||
} // namespace Uring
|
||||
|
Loading…
x
Reference in New Issue
Block a user