3#if __has_include(<liburing.h>)
6#include <coroio/base.hpp>
7#include <coroio/socket.hpp>
8#include <coroio/poller.hpp>
12#include <sys/eventfd.h>
15#include <system_error>
82 void Read(
int fd,
void* buf,
int size, std::coroutine_handle<> handle);
91 void Write(
int fd,
const void* buf,
int size, std::coroutine_handle<> handle);
100 void Recv(
int fd,
void* buf,
int size, std::coroutine_handle<> handle);
109 void Send(
int fd,
const void* buf,
int size, std::coroutine_handle<> handle);
118 void Accept(
int fd,
struct sockaddr* addr, socklen_t* len, std::coroutine_handle<> handle);
127 void Connect(
int fd,
const sockaddr* addr, socklen_t len, std::coroutine_handle<> handle);
152 int Wait(timespec ts = {10,0});
176 io_uring_sqe* GetSqe() {
177 io_uring_sqe* r = io_uring_get_sqe(&Ring_);
180 r = io_uring_get_sqe(&Ring_);
190 struct io_uring Ring_;
191 std::queue<int> Results_;
192 std::vector<char> Buffer_;
Base class for pollers managing asynchronous I/O events and timers.
Definition poller.hpp:52
timespec GetTimeout() const
Computes the poll timeout based on scheduled timers.
Definition poller.hpp:286
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
Poller implementation based on io_uring.
Definition uring.hpp:60
int Result()
Retrieves the result of the last completed I/O completion.
int Wait(timespec ts={10, 0})
Waits for I/O completions.
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:158
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.
void Write(int fd, const void *buf, int size, std::coroutine_handle<> handle)
Posts an asynchronous write operation.
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.