io/uring/Ring: use if
with initializer
This commit is contained in:

committed by
Max Kellermann

parent
6fb91e661c
commit
badf7101e2
@@ -9,24 +9,24 @@ namespace Uring {
|
|||||||
|
|
||||||
Ring::Ring(unsigned entries, unsigned flags)
|
Ring::Ring(unsigned entries, unsigned flags)
|
||||||
{
|
{
|
||||||
int error = io_uring_queue_init(entries, &ring, flags);
|
if (int error = io_uring_queue_init(entries, &ring, flags);
|
||||||
if (error < 0)
|
error < 0)
|
||||||
throw MakeErrno(-error, "io_uring_queue_init() failed");
|
throw MakeErrno(-error, "io_uring_queue_init() failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Ring::Submit()
|
Ring::Submit()
|
||||||
{
|
{
|
||||||
int error = io_uring_submit(&ring);
|
if (int error = io_uring_submit(&ring);
|
||||||
if (error < 0)
|
error < 0)
|
||||||
throw MakeErrno(-error, "io_uring_submit() failed");
|
throw MakeErrno(-error, "io_uring_submit() failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Ring::SubmitAndGetEvents()
|
Ring::SubmitAndGetEvents()
|
||||||
{
|
{
|
||||||
int error = io_uring_submit_and_get_events(&ring);
|
if (int error = io_uring_submit_and_get_events(&ring);
|
||||||
if (error < 0)
|
error < 0)
|
||||||
throw MakeErrno(-error, "io_uring_submit() failed");
|
throw MakeErrno(-error, "io_uring_submit() failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -34,8 +34,8 @@ struct io_uring_cqe *
|
|||||||
Ring::WaitCompletion()
|
Ring::WaitCompletion()
|
||||||
{
|
{
|
||||||
struct io_uring_cqe *cqe;
|
struct io_uring_cqe *cqe;
|
||||||
int error = io_uring_wait_cqe(&ring, &cqe);
|
if (int error = io_uring_wait_cqe(&ring, &cqe);
|
||||||
if (error < 0) {
|
error < 0) {
|
||||||
if (error == -EAGAIN)
|
if (error == -EAGAIN)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
@@ -49,8 +49,7 @@ struct io_uring_cqe *
|
|||||||
Ring::PeekCompletion()
|
Ring::PeekCompletion()
|
||||||
{
|
{
|
||||||
struct io_uring_cqe *cqe;
|
struct io_uring_cqe *cqe;
|
||||||
int error = io_uring_peek_cqe(&ring, &cqe);
|
if (int error = io_uring_peek_cqe(&ring, &cqe); error < 0) {
|
||||||
if (error < 0) {
|
|
||||||
if (error == -EAGAIN)
|
if (error == -EAGAIN)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user