16#if !IO_URING_CHECK_VERSION(2, 4)
20#define CONDY_FILE_INDEX_ALLOC IORING_FILE_INDEX_ALLOC
25#define CONDY_FILE_INDEX_ALLOC (IORING_FILE_INDEX_ALLOC - 1)
32template <
typename CoroFunc>
struct SpawnHelper {
33 void operator()(
auto &&res) {
34 co_spawn(func(std::forward<
decltype(res)>(res))).detach();
36 std::decay_t<CoroFunc> func;
39template <
typename Channel>
struct PushHelper {
40 void operator()(
auto &&res) {
41 channel.force_push(std::forward<
decltype(res)>(res));
43 std::decay_t<Channel> &channel;
57template <
typename CoroFunc>
auto will_spawn(CoroFunc &&coro) {
58 return detail::SpawnHelper<std::decay_t<CoroFunc>>{
59 std::forward<CoroFunc>(coro)};
73 return detail::PushHelper<std::decay_t<Channel>>{channel};
80 operator int()
const {
return value; }
83template <
typename T>
struct FixedBuffer {
98inline auto fixed(
int fd) {
return detail::FixedFd{fd}; }
109template <BufferLike Buffer>
auto fixed(
int buf_index, Buffer &&buf) {
110 return detail::FixedBuffer<Buffer>{std::forward<Buffer>(buf), buf_index};
121inline auto fixed(
int buf_index,
const struct iovec *iov) {
122 return detail::FixedBuffer<const iovec *>{iov, buf_index};
133inline auto fixed(
int buf_index,
const struct msghdr *msg) {
134 return detail::FixedBuffer<const msghdr *>{msg, buf_index};
147 return static_cast<BundledProvidedBufferPool &
>(
buffer);
157 return static_cast<BundledProvidedBufferQueue &
>(
buffer);
Thread-safe bounded channel for communication and synchronization.
Definition channel.hpp:33
Provided buffer pool.
Definition provided_buffers.hpp:408
Provided buffer queue.
Definition provided_buffers.hpp:177
The main namespace for the Condy library.
Definition condy.hpp:28
auto will_spawn(CoroFunc &&coro)
Helper to build an invocable that spawns a coroutine on invocation.
Definition helpers.hpp:57
auto & bundled(ProvidedBufferPool &buffer)
Get the bundled variant of a provided buffer pool. This will enable buffer bundling feature of io_uri...
Definition helpers.hpp:146
auto fixed(int fd)
Mark a file descriptor as fixed for io_uring operations.
Definition helpers.hpp:98
MutableBuffer buffer(void *data, size_t size)
Create a buffer object from various data sources.
Definition buffers.hpp:84
auto will_push(Channel &channel)
Helper to build an invocable that pushes the result to a channel on invocation.
Definition helpers.hpp:72
Task< T, Allocator > co_spawn(Runtime &runtime, Coro< T, Allocator > coro)
Spawn a coroutine as a task in the given runtime.
Definition task.hpp:240
Support for io_uring provided buffers.