io_uring: Add file registration management
This makes it possible to use SQPOLL and other io_uring options.
Change-Id: I543879b193461ff022b3fd567ba35f2d95754bd7
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/test/io_uring.cpp b/test/io_uring.cpp
index 5be1b91..6e9981d 100644
--- a/test/io_uring.cpp
+++ b/test/io_uring.cpp
@@ -131,4 +131,17 @@
EXPECT_CALL(h[0], handleCQE(_));
}
+TEST_F(IoUringTest, RegisterFiles)
+{
+ // Slots are always allocated linearly and re-used if invalidated
+ std::optional<IoUring::FileHandle> h;
+ h = ring.registerFile(0);
+ EXPECT_EQ(*h, 0);
+ h = ring.registerFile(1);
+ EXPECT_EQ(*h, 1);
+ // The first handle should have dropped and can be replaced
+ h = ring.registerFile(2);
+ EXPECT_EQ(*h, 0);
+}
+
} // namespace stdplus