io/uring/Queue: add DispatchCompletions() overload using io_uring_for_each_cqe()
This commit is contained in:

committed by
Max Kellermann

parent
a9bee1c64b
commit
2276ebd70f
@ -51,8 +51,8 @@ Queue::AddPending(struct io_uring_sqe &sqe,
|
|||||||
io_uring_sqe_set_data(&sqe, c);
|
io_uring_sqe_set_data(&sqe, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
inline void
|
||||||
Queue::DispatchOneCompletion(struct io_uring_cqe &cqe) noexcept
|
Queue::_DispatchOneCompletion(const struct io_uring_cqe &cqe) noexcept
|
||||||
{
|
{
|
||||||
void *data = io_uring_cqe_get_data(&cqe);
|
void *data = io_uring_cqe_get_data(&cqe);
|
||||||
if (data != nullptr) {
|
if (data != nullptr) {
|
||||||
@ -64,7 +64,12 @@ Queue::DispatchOneCompletion(struct io_uring_cqe &cqe) noexcept
|
|||||||
delete c;
|
delete c;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Queue::DispatchOneCompletion(struct io_uring_cqe &cqe) noexcept
|
||||||
|
{
|
||||||
|
_DispatchOneCompletion(cqe);
|
||||||
ring.SeenCompletion(cqe);
|
ring.SeenCompletion(cqe);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,6 +84,14 @@ Queue::DispatchOneCompletion()
|
|||||||
return true;
|
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
|
bool
|
||||||
Queue::WaitDispatchOneCompletion()
|
Queue::WaitDispatchOneCompletion()
|
||||||
{
|
{
|
||||||
|
@ -104,7 +104,13 @@ public:
|
|||||||
bool SubmitAndWaitDispatchOneCompletion(struct __kernel_timespec &timeout);
|
bool SubmitAndWaitDispatchOneCompletion(struct __kernel_timespec &timeout);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
static void _DispatchOneCompletion(const struct io_uring_cqe &cqe) noexcept;
|
||||||
void DispatchOneCompletion(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
|
} // namespace Uring
|
||||||
|
Reference in New Issue
Block a user