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)
noexcept {
36 assert(detail::Context::current().runtime() !=
nullptr);
37 co_spawn(func(std::forward<
decltype(res)>(res))).detach();
42template <
typename Channel>
struct PushHelper {
43 void operator()(
auto &&res)
noexcept {
44 channel.force_push(std::forward<
decltype(res)>(res));
60template <
typename CoroFunc>
auto will_spawn(CoroFunc &&coro) {
61 return detail::SpawnHelper<std::decay_t<CoroFunc>>{
62 std::forward<CoroFunc>(coro)};
76 return detail::PushHelper<Channel>{channel};
83 operator int()
const {
return value; }
86template <
typename T>
struct FixedBuffer {
101inline auto fixed(
int fd) {
return detail::FixedFd{fd}; }
112template <BufferLike Buffer>
auto fixed(
int buf_index, Buffer &&buf) {
113 return detail::FixedBuffer<Buffer>{std::forward<Buffer>(buf), buf_index};
124inline auto fixed(
int buf_index,
const struct iovec *iov) {
125 return detail::FixedBuffer<const iovec *>{iov, buf_index};
136inline auto fixed(
int buf_index,
const struct msghdr *msg) {
137 return detail::FixedBuffer<const msghdr *>{msg, buf_index};
Thread-safe bounded channel for communication and synchronization.
The main namespace for the Condy library.
auto will_spawn(CoroFunc &&coro)
Helper to build an invocable that spawns a coroutine on invocation.
Task< T, Allocator > co_spawn(Runtime &runtime, Coro< T, Allocator > coro) noexcept
Spawn a coroutine as a task in the given runtime.
auto fixed(int fd)
Mark a file descriptor as fixed for io_uring operations.
auto will_push(Channel &channel)
Helper to build an invocable that pushes the result to a channel on invocation.