24template <
typename Func,
typename... Args>
26 auto prep_func = [func = std::forward<Func>(func),
27 ... args = std::forward<Args>(args)](Ring *ring) {
28 auto *sqe = ring->get_sqe();
32 return OpAwaiter<decltype(prep_func), SimpleCQEHandler>(
33 std::move(prep_func));
36#if !IO_URING_CHECK_VERSION(2, 13)
40template <
typename Func,
typename... Args>
42 auto prep_func = [func = std::forward<Func>(func),
43 ... args = std::forward<Args>(args)](Ring *ring) {
44 auto *sqe = ring->get_sqe128();
48 return OpAwaiter<decltype(prep_func), SimpleCQEHandler>(
49 std::move(prep_func));
56template <
typename MultiShotFunc,
typename Func,
typename... Args>
59 auto prep_func = [func = std::forward<Func>(func),
60 ... args = std::forward<Args>(args)](Ring *ring) {
61 auto *sqe = ring->get_sqe();
65 return MultiShotOpAwaiter<
decltype(prep_func), SimpleCQEHandler,
66 std::decay_t<MultiShotFunc>>(
67 std::move(prep_func), std::forward<MultiShotFunc>(multishot_func));
73template <BufferRingLike Br,
typename Func,
typename... Args>
75 auto prep_func = [bgid = buffers->bgid(), func = std::forward<Func>(func),
76 ... args = std::forward<Args>(args)](Ring *ring) {
77 auto *sqe = ring->get_sqe();
79 sqe->flags |= IOSQE_BUFFER_SELECT;
80 sqe->buf_group = bgid;
83 return OpAwaiter<
decltype(prep_func), SelectBufferCQEHandler<Br>>(
84 std::move(prep_func), buffers);
90template <
typename MultiShotFunc, BufferRingLike Br,
typename Func,
93 Br *buffers, Func &&func,
95 auto prep_func = [bgid = buffers->bgid(), func = std::forward<Func>(func),
96 ... args = std::forward<Args>(args)](Ring *ring) {
97 auto *sqe = ring->get_sqe();
99 sqe->flags |= IOSQE_BUFFER_SELECT;
100 sqe->buf_group = bgid;
103 return MultiShotOpAwaiter<
decltype(prep_func), SelectBufferCQEHandler<Br>,
104 std::decay_t<MultiShotFunc>>(
105 std::move(prep_func), std::forward<MultiShotFunc>(multishot_func),
109#if !IO_URING_CHECK_VERSION(2, 7)
113template <BufferRingLike Br,
typename Func,
typename... Args>
116 auto prep_func = [bgid = buffers->bgid(), func = std::forward<Func>(func),
117 ... args = std::forward<Args>(args)](Ring *ring) {
118 auto *sqe = ring->get_sqe();
120 sqe->flags |= IOSQE_BUFFER_SELECT;
121 sqe->buf_group = bgid;
122 sqe->ioprio |= IORING_RECVSEND_BUNDLE;
125 return OpAwaiter<
decltype(prep_func), SelectBufferCQEHandler<Br>>(
126 std::move(prep_func), buffers);
130#if !IO_URING_CHECK_VERSION(2, 7)
134template <
typename MultiShotFunc, BufferRingLike Br,
typename Func,
137 MultiShotFunc &&multishot_func, Br *buffers, Func &&func, Args &&...args) {
138 auto prep_func = [bgid = buffers->bgid(), func = std::forward<Func>(func),
139 ... args = std::forward<Args>(args)](Ring *ring) {
140 auto *sqe = ring->get_sqe();
142 sqe->flags |= IOSQE_BUFFER_SELECT;
143 sqe->buf_group = bgid;
144 sqe->ioprio |= IORING_RECVSEND_BUNDLE;
147 return MultiShotOpAwaiter<
decltype(prep_func), SelectBufferCQEHandler<Br>,
148 std::decay_t<MultiShotFunc>>(
149 std::move(prep_func), std::forward<MultiShotFunc>(multishot_func),
157template <
typename FreeFunc,
typename Func,
typename... Args>
160 auto prep_func = [func = std::forward<Func>(func),
161 ... args = std::forward<Args>(args)](Ring *ring) {
162 auto *sqe = ring->get_sqe();
166 return ZeroCopyOpAwaiter<
decltype(prep_func), SimpleCQEHandler,
167 std::decay_t<FreeFunc>>(
168 std::move(prep_func), std::forward<FreeFunc>(free_func));
177template <
unsigned int Flags, AwaiterLike Awaiter>
179 return FlaggedOpAwaiter<Flags, std::decay_t<Awaiter>>(
180 std::forward<Awaiter>(awaiter));
187template <AwaiterLike Awaiter>
auto drain(Awaiter &&awaiter) {
207template <
template <AwaiterLike... Awaiter>
typename AwaiterType,
208 AwaiterLike... Awaiter>
210 return AwaiterType<std::decay_t<Awaiter>...>(
211 std::forward<Awaiter>(awaiters)...);
222template <
template <
typename Awaiter>
typename RangedAwaiterType,
225 using AwaiterType =
typename std::decay_t<Range>::value_type;
226 auto begin = std::make_move_iterator(std::begin(range));
227 auto end = std::make_move_iterator(std::end(range));
228 std::vector<AwaiterType> awaiters(begin, end);
229 return RangedAwaiterType<AwaiterType>(std::move(awaiters));
239template <AwaiterLike... Awaiters>
auto when_all(Awaiters &&...awaiters) {
250template <AwaiterRange Range>
auto when_all(Range &&range) {
263template <AwaiterLike... Awaiters>
auto when_any(Awaiters &&...awaiters) {
274template <AwaiterRange Range>
auto when_any(Range &&range) {
285template <AwaiterLike... Awaiters>
auto link(Awaiters &&...awaiters) {
296template <AwaiterRange Range>
auto link(Range &&range) {
307template <AwaiterLike... Awaiters>
auto hard_link(Awaiters &&...awaiters) {
318template <AwaiterRange Range>
auto hard_link(Range &&range) {
330template <AwaiterLike Awaiter1, AwaiterLike Awaiter2>
332 return when_all(std::move(aw1), std::move(aw2));
338template <AwaiterLike Awaiter, AwaiterLike... Awaiters>
340 return WhenAllAwaiter<Awaiters..., std::decay_t<Awaiter>>(std::move(aws),
347template <AwaiterLike Awaiter1, AwaiterLike Awaiter2>
349 return when_any(std::move(aw1), std::move(aw2));
355template <AwaiterLike Awaiter, AwaiterLike... Awaiters>
357 return WhenAnyAwaiter<Awaiters..., std::decay_t<Awaiter>>(std::move(aws),
364template <AwaiterLike Awaiter1, AwaiterLike Awaiter2>
366 return link(std::move(aw1), std::move(aw2));
372template <AwaiterLike Awaiter, AwaiterLike... Awaiters>
374 return LinkAwaiter<Awaiters..., std::decay_t<Awaiter>>(std::move(aws),
Definitions of awaiter types for asynchronous operations.
Definitions of CQE handlers.
Operators for composing awaiters.
auto operator||(Awaiter1 aw1, Awaiter2 aw2)
Operator overloads version of when_any.
auto operator&&(Awaiter1 aw1, Awaiter2 aw2)
Operator overloads version of when_all.
auto operator>>(Awaiter1 aw1, Awaiter2 aw2)
Operator overloads version of link.
The main namespace for the Condy library.
auto make_multishot_select_buffer_op_awaiter(MultiShotFunc &&multishot_func, Br *buffers, Func &&func, Args &&...args)
This function creates a variant of OpAwaiter. OpAwaiter represents an asynchronous operation that can...
auto make_op_awaiter(Func &&func, Args &&...args)
This function creates a variant of OpAwaiter. OpAwaiter represents an asynchronous operation that can...
auto parallel(Awaiter &&...awaiters)
Compose multiple awaiters into a single awaiter that executes them in parallel.
auto make_bundle_select_buffer_op_awaiter(Br *buffers, Func &&func, Args &&...args)
This function creates a variant of OpAwaiter. OpAwaiter represents an asynchronous operation that can...
auto drain(Awaiter &&awaiter)
Mark an awaiter as drain operation.
auto when_all(Awaiters &&...awaiters)
Compose multiple awaiters into a single awaiter that completes when all of them complete.
auto make_multishot_op_awaiter(MultiShotFunc &&multishot_func, Func &&func, Args &&...args)
This function creates a variant of OpAwaiter. OpAwaiter represents an asynchronous operation that can...
auto make_zero_copy_op_awaiter(FreeFunc &&free_func, Func &&func, Args &&...args)
This function creates a variant of OpAwaiter. OpAwaiter represents an asynchronous operation that can...
auto link(Awaiters &&...awaiters)
Compose multiple awaiters into a single awaiter that executes them in sequence.
auto make_op_awaiter128(Func &&func, Args &&...args)
This function creates a variant of OpAwaiter. OpAwaiter represents an asynchronous operation that can...
auto make_select_buffer_op_awaiter(Br *buffers, Func &&func, Args &&...args)
This function creates a variant of OpAwaiter. OpAwaiter represents an asynchronous operation that can...
LinkAwaiterBase< IOSQE_IO_LINK, Awaiter... > LinkAwaiter
Awaiter that links multiple operations using IO_LINK.
auto when_any(Awaiters &&...awaiters)
Compose multiple awaiters into a single awaiter that completes when any of them complete.
auto flag(Awaiter &&awaiter)
Decorates an awaiter with specific io_uring sqe flags.
ParallelAwaiterBase< WhenAllFinishHandle< typename Awaiter::HandleType... >, Awaiter... > WhenAllAwaiter
Awaiter that waits for all operations to complete in parallel.
auto hard_link(Awaiters &&...awaiters)
Compose multiple awaiters into a single awaiter that executes them in sequence and continues even if ...
ParallelAwaiterBase< WhenAnyFinishHandle< typename Awaiter::HandleType... >, Awaiter... > WhenAnyAwaiter
Awaiter that waits for any operation to complete in parallel.
auto make_multishot_bundle_select_buffer_op_awaiter(MultiShotFunc &&multishot_func, Br *buffers, Func &&func, Args &&...args)
This function creates a variant of OpAwaiter. OpAwaiter represents an asynchronous operation that can...
auto always_async(Awaiter &&awaiter)
Mark an awaiter to always execute asynchronously.
Wrapper classes for liburing interfaces.