Condy v1.8
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 !IO_URING_CHECK_VERSION(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
38template <typename CoroFunc> auto will_spawn(CoroFunc &&coro) {
39 return detail::SpawnHelper<std::decay_t<CoroFunc>>{
40 std::forward<CoroFunc>(coro)};
41}
42
53template <typename Channel> auto will_push(Channel &channel) {
54 return detail::PushHelper<Channel>{channel};
55}
56
65inline auto fixed(int fd) { return detail::FixedFd{fd}; }
66
76template <BufferLike Buffer> auto fixed(int buf_index, Buffer &&buf) {
77 return detail::FixedBuffer<Buffer>{std::forward<Buffer>(buf), buf_index};
78}
79
88inline auto fixed(int buf_index, const struct iovec *iov) {
89 return detail::FixedBuffer<const iovec *>{iov, buf_index};
90}
91
100inline auto fixed(int buf_index, const struct msghdr *msg) {
101 return detail::FixedBuffer<const msghdr *>{msg, buf_index};
102}
103
104} // namespace condy
Thread-safe bounded channel for communication and synchronization.
Definition channel.hpp:38
Helper functions for asynchronous operations.
The main namespace for the Condy library.
Definition condy.hpp:37
auto will_spawn(CoroFunc &&coro)
Helper to build an invocable that spawns a coroutine on invocation.
Definition helpers.hpp:38
auto fixed(int fd)
Mark a file descriptor as fixed for io_uring operations.
Definition helpers.hpp:65
auto will_push(Channel &channel)
Helper to build an invocable that pushes the result to a channel on invocation.
Definition helpers.hpp:53