Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
bf36223
move some class in coro and task to detail
wokron May 29, 2026
98c7edd
move finish handles to detail
wokron May 29, 2026
6035814
move senders to detail
wokron May 29, 2026
520cbe6
move to detail dir
wokron May 29, 2026
8e2ccc2
update coro.inl
wokron May 29, 2026
b8a74b8
rename to detail/coro.hpp
wokron May 29, 2026
63e7e19
separate senders.hpp
wokron May 29, 2026
c28ab55
move singleton to detail
wokron May 29, 2026
9e0faa3
move to detail dir
wokron May 29, 2026
853e868
move invoker to detail
wokron May 29, 2026
467d4cd
move to detail dir
wokron May 29, 2026
db789e2
move to detail
wokron May 29, 2026
8109891
move to detail
wokron May 29, 2026
34d92c1
move intrusive to detail
wokron May 29, 2026
d2126c5
move to detail
wokron May 29, 2026
225fa16
move type_trais to detail
wokron May 29, 2026
a918dbb
move to detail
wokron May 29, 2026
bf6970f
move work type to detail
wokron May 29, 2026
4e2b06d
move to detail
wokron May 29, 2026
148a15d
move helpers to detail
wokron May 29, 2026
6b20dc6
move ring to detail
wokron May 29, 2026
ca48314
move to detail
wokron May 29, 2026
355e6db
move async op to detail
wokron May 29, 2026
04f5c7d
move to detail
wokron May 29, 2026
a1ab5a0
move utils (1)
wokron May 29, 2026
26c7dff
move utils (2)
wokron May 29, 2026
5c711ed
move utils (3)
wokron May 29, 2026
baad9d9
move utils (4)
wokron May 29, 2026
2a44351
move utils (5)
wokron May 29, 2026
dc6a76f
move utils (6)
wokron May 29, 2026
1ff8999
move utils (7)
wokron May 29, 2026
343db0b
move utils (8)
wokron May 29, 2026
917beff
move utils (9)
wokron May 29, 2026
42f1941
move utils (10)
wokron May 29, 2026
0466111
move to detail
wokron May 29, 2026
7a8137d
update include
wokron May 29, 2026
0c1d9db
update include
wokron May 29, 2026
ba4dabd
remove useless detail::
wokron May 30, 2026
f42e2ef
fix static check
wokron May 30, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions include/condy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,20 @@

#include "condy/async_operations.hpp" // IWYU pragma: export
#include "condy/awaiter_operations.hpp" // IWYU pragma: export
#include "condy/awaiters.hpp" // IWYU pragma: export
#include "condy/buffers.hpp" // IWYU pragma: export
#include "condy/channel.hpp" // IWYU pragma: export
#include "condy/coro.hpp" // IWYU pragma: export
#include "condy/cqe_handler.hpp" // IWYU pragma: export
#include "condy/futex.hpp" // IWYU pragma: export
#include "condy/helpers.hpp" // IWYU pragma: export
#include "condy/pmr.hpp" // IWYU pragma: export
#include "condy/provided_buffers.hpp" // IWYU pragma: export
#include "condy/ring_settings.hpp" // IWYU pragma: export
#include "condy/runtime.hpp" // IWYU pragma: export
#include "condy/runtime_options.hpp" // IWYU pragma: export
#include "condy/sender_operations.hpp" // IWYU pragma: export
#include "condy/senders.hpp" // IWYU pragma: export
#include "condy/sync_wait.hpp" // IWYU pragma: export
#include "condy/task.hpp" // IWYU pragma: export
#include "condy/version.hpp" // IWYU pragma: export
Expand Down
72 changes: 9 additions & 63 deletions include/condy/async_operations.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
#include "condy/awaiter_operations.hpp"
#include "condy/concepts.hpp"
#include "condy/condy_uring.hpp"
#include "condy/helpers.hpp"
#include "condy/detail/async_operations.hpp"
#include "condy/detail/helpers.hpp"

