Handle all io_uring events using lambdas

This commit is contained in:
Vitaliy Filippov
2019-11-13 22:46:42 +03:00
parent 7739f628cb
commit 1c6b9778a4
14 changed files with 43 additions and 76 deletions
+2 -8
View File
@@ -52,7 +52,6 @@ void ring_loop_t::unregister_consumer(int number)
{
if (number < consumers.size())
{
consumers[number].handle_event = NULL;
consumers[number].loop = NULL;
}
}
@@ -67,14 +66,9 @@ void ring_loop_t::loop(bool sleep)
while ((io_uring_peek_cqe(ring, &cqe), cqe))
{
struct ring_data_t *d = (struct ring_data_t*)cqe->user_data;
if (d->source < consumers.size())
if (d->callback)
{
d->res = cqe->res;
ring_consumer_t & c = consumers[d->source];
if (c.handle_event != NULL)
{
c.handle_event(d);
}
d->callback(d);
}
io_uring_cqe_seen(ring, cqe);
}