Condy v1.9
C++ Asynchronous System Call Layer for Linux
Loading...
Searching...
No Matches
helpers.hpp
Go to the documentation of this file.
1
8
9#pragma once
10
11#include "condy/concepts.hpp"
12#include "condy/condy_uring.hpp"
14
15#if CONDY_URING_VERSION_GE(2, 4) // >= 2.4
19#define CONDY_FILE_INDEX_ALLOC IORING_FILE_INDEX_ALLOC
20#else
24#define CONDY_FILE_INDEX_ALLOC (IORING_FILE_INDEX_ALLOC - 1)
25#endif
26
27namespace condy {
28
32inline constexpr unsigned file_index_alloc = CONDY_FILE_INDEX_ALLOC;
33
43template <typename CoroFunc> auto will_spawn(CoroFunc &&coro) {
44 return detail::SpawnHelper<std::decay_t<CoroFunc>>{
45 std::forward<CoroFunc>(coro)};
46}
47
58template <typename Channel> auto will_push(Channel &channel) {
59 return detail::PushHelper<Channel>{channel};
60}
61
70inline auto fixed(int fd) { return detail::FixedFd{fd}; }
71
81template <BufferLike Buffer> auto fixed(int buf_index, Buffer &&buf) {
82 return detail::FixedBuffer<Buffer>{std::forward<Buffer>(buf), buf_index};
83}
84
93inline auto fixed(int buf_index, const struct iovec *iov) {
94 return detail::FixedBuffer<const iovec *>{iov, buf_index};
95}
96
105inline auto fixed(int buf_index, const struct msghdr *msg) {
106 return detail::FixedBuffer<const msghdr *>{msg, buf_index};
107}
108
109} // namespace condy
Thread-safe bounded channel for communication and synchronization.
Definition channel.hpp:42
Helper functions for asynchronous operations.
#define CONDY_FILE_INDEX_ALLOC
Placeholder to let io_uring allocate a direct file descriptor.
Definition helpers.hpp:24
The main namespace for the Condy library.
Definition condy.hpp:38
auto will_spawn(CoroFunc &&coro)
Helper to build an invocable that spawns a coroutine on invocation.
Definition helpers.hpp:43
constexpr unsigned file_index_alloc
Placeholder to let io_uring allocate a direct file descriptor.
Definition helpers.hpp:32
auto fixed(int fd)
Mark a file descriptor as fixed for io_uring operations.
Definition helpers.hpp:70
auto will_push(Channel &channel)
Helper to build an invocable that pushes the result to a channel on invocation.
Definition helpers.hpp:58