namespace condy {

Expand All @@ -23,18 +24,6 @@ namespace detail {
class BundledProvidedBufferQueue;
class BundledProvidedBufferPool;

template <typename Awaiter>
auto maybe_flag_fixed_fd(Awaiter &&op, const FixedFd &) {
return flag<IOSQE_FIXED_FILE>(std::forward<Awaiter>(op));
}

template <typename Awaiter> auto maybe_flag_fixed_fd(Awaiter &&op, int) {
return std::forward<Awaiter>(op);
}

template <typename Fd>
constexpr bool is_fixed_fd_v = std::is_same_v<std::remove_cvref_t<Fd>, FixedFd>;

} // namespace detail

/**
Expand Down Expand Up @@ -472,49 +461,6 @@ inline auto async_madvise64(void *addr, off_t length, int advice) {
}
#endif

namespace detail {

inline void prep_sendto(io_uring_sqe *sqe, int sockfd, const void *buf,
size_t len, int flags, const struct sockaddr *addr,
socklen_t addrlen) {
io_uring_prep_send(sqe, sockfd, buf, len, flags);
io_uring_prep_send_set_addr(sqe, addr, addrlen);
}

inline void prep_send_fixed(io_uring_sqe *sqe, int sockfd, const void *buf,
size_t len, int flags, int buf_index) {
io_uring_prep_send(sqe, sockfd, buf, len, flags);
sqe->ioprio |= IORING_RECVSEND_FIXED_BUF;
sqe->buf_index = buf_index;
}

inline void prep_sendto_fixed(io_uring_sqe *sqe, int sockfd, const void *buf,
size_t len, int flags,
const struct sockaddr *addr, socklen_t addrlen,
int buf_index) {
prep_sendto(sqe, sockfd, buf, len, flags, addr, addrlen);
sqe->ioprio |= IORING_RECVSEND_FIXED_BUF;
sqe->buf_index = buf_index;
}

inline void prep_sendto_zc(io_uring_sqe *sqe, int sockfd, const void *buf,
size_t len, int flags, const struct sockaddr *addr,
socklen_t addrlen, unsigned zc_flags) {
io_uring_prep_send_zc(sqe, sockfd, buf, len, flags, zc_flags);
io_uring_prep_send_set_addr(sqe, addr, addrlen);
}

inline void prep_sendto_zc_fixed(io_uring_sqe *sqe, int sockfd, const void *buf,
size_t len, int flags,
const struct sockaddr *addr, socklen_t addrlen,
unsigned zc_flags, int buf_index) {
prep_sendto_zc(sqe, sockfd, buf, len, flags, addr, addrlen, zc_flags);
sqe->ioprio |= IORING_RECVSEND_FIXED_BUF;
sqe->buf_index = buf_index;
}

} // namespace detail

/**
* @brief See io_uring_prep_send
*/
Expand Down Expand Up @@ -875,8 +821,8 @@ inline auto async_socket_direct(int domain, int type, int protocol,
template <CQEHandlerLike CQEHandler = SimpleCQEHandler, FdLike Fd,
typename CmdFunc>
inline auto async_uring_cmd(int cmd_op, Fd fd, CmdFunc &&cmd_func) {
auto prep_func = [cmd_op, fd,
cmd_func = std::forward<CmdFunc>(cmd_func)](Ring *ring) {
auto prep_func = [cmd_op, fd, cmd_func = std::forward<CmdFunc>(cmd_func)](
detail::Ring *ring) {
auto *sqe = ring->get_sqe();
io_uring_prep_uring_cmd(sqe, cmd_op, fd);
cmd_func(sqe);
Expand All @@ -893,8 +839,8 @@ template <CQEHandlerLike CQEHandler = SimpleCQEHandler, FdLike Fd,
typename CmdFunc, typename MultiShotFunc>
inline auto async_uring_cmd_multishot(int cmd_op, Fd fd, CmdFunc &&cmd_func,
MultiShotFunc &&func) {
auto prep_func = [cmd_op, fd,
cmd_func = std::forward<CmdFunc>(cmd_func)](Ring *ring) {
auto prep_func = [cmd_op, fd, cmd_func = std::forward<CmdFunc>(cmd_func)](
detail::Ring *ring) {
auto *sqe = ring->get_sqe();
io_uring_prep_uring_cmd(sqe, cmd_op, fd);
cmd_func(sqe);
Expand All @@ -915,11 +861,11 @@ inline auto async_uring_cmd_multishot(int cmd_op, Fd fd, CmdFunc &&cmd_func,
template <CQEHandlerLike CQEHandler = SimpleCQEHandler, FdLike Fd,
typename CmdFunc>
inline auto async_uring_cmd128(int cmd_op, Fd fd, CmdFunc &&cmd_func) {
auto prep_func = [cmd_op, fd,
cmd_func = std::forward<CmdFunc>(cmd_func)](Ring *ring) {
auto prep_func = [cmd_op, fd, cmd_func = std::forward<CmdFunc>(cmd_func)](
detail::Ring *ring) {
auto *sqe = ring->get_sqe128();
if (!sqe) {
panic_on("SQE128 not enabled in the ring");
detail::panic_on("SQE128 not enabled in the ring");
}
io_uring_prep_uring_cmd128(sqe, cmd_op, fd);
cmd_func(sqe);
Expand Down
129 changes: 0 additions & 129 deletions include/condy/awaiter_operations.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
#pragma once

#include "condy/concepts.hpp"
#include "condy/cqe_handler.hpp"
#include "condy/ring.hpp"
#include "condy/sender_operations.hpp"

namespace condy {
Expand Down Expand Up @@ -76,131 +74,4 @@ auto build_zero_copy_op_awaiter(PrepFunc &&func, FreeFunc &&free_func,
std::forward<Args>(handler_args)...);
}

namespace detail {

template <typename Func, typename... Args>
auto make_op_awaiter(Func &&func, Args &&...args) {
auto prep_func = [func = std::forward<Func>(func),
... args = std::forward<Args>(args)](Ring *ring) {
auto *sqe = ring->get_sqe();
func(sqe, args...);
return sqe;
};
return build_op_awaiter<SimpleCQEHandler>(std::move(prep_func));
}

#if !IO_URING_CHECK_VERSION(2, 13) // >= 2.13
template <typename Func, typename... Args>
auto make_op_awaiter128(Func &&func, Args &&...args) {
auto prep_func = [func = std::forward<Func>(func),
... args = std::forward<Args>(args)](Ring *ring) {
auto *sqe = ring->get_sqe128();
if (!sqe) {
panic_on("SQE128 not enabled in the ring");
}
func(sqe, args...);
return sqe;
};
return build_op_awaiter<SimpleCQEHandler>(std::move(prep_func));
}
#endif

template <typename MultiShotFunc, typename Func, typename... Args>
auto make_multishot_op_awaiter(MultiShotFunc &&multishot_func, Func &&func,
Args &&...args) {
auto prep_func = [func = std::forward<Func>(func),
... args = std::forward<Args>(args)](Ring *ring) {
auto *sqe = ring->get_sqe();
func(sqe, args...);
return sqe;
};
return build_multishot_op_awaiter<SimpleCQEHandler>(
std::move(prep_func), std::forward<MultiShotFunc>(multishot_func));
}

template <BufferRingLike Br, typename Func, typename... Args>
auto make_select_buffer_op_awaiter(Br *buffers, Func &&func, Args &&...args) {
auto prep_func = [bgid = buffers->bgid(), func = std::forward<Func>(func),
... args = std::forward<Args>(args)](Ring *ring) {
auto *sqe = ring->get_sqe();
func(sqe, args...);
sqe->flags |= IOSQE_BUFFER_SELECT;
sqe->buf_group = bgid;
return sqe;
};
return build_op_awaiter<SelectBufferCQEHandler<Br>>(std::move(prep_func),
buffers);
}

template <typename MultiShotFunc, BufferRingLike Br, typename Func,
typename... Args>
auto make_multishot_select_buffer_op_awaiter(MultiShotFunc &&multishot_func,
Br *buffers, Func &&func,
Args &&...args) {
auto prep_func = [bgid = buffers->bgid(), func = std::forward<Func>(func),
... args = std::forward<Args>(args)](Ring *ring) {
auto *sqe = ring->get_sqe();
func(sqe, args...);
sqe->flags |= IOSQE_BUFFER_SELECT;
sqe->buf_group = bgid;
return sqe;
};
return build_multishot_op_awaiter<SelectBufferCQEHandler<Br>>(
std::move(prep_func), std::forward<MultiShotFunc>(multishot_func),
buffers);
}

#if !IO_URING_CHECK_VERSION(2, 7) // >= 2.7
template <BufferRingLike Br, typename Func, typename... Args>
auto make_bundle_select_buffer_op_awaiter(Br *buffers, Func &&func,
Args &&...args) {
auto prep_func = [bgid = buffers->bgid(), func = std::forward<Func>(func),
... args = std::forward<Args>(args)](Ring *ring) {
auto *sqe = ring->get_sqe();
func(sqe, args...);
sqe->flags |= IOSQE_BUFFER_SELECT;
sqe->buf_group = bgid;
sqe->ioprio |= IORING_RECVSEND_BUNDLE;
return sqe;
};
return build_op_awaiter<SelectBufferCQEHandler<Br>>(std::move(prep_func),
buffers);
}
#endif

#if !IO_URING_CHECK_VERSION(2, 7) // >= 2.7
template <typename MultiShotFunc, BufferRingLike Br, typename Func,
typename... Args>
auto make_multishot_bundle_select_buffer_op_awaiter(
MultiShotFunc &&multishot_func, Br *buffers, Func &&func, Args &&...args) {
auto prep_func = [bgid = buffers->bgid(), func = std::forward<Func>(func),
... args = std::forward<Args>(args)](Ring *ring) {
auto *sqe = ring->get_sqe();
func(sqe, args...);
sqe->flags |= IOSQE_BUFFER_SELECT;
sqe->buf_group = bgid;
sqe->ioprio |= IORING_RECVSEND_BUNDLE;
return sqe;
};
return build_multishot_op_awaiter<SelectBufferCQEHandler<Br>>(
std::move(prep_func), std::forward<MultiShotFunc>(multishot_func),
buffers);
}
#endif

template <typename FreeFunc, typename Func, typename... Args>
auto make_zero_copy_op_awaiter(FreeFunc &&free_func, Func &&func,
Args &&...args) {
auto prep_func = [func = std::forward<Func>(func),
... args = std::forward<Args>(args)](Ring *ring) {
auto *sqe = ring->get_sqe();
func(sqe, args...);
return sqe;
};
return build_zero_copy_op_awaiter<SimpleCQEHandler>(
std::move(prep_func), std::forward<FreeFunc>(free_func));
}

} // namespace detail

} // namespace condy
Loading
Loading