9#include <sys/eventfd.h>
11#include <sys/utsname.h>
13#include <system_error>
86 void Read(
int fd,
void* buf,
int size, std::coroutine_handle<> handle);
95 void Write(
int fd,
const void* buf,
int size, std::coroutine_handle<> handle);
104 void Recv(
int fd,
void* buf,
int size, std::coroutine_handle<> handle);
113 void Send(
int fd,
const void* buf,
int size, std::coroutine_handle<> handle);
122 void Accept(
int fd,
struct sockaddr* addr, socklen_t* len, std::coroutine_handle<> handle);
131 void Connect(
int fd,
const sockaddr* addr, socklen_t len, std::coroutine_handle<> handle);
156 int Wait(timespec ts = {10,0});
179 std::tuple<int, int, int>
Kernel()
const;
195 io_uring_sqe* GetSqe() {
196 io_uring_sqe* r = io_uring_get_sqe(&Ring_);
199 r = io_uring_get_sqe(&Ring_);
206 struct io_uring Ring_;
207 std::queue<int> Results_;
208 std::vector<char> Buffer_;
209 std::tuple<int, int, int> Kernel_;
210 std::string KernelStr_;
timespec GetTimeout() const
Computes the poll timeout based on scheduled timers.
Definition poller.hpp:278
TPollerBase()=default
Default constructor.
Asynchronous file handle driven by the poller's implementation.
Definition socket.hpp:742
Socket type driven by the poller's implementation.
Definition socket.hpp:519
NNet::TPollerDrivenFileHandle< TUring > TFileHandle
Alias for the poller-driven file handle type.
Definition uring.hpp:69
int Result()
Retrieves the result of the last completed I/O completion.
int Wait(timespec ts={10, 0})
Waits for I/O completions.
const std::string & KernelStr() const
For testing: retrieves a string describing kernel.
void Cancel(int fd)
Cancels pending operations on the specified file descriptor.
void Read(int fd, void *buf, int size, std::coroutine_handle<> handle)
Posts an asynchronous read operation.
void Recv(int fd, void *buf, int size, std::coroutine_handle<> handle)
Posts an asynchronous receive operation.
~TUring()
Destructor cleans up the io_uring and related resources.
void Poll()
Polls for I/O completions.
Definition uring.hpp:162
void Send(int fd, const void *buf, int size, std::coroutine_handle<> handle)
Posts an asynchronous send operation.
void Connect(int fd, const sockaddr *addr, socklen_t len, std::coroutine_handle<> handle)
Posts an asynchronous connect operation.
NNet::TPollerDrivenSocket< TUring > TSocket
Alias for the poller-driven socket type.
Definition uring.hpp:67
std::tuple< int, int, int > Kernel() const
For testing: retrieves kernel version.
void Write(int fd, const void *buf, int size, std::coroutine_handle<> handle)
Posts an asynchronous write operation.
void Submit()
Submits queued I/O requests to the kernel.
TUring(int queueSize=256)
Constructs a TUring instance.
void Cancel(std::coroutine_handle<> h)
Cancels pending operations associated with a specific coroutine handle.
void Accept(int fd, struct sockaddr *addr, socklen_t *len, std::coroutine_handle<> handle)
Posts an asynchronous accept operation.
void Register(int fd)
Registers a file descriptor with the IO_uring poller.