23class BundledProvidedBufferQueue;
24class BundledProvidedBufferPool;
26template <AwaiterLike Awaiter>
27auto maybe_flag_fixed_fd(Awaiter &&op,
const FixedFd &) {
31template <AwaiterLike Awaiter>
auto maybe_flag_fixed_fd(Awaiter &&op,
int) {
32 return std::forward<Awaiter>(op);
36constexpr bool is_fixed_fd_v = std::is_same_v<std::decay_t<Fd>, FixedFd>;
43template <FdLike Fd1, FdLike Fd2>
44inline auto async_splice(Fd1 fd_in, int64_t off_in, Fd2 fd_out, int64_t off_out,
45 unsigned int nbytes,
unsigned int splice_flags) {
46 if constexpr (detail::is_fixed_fd_v<Fd1>) {
47 splice_flags |= SPLICE_F_FD_IN_FIXED;
49 auto op = detail::make_op_awaiter(io_uring_prep_splice, fd_in, off_in,
50 fd_out, off_out, nbytes, splice_flags);
51 return detail::maybe_flag_fixed_fd(std::move(op), fd_out);
57template <FdLike Fd1, FdLike Fd2>
58inline auto async_tee(Fd1 fd_in, Fd2 fd_out,
unsigned int nbytes,
59 unsigned int splice_flags) {
60 if constexpr (detail::is_fixed_fd_v<Fd1>) {
61 splice_flags |= SPLICE_F_FD_IN_FIXED;
63 auto op = detail::make_op_awaiter(io_uring_prep_tee, fd_in, fd_out, nbytes,
65 return detail::maybe_flag_fixed_fd(std::move(op), fd_out);
72inline auto async_readv(Fd fd,
const struct iovec *iovecs,
unsigned nr_vecs,
73 __u64 offset,
int flags) {
74 auto op = detail::make_op_awaiter(io_uring_prep_readv2, fd, iovecs, nr_vecs,
76 return detail::maybe_flag_fixed_fd(std::move(op), fd);
79#if !IO_URING_CHECK_VERSION(2, 10)
84inline auto async_readv(Fd fd, detail::FixedBuffer<const iovec *> iovecs,
85 unsigned nr_vecs, __u64 offset,
int flags) {
87 detail::make_op_awaiter(io_uring_prep_readv_fixed, fd, iovecs.value,
88 nr_vecs, offset, flags, iovecs.buf_index);
89 return detail::maybe_flag_fixed_fd(std::move(op), fd);
98 unsigned int nr_vecs, __u64 offset,
int flags) {
99 auto op = detail::make_op_awaiter(io_uring_prep_writev2, fd, iovecs,
100 nr_vecs, offset, flags);
101 return detail::maybe_flag_fixed_fd(std::move(op), fd);
104#if !IO_URING_CHECK_VERSION(2, 10)
109inline auto async_writev(Fd fd, detail::FixedBuffer<const iovec *> iovecs,
110 unsigned int nr_vecs, __u64 offset,
int flags) {
112 detail::make_op_awaiter(io_uring_prep_writev_fixed, fd, iovecs.value,
113 nr_vecs, offset, flags, iovecs.buf_index);
114 return detail::maybe_flag_fixed_fd(std::move(op), fd);
123 auto op = detail::make_op_awaiter(io_uring_prep_recvmsg, fd, msg, flags);
124 return detail::maybe_flag_fixed_fd(std::move(op), fd);
130template <FdLike Fd,
typename MultiShotFunc,
131 AnySameAs<ProvidedBufferQueue, ProvidedBufferPool> Buffer>
133 Buffer &buf, MultiShotFunc &&func) {
134 auto op = detail::make_multishot_select_buffer_op_awaiter(
135 std::forward<MultiShotFunc>(func), &buf,
136 io_uring_prep_recvmsg_multishot, fd, msg, flags);
137 return detail::maybe_flag_fixed_fd(std::move(op), fd);
145 auto op = detail::make_op_awaiter(io_uring_prep_sendmsg, fd, msg, flags);
146 return detail::maybe_flag_fixed_fd(std::move(op), fd);
152template <FdLike Fd,
typename FreeFunc>
155 auto op = detail::make_zero_copy_op_awaiter(
156 std::forward<FreeFunc>(func), io_uring_prep_sendmsg_zc, fd, msg, flags);
157 return detail::maybe_flag_fixed_fd(std::move(op), fd);
160#if !IO_URING_CHECK_VERSION(2, 10)
164template <FdLike Fd,
typename FreeFunc>
166 unsigned flags, FreeFunc &&func) {
167 auto op = detail::make_zero_copy_op_awaiter(
168 std::forward<FreeFunc>(func), io_uring_prep_sendmsg_zc_fixed, fd,
169 msg.value, flags, msg.buf_index);
170 return detail::maybe_flag_fixed_fd(std::move(op), fd);
177template <FdLike Fd>
inline auto async_fsync(Fd fd,
unsigned fsync_flags) {
178 auto op = detail::make_op_awaiter(io_uring_prep_fsync, fd, fsync_flags);
179 return detail::maybe_flag_fixed_fd(std::move(op), fd);
185inline auto async_nop() {
return detail::make_op_awaiter(io_uring_prep_nop); }
187#if !IO_URING_CHECK_VERSION(2, 13)
192 return detail::make_op_awaiter128(io_uring_prep_nop128);
201 return detail::make_op_awaiter(io_uring_prep_timeout, ts, count, flags);
204#if !IO_URING_CHECK_VERSION(2, 4)
209template <
typename MultiShotFunc>
211 unsigned count,
unsigned flags,
212 MultiShotFunc &&func) {
213 return detail::make_multishot_op_awaiter(std::forward<MultiShotFunc>(func),
214 io_uring_prep_timeout, ts, count,
215 flags | IORING_TIMEOUT_MULTISHOT);
223inline auto async_accept(Fd fd,
struct sockaddr *addr, socklen_t *addrlen,
226 detail::make_op_awaiter(io_uring_prep_accept, fd, addr, addrlen, flags);
227 return detail::maybe_flag_fixed_fd(std::move(op), fd);
235 socklen_t *addrlen,
int flags,
236 unsigned int file_index) {
237 auto op = detail::make_op_awaiter(io_uring_prep_accept_direct, fd, addr,
238 addrlen, flags, file_index);
239 return detail::maybe_flag_fixed_fd(std::move(op), fd);
245template <FdLike Fd,
typename MultiShotFunc>
247 socklen_t *addrlen,
int flags,
248 MultiShotFunc &&func) {
249 auto op = detail::make_multishot_op_awaiter(
250 std::forward<MultiShotFunc>(func), io_uring_prep_multishot_accept, fd,
251 addr, addrlen, flags);
252 return detail::maybe_flag_fixed_fd(std::move(op), fd);
258template <FdLike Fd,
typename MultiShotFunc>
260 socklen_t *addrlen,
int flags,
261 MultiShotFunc &&func) {
262 auto op = detail::make_multishot_op_awaiter(
263 std::forward<MultiShotFunc>(func),
264 io_uring_prep_multishot_accept_direct, fd, addr, addrlen, flags);
265 return detail::maybe_flag_fixed_fd(std::move(op), fd);
272 if constexpr (detail::is_fixed_fd_v<Fd>) {
273 flags |= IORING_ASYNC_CANCEL_FD_FIXED;
275 return detail::make_op_awaiter(io_uring_prep_cancel_fd, fd, flags);
282 return detail::make_op_awaiter(io_uring_prep_link_timeout, ts, flags);
291 auto op = detail::make_op_awaiter(io_uring_prep_connect, fd, addr, addrlen);
292 return detail::maybe_flag_fixed_fd(std::move(op), fd);
299 return detail::make_op_awaiter(io_uring_prep_files_update, fds, nr_fds,
309 detail::make_op_awaiter(io_uring_prep_fallocate, fd, mode, offset, len);
310 return detail::maybe_flag_fixed_fd(std::move(op), fd);
316inline auto async_openat(
int dfd,
const char *path,
int flags, mode_t mode) {
317 return detail::make_op_awaiter(io_uring_prep_openat, dfd, path, flags,
325 mode_t mode,
unsigned file_index) {
326 return detail::make_op_awaiter(io_uring_prep_openat_direct, dfd, path,
327 flags, mode, file_index);
333inline auto async_open(
const char *path,
int flags, mode_t mode) {
341 unsigned file_index) {
349 return detail::make_op_awaiter(io_uring_prep_close, fd);
356 return detail::make_op_awaiter(io_uring_prep_close_direct, fd);
362template <FdLike Fd, BufferLike Buffer>
364 auto op = detail::make_op_awaiter(io_uring_prep_read, fd, buf.data(),
366 return detail::maybe_flag_fixed_fd(std::move(op), fd);
372template <FdLike Fd, BufferLike Buffer>
373inline auto async_read(Fd fd, detail::FixedBuffer<Buffer> buf, __u64 offset) {
375 detail::make_op_awaiter(io_uring_prep_read_fixed, fd, buf.value.data(),
376 buf.value.size(), offset, buf.buf_index);
377 return detail::maybe_flag_fixed_fd(std::move(op), fd);
383template <FdLike Fd, AnySameAs<Prov
idedBufferQueue, Prov
idedBufferPool> Buffer>
385 auto op = detail::make_select_buffer_op_awaiter(&buf, io_uring_prep_read,
386 fd,
nullptr, 0, offset);
387 return detail::maybe_flag_fixed_fd(std::move(op), fd);
390#if !IO_URING_CHECK_VERSION(2, 6)
394template <FdLike Fd, AnySameAs<Prov
idedBufferQueue, Prov
idedBufferPool> Buffer,
395 typename MultiShotFunc>
397 MultiShotFunc &&func) {
398 auto op = detail::make_multishot_select_buffer_op_awaiter(
399 std::forward<MultiShotFunc>(func), &buf, io_uring_prep_read_multishot,
400 fd, 0, offset, buf.bgid());
401 return detail::maybe_flag_fixed_fd(std::move(op), fd);
408template <FdLike Fd, BufferLike Buffer>
410 auto op = detail::make_op_awaiter(io_uring_prep_write, fd, buf.data(),
412 return detail::maybe_flag_fixed_fd(std::move(op), fd);
418template <FdLike Fd, BufferLike Buffer>
419inline auto async_write(Fd fd, detail::FixedBuffer<Buffer> buf, __u64 offset) {
421 detail::make_op_awaiter(io_uring_prep_write_fixed, fd, buf.value.data(),
422 buf.value.size(), offset, buf.buf_index);
423 return detail::maybe_flag_fixed_fd(std::move(op), fd);
429inline auto async_statx(
int dfd,
const char *path,
int flags,
unsigned mask,
430 struct statx *statxbuf) {
431 return detail::make_op_awaiter(io_uring_prep_statx, dfd, path, flags, mask,
441 detail::make_op_awaiter(io_uring_prep_fadvise, fd, offset, len, advice);
442 return detail::maybe_flag_fixed_fd(std::move(op), fd);
445#if !IO_URING_CHECK_VERSION(2, 7)
451 auto op = detail::make_op_awaiter(io_uring_prep_fadvise64, fd, offset, len,
453 return detail::maybe_flag_fixed_fd(std::move(op), fd);
461 return detail::make_op_awaiter(io_uring_prep_madvise, addr, length, advice);
464#if !IO_URING_CHECK_VERSION(2, 7)
470 detail::make_op_awaiter(io_uring_prep_madvise64, addr, length, advice);
477inline void prep_sendto(io_uring_sqe *sqe,
int sockfd,
const void *buf,
478 size_t len,
int flags,
const struct sockaddr *addr,
480 io_uring_prep_send(sqe, sockfd, buf, len, flags);
481 io_uring_prep_send_set_addr(sqe, addr, addrlen);
484inline void prep_send_fixed(io_uring_sqe *sqe,
int sockfd,
const void *buf,
485 size_t len,
int flags,
int buf_index) {
486 io_uring_prep_send(sqe, sockfd, buf, len, flags);
487 sqe->ioprio |= IORING_RECVSEND_FIXED_BUF;
488 sqe->buf_index = buf_index;
491inline void prep_sendto_fixed(io_uring_sqe *sqe,
int sockfd,
const void *buf,
492 size_t len,
int flags,
493 const struct sockaddr *addr, socklen_t addrlen,
495 prep_sendto(sqe, sockfd, buf, len, flags, addr, addrlen);
496 sqe->ioprio |= IORING_RECVSEND_FIXED_BUF;
497 sqe->buf_index = buf_index;
500inline void prep_sendto_zc(io_uring_sqe *sqe,
int sockfd,
const void *buf,
501 size_t len,
int flags,
const struct sockaddr *addr,
502 socklen_t addrlen,
unsigned zc_flags) {
503 io_uring_prep_send_zc(sqe, sockfd, buf, len, flags, zc_flags);
504 io_uring_prep_send_set_addr(sqe, addr, addrlen);
507inline void prep_sendto_zc_fixed(io_uring_sqe *sqe,
int sockfd,
const void *buf,
508 size_t len,
int flags,
509 const struct sockaddr *addr, socklen_t addrlen,
510 unsigned zc_flags,
int buf_index) {
511 prep_sendto_zc(sqe, sockfd, buf, len, flags, addr, addrlen, zc_flags);
512 sqe->ioprio |= IORING_RECVSEND_FIXED_BUF;
513 sqe->buf_index = buf_index;
521template <FdLike Fd, BufferLike Buffer>
523 auto op = detail::make_op_awaiter(io_uring_prep_send, sockfd, buf.data(),
525 return detail::maybe_flag_fixed_fd(std::move(op), sockfd);
533 auto op = detail::make_select_buffer_op_awaiter(&buf, io_uring_prep_send,
534 sockfd,
nullptr, 0, flags);
535 return detail::maybe_flag_fixed_fd(std::move(op), sockfd);
538#if !IO_URING_CHECK_VERSION(2, 7)
543inline auto async_send(Fd sockfd, detail::BundledProvidedBufferQueue &buf,
545 auto op = detail::make_bundle_select_buffer_op_awaiter(
546 &buf, io_uring_prep_send, sockfd,
nullptr, 0, flags);
547 return detail::maybe_flag_fixed_fd(std::move(op), sockfd);
554template <FdLike Fd, BufferLike Buffer>
556 const struct sockaddr *addr, socklen_t addrlen) {
557 auto op = detail::make_op_awaiter(detail::prep_sendto, sockfd, buf.data(),
558 buf.size(), flags, addr, addrlen);
559 return detail::maybe_flag_fixed_fd(std::move(op), sockfd);
567 const struct sockaddr *addr, socklen_t addrlen) {
568 auto op = detail::make_select_buffer_op_awaiter(
569 &buf, detail::prep_sendto, sockfd,
nullptr, 0, flags, addr, addrlen);
570 return detail::maybe_flag_fixed_fd(std::move(op), sockfd);
573#if !IO_URING_CHECK_VERSION(2, 7)
578inline auto async_sendto(Fd sockfd, detail::BundledProvidedBufferQueue &buf,
579 int flags,
const struct sockaddr *addr,
581 auto op = detail::make_bundle_select_buffer_op_awaiter(
582 &buf, detail::prep_sendto, sockfd,
nullptr, 0, flags, addr, addrlen);
583 return detail::maybe_flag_fixed_fd(std::move(op), sockfd);
590template <FdLike Fd,
typename Buffer,
typename FreeFunc>
591inline auto async_send_zc(Fd sockfd, Buffer &&buf,
int flags,
unsigned zc_flags,
593 auto op = detail::make_zero_copy_op_awaiter(
594 std::forward<FreeFunc>(func), io_uring_prep_send_zc, sockfd, buf.data(),
595 buf.size(), flags, zc_flags);
596 return detail::maybe_flag_fixed_fd(std::move(op), sockfd);
602template <FdLike Fd, BufferLike Buffer,
typename FreeFunc>
603inline auto async_send_zc(Fd sockfd, detail::FixedBuffer<Buffer> buf,
int flags,
604 unsigned zc_flags, FreeFunc &&func) {
605 auto op = detail::make_zero_copy_op_awaiter(
606 std::forward<FreeFunc>(func), io_uring_prep_send_zc_fixed, sockfd,
607 buf.value.data(), buf.value.size(), flags, zc_flags, buf.buf_index);
608 return detail::maybe_flag_fixed_fd(std::move(op), sockfd);
614template <FdLike Fd, BufferLike Buffer,
typename FreeFunc>
616 const struct sockaddr *addr, socklen_t addrlen,
617 unsigned zc_flags, FreeFunc &&func) {
618 auto op = detail::make_zero_copy_op_awaiter(
619 std::forward<FreeFunc>(func), detail::prep_sendto_zc, sockfd,
620 buf.data(), buf.size(), flags, addr, addrlen, zc_flags);
621 return detail::maybe_flag_fixed_fd(std::move(op), sockfd);
627template <FdLike Fd, BufferLike Buffer,
typename FreeFunc>
629 int flags,
const struct sockaddr *addr,
630 socklen_t addrlen,
unsigned zc_flags,
632 auto op = detail::make_zero_copy_op_awaiter(
633 std::forward<FreeFunc>(func), detail::prep_sendto_zc_fixed, sockfd,
634 buf.value.data(), buf.value.size(), flags, addr, addrlen, zc_flags,
636 return detail::maybe_flag_fixed_fd(std::move(op), sockfd);
642template <FdLike Fd, BufferLike Buffer>
644 auto op = detail::make_op_awaiter(io_uring_prep_recv, sockfd, buf.data(),
646 return detail::maybe_flag_fixed_fd(std::move(op), sockfd);
652template <FdLike Fd, AnySameAs<Prov
idedBufferQueue, Prov
idedBufferPool> Buffer>
654 auto op = detail::make_select_buffer_op_awaiter(&buf, io_uring_prep_recv,
655 sockfd,
nullptr, 0, flags);
656 return detail::maybe_flag_fixed_fd(std::move(op), sockfd);
659#if !IO_URING_CHECK_VERSION(2, 7)
663template <FdLike Fd, AnySameAs<detail::BundledProvidedBufferQueue,
664 detail::BundledProvidedBufferPool>
667 auto op = detail::make_bundle_select_buffer_op_awaiter(
668 &buf, io_uring_prep_recv, sockfd,
nullptr, 0, flags);
669 return detail::maybe_flag_fixed_fd(std::move(op), sockfd);
676template <FdLike Fd, AnySameAs<Prov
idedBufferQueue, Prov
idedBufferPool> Buffer,
677 typename MultiShotFunc>
679 MultiShotFunc &&func) {
680 auto op = detail::make_multishot_select_buffer_op_awaiter(
681 std::forward<MultiShotFunc>(func), &buf, io_uring_prep_recv_multishot,
682 sockfd,
nullptr, 0, flags);
683 return detail::maybe_flag_fixed_fd(std::move(op), sockfd);
686#if !IO_URING_CHECK_VERSION(2, 7)
691 AnySameAs<detail::BundledProvidedBufferQueue,
692 detail::BundledProvidedBufferPool>
694 typename MultiShotFunc>
696 MultiShotFunc &&func) {
697 auto op = detail::make_multishot_bundle_select_buffer_op_awaiter(
698 std::forward<MultiShotFunc>(func), &buf, io_uring_prep_recv_multishot,
699 sockfd,
nullptr, 0, flags);
700 return detail::maybe_flag_fixed_fd(std::move(op), sockfd);
708 return detail::make_op_awaiter(io_uring_prep_openat2, dfd, path, how);
715 struct open_how *how,
unsigned file_index) {
716 return detail::make_op_awaiter(io_uring_prep_openat2_direct, dfd, path, how,
724 auto op = detail::make_op_awaiter(io_uring_prep_shutdown, fd, how);
725 return detail::maybe_flag_fixed_fd(std::move(op), fd);
732 return detail::make_op_awaiter(io_uring_prep_unlinkat, dfd, path, flags);
746 const char *newpath,
unsigned int flags) {
747 return detail::make_op_awaiter(io_uring_prep_renameat, olddfd, oldpath,
748 newdfd, newpath, flags);
764 auto op = detail::make_op_awaiter(io_uring_prep_sync_file_range, fd, len,
766 return detail::maybe_flag_fixed_fd(std::move(op), fd);
773 return detail::make_op_awaiter(io_uring_prep_mkdirat, dfd, path, mode);
787 const char *linkpath) {
788 return detail::make_op_awaiter(io_uring_prep_symlinkat, target, newdirfd,
803 const char *newpath,
int flags) {
804 return detail::make_op_awaiter(io_uring_prep_linkat, olddfd, oldpath,
805 newdfd, newpath, flags);
811inline auto async_link(
const char *oldpath,
const char *newpath,
int flags) {
812 return async_linkat(AT_FDCWD, oldpath, AT_FDCWD, newpath, flags);
820 return detail::make_op_awaiter(io_uring_prep_getxattr, name, value, path,
828 const char *path,
int flags,
unsigned int len) {
829 return detail::make_op_awaiter(io_uring_prep_setxattr, name, value, path,
838 return detail::make_op_awaiter(io_uring_prep_fgetxattr, fd, name, value,
846 int flags,
unsigned int len) {
847 return detail::make_op_awaiter(io_uring_prep_fsetxattr, fd, name, value,
855 unsigned int flags) {
856 return detail::make_op_awaiter(io_uring_prep_socket, domain, type, protocol,
864 unsigned file_index,
unsigned int flags) {
865 return detail::make_op_awaiter(io_uring_prep_socket_direct, domain, type,
866 protocol, file_index, flags);
875template <CQEHandlerLike CQEHandler = SimpleCQEHandler, FdLike Fd,
878 auto prep_func = [cmd_op, fd,
879 cmd_func = std::forward<CmdFunc>(cmd_func)](Ring *ring) {
880 auto *sqe = ring->get_sqe();
881 io_uring_prep_uring_cmd(sqe, cmd_op, fd);
886 return detail::maybe_flag_fixed_fd(std::move(op), fd);
892template <CQEHandlerLike CQEHandler = SimpleCQEHandler, FdLike Fd,
893 typename CmdFunc,
typename MultiShotFunc>
895 MultiShotFunc &&func) {
896 auto prep_func = [cmd_op, fd,
897 cmd_func = std::forward<CmdFunc>(cmd_func)](Ring *ring) {
898 auto *sqe = ring->get_sqe();
899 io_uring_prep_uring_cmd(sqe, cmd_op, fd);
904 std::move(prep_func), std::forward<MultiShotFunc>(func));
905 return detail::maybe_flag_fixed_fd(std::move(op), fd);
908#if !IO_URING_CHECK_VERSION(2, 13)
915template <CQEHandlerLike CQEHandler = SimpleCQEHandler, FdLike Fd,
918 auto prep_func = [cmd_op, fd,
919 cmd_func = std::forward<CmdFunc>(cmd_func)](Ring *ring) {
920 auto *sqe = ring->get_sqe128();
922 panic_on(
"SQE128 not enabled in the ring");
924 io_uring_prep_uring_cmd128(sqe, cmd_op, fd);
929 return detail::maybe_flag_fixed_fd(std::move(op), fd);
933#if !IO_URING_CHECK_VERSION(2, 5)
939 void *optval,
int optlen) {
940 auto op = detail::make_op_awaiter(io_uring_prep_cmd_sock, cmd_op, fd, level,
941 optname, optval, optlen);
942 return detail::maybe_flag_fixed_fd(std::move(op), fd);
946#if !IO_URING_CHECK_VERSION(2, 13)
952 socklen_t *sockaddr_len,
int peer) {
953 auto op = detail::make_op_awaiter(io_uring_prep_cmd_getsockname, fd,
954 sockaddr, sockaddr_len, peer);
955 return detail::maybe_flag_fixed_fd(std::move(op), fd);
959#if !IO_URING_CHECK_VERSION(2, 6)
964 int options,
unsigned int flags) {
965 return detail::make_op_awaiter(io_uring_prep_waitid, idtype,
id, infop,
970#if !IO_URING_CHECK_VERSION(2, 6)
975 uint32_t futex_flags,
unsigned int flags) {
976 return detail::make_op_awaiter(io_uring_prep_futex_wake, futex, val, mask,
981#if !IO_URING_CHECK_VERSION(2, 6)
986 uint32_t futex_flags,
unsigned int flags) {
987 return detail::make_op_awaiter(io_uring_prep_futex_wait, futex, val, mask,
992#if !IO_URING_CHECK_VERSION(2, 6)
997 unsigned int flags) {
998 return detail::make_op_awaiter(io_uring_prep_futex_waitv, futex, nr_futex,
1003#if !IO_URING_CHECK_VERSION(2, 6)
1008 return detail::make_op_awaiter(io_uring_prep_fixed_fd_install, fixed_fd,
1013#if !IO_URING_CHECK_VERSION(2, 6)
1018 auto op = detail::make_op_awaiter(io_uring_prep_ftruncate, fd, len);
1019 return detail::maybe_flag_fixed_fd(std::move(op), fd);
1023#if !IO_URING_CHECK_VERSION(2, 8)
1030 detail::make_op_awaiter(io_uring_prep_cmd_discard, fd, offset, nbytes);
1031 return detail::maybe_flag_fixed_fd(std::move(op), fd);
1035#if !IO_URING_CHECK_VERSION(2, 7)
1040inline auto async_bind(Fd fd,
struct sockaddr *addr, socklen_t addrlen) {
1041 auto op = detail::make_op_awaiter(io_uring_prep_bind, fd, addr, addrlen);
1042 return detail::maybe_flag_fixed_fd(std::move(op), fd);
1046#if !IO_URING_CHECK_VERSION(2, 7)
1051 auto op = detail::make_op_awaiter(io_uring_prep_listen, fd, backlog);
1052 return detail::maybe_flag_fixed_fd(std::move(op), fd);
1060 return detail::make_op_awaiter(io_uring_prep_epoll_ctl, epfd, fd, op, ev);
1063#if !IO_URING_CHECK_VERSION(2, 10)
1069 return detail::make_op_awaiter(io_uring_prep_epoll_wait, fd, events,
1074#if !IO_URING_CHECK_VERSION(2, 12)
1079 return detail::make_op_awaiter(io_uring_prep_pipe, fds, pipe_flags);
1083#if !IO_URING_CHECK_VERSION(2, 12)
1088 unsigned int file_index) {
1089 return detail::make_op_awaiter(io_uring_prep_pipe_direct, fds, pipe_flags,
Helper functions for composing asynchronous operations.
Helper functions for asynchronous operations.
The main namespace for the Condy library.
auto async_read_multishot(Fd fd, Buffer &buf, __u64 offset, MultiShotFunc &&func)
See io_uring_prep_read_multishot.
auto async_symlinkat(const char *target, int newdirfd, const char *linkpath)
See io_uring_prep_symlinkat.
auto async_splice(Fd1 fd_in, int64_t off_in, Fd2 fd_out, int64_t off_out, unsigned int nbytes, unsigned int splice_flags)
See io_uring_prep_splice.
auto async_fsetxattr(int fd, const char *name, const char *value, int flags, unsigned int len)
See io_uring_prep_fsetxattr.
auto async_fadvise(Fd fd, __u64 offset, off_t len, int advice)
See io_uring_prep_fadvise.
auto async_writev(Fd fd, const struct iovec *iovecs, unsigned int nr_vecs, __u64 offset, int flags)
See io_uring_prep_writev2.
auto async_fixed_fd_install(int fixed_fd, unsigned int flags)
See io_uring_prep_fixed_fd_install.
auto build_op_awaiter(PrepFunc &&func, Args &&...handler_args)
Build a single-shot operation awaiter with custom CQE handler.
auto async_socket_direct(int domain, int type, int protocol, unsigned file_index, unsigned int flags)
See io_uring_prep_socket_direct.
auto async_madvise64(void *addr, off_t length, int advice)
See io_uring_prep_madvise64.
auto async_fsync(Fd fd, unsigned fsync_flags)
See io_uring_prep_fsync.
auto async_cmd_getsockname(Fd fd, struct sockaddr *sockaddr, socklen_t *sockaddr_len, int peer)
See io_uring_prep_cmd_getsockname.
auto async_ftruncate(Fd fd, loff_t len)
See io_uring_prep_ftruncate.
auto async_recvmsg(Fd fd, struct msghdr *msg, unsigned flags)
See io_uring_prep_recvmsg.
auto async_openat2(int dfd, const char *path, struct open_how *how)
See io_uring_prep_openat2.
auto build_multishot_op_awaiter(PrepFunc &&func, MultiShotFunc &&multishot_func, Args &&...handler_args)
Build a multi-shot operation awaiter with custom CQE handler.
auto async_nop128()
See io_uring_prep_nop128.
auto async_open_direct(const char *path, int flags, mode_t mode, unsigned file_index)
See io_uring_prep_openat_direct.
auto async_write(Fd fd, Buffer &&buf, __u64 offset)
See io_uring_prep_write.
auto async_getxattr(const char *name, char *value, const char *path, unsigned int len)
See io_uring_prep_getxattr.
auto async_unlinkat(int dfd, const char *path, int flags)
See io_uring_prep_unlinkat.
auto async_openat_direct(int dfd, const char *path, int flags, mode_t mode, unsigned file_index)
See io_uring_prep_openat_direct.
auto async_epoll_ctl(int epfd, int fd, int op, struct epoll_event *ev)
See io_uring_prep_epoll_ctl.
auto async_mkdir(const char *path, mode_t mode)
See io_uring_prep_mkdirat.
auto async_fgetxattr(int fd, const char *name, char *value, unsigned int len)
See io_uring_prep_fgetxattr.
auto async_statx(int dfd, const char *path, int flags, unsigned mask, struct statx *statxbuf)
See io_uring_prep_statx.
auto async_sendto_zc(Fd sockfd, Buffer &&buf, int flags, const struct sockaddr *addr, socklen_t addrlen, unsigned zc_flags, FreeFunc &&func)
See io_uring_prep_send_zc and io_uring_prep_send_set_addr.
auto async_cmd_discard(Fd fd, uint64_t offset, uint64_t nbytes)
See io_uring_prep_cmd_discard.
auto async_link(const char *oldpath, const char *newpath, int flags)
See io_uring_prep_linkat.
auto async_multishot_accept_direct(Fd fd, struct sockaddr *addr, socklen_t *addrlen, int flags, MultiShotFunc &&func)
See io_uring_prep_multishot_accept_direct.
auto async_sendto(Fd sockfd, Buffer &&buf, int flags, const struct sockaddr *addr, socklen_t addrlen)
See io_uring_prep_send and io_uring_prep_send_set_addr.
auto async_futex_wake(uint32_t *futex, uint64_t val, uint64_t mask, uint32_t futex_flags, unsigned int flags)
See io_uring_prep_futex_wake.
auto async_recv_multishot(Fd sockfd, Buffer &buf, int flags, MultiShotFunc &&func)
See io_uring_prep_recv_multishot.
auto async_recv(Fd sockfd, Buffer &&buf, int flags)
See io_uring_prep_recv.
auto async_multishot_accept(Fd fd, struct sockaddr *addr, socklen_t *addrlen, int flags, MultiShotFunc &&func)
See io_uring_prep_multishot_accept.
auto async_fallocate(Fd fd, int mode, __u64 offset, __u64 len)
See io_uring_prep_fallocate.
auto async_madvise(void *addr, __u32 length, int advice)
See io_uring_prep_madvise.
auto async_epoll_wait(int fd, struct epoll_event *events, int maxevents, unsigned flags)
See io_uring_prep_epoll_wait.
auto async_symlink(const char *target, const char *linkpath)
See io_uring_prep_symlinkat.
auto async_sync_file_range(Fd fd, unsigned len, __u64 offset, int flags)
See io_uring_prep_sync_file_range.
auto async_fadvise64(Fd fd, __u64 offset, off_t len, int advice)
See io_uring_prep_fadvise64.
auto async_bind(Fd fd, struct sockaddr *addr, socklen_t addrlen)
See io_uring_prep_bind.
auto async_connect(Fd fd, const struct sockaddr *addr, socklen_t addrlen)
See io_uring_prep_connect.
auto async_waitid(idtype_t idtype, id_t id, siginfo_t *infop, int options, unsigned int flags)
See io_uring_prep_waitid.
auto async_files_update(int *fds, unsigned nr_fds, int offset)
See io_uring_prep_files_update.
auto async_cmd_sock(int cmd_op, Fd fd, int level, int optname, void *optval, int optlen)
See io_uring_prep_cmd_sock.
auto async_tee(Fd1 fd_in, Fd2 fd_out, unsigned int nbytes, unsigned int splice_flags)
See io_uring_prep_tee.
auto async_recvmsg_multishot(Fd fd, struct msghdr *msg, unsigned flags, Buffer &buf, MultiShotFunc &&func)
See io_uring_prep_recvmsg_multishot.
auto async_futex_wait(uint32_t *futex, uint64_t val, uint64_t mask, uint32_t futex_flags, unsigned int flags)
See io_uring_prep_futex_wait.
auto async_sendmsg(Fd fd, const struct msghdr *msg, unsigned flags)
See io_uring_prep_sendmsg.
auto async_read(Fd fd, Buffer &&buf, __u64 offset)
See io_uring_prep_read.
auto async_cancel_fd(Fd fd, unsigned int flags)
See io_uring_prep_cancel_fd.
auto async_pipe_direct(int *fds, int pipe_flags, unsigned int file_index)
See io_uring_prep_pipe_direct.
auto async_link_timeout(struct __kernel_timespec *ts, unsigned flags)
See io_uring_prep_link_timeout.
auto async_nop()
See io_uring_prep_nop.
auto async_sendmsg_zc(Fd fd, const struct msghdr *msg, unsigned flags, FreeFunc &&func)
See io_uring_prep_sendmsg_zc.
auto async_close(int fd)
See io_uring_prep_close.
auto async_uring_cmd128(int cmd_op, Fd fd, CmdFunc &&cmd_func)
See io_uring_prep_uring_cmd128.
auto async_open(const char *path, int flags, mode_t mode)
See io_uring_prep_openat.
auto flag(Awaiter &&awaiter)
Decorates an awaiter with specific io_uring sqe flags.
auto async_listen(Fd fd, int backlog)
See io_uring_prep_listen.
auto async_send(Fd sockfd, Buffer &&buf, int flags)
See io_uring_prep_send.
auto async_renameat(int olddfd, const char *oldpath, int newdfd, const char *newpath, unsigned int flags)
See io_uring_prep_renameat.
auto async_accept_direct(Fd fd, struct sockaddr *addr, socklen_t *addrlen, int flags, unsigned int file_index)
See io_uring_prep_accept_direct.
auto async_timeout(struct __kernel_timespec *ts, unsigned count, unsigned flags)
See io_uring_prep_timeout.
auto async_rename(const char *oldpath, const char *newpath)
See io_uring_prep_renameat.
auto async_setxattr(const char *name, const char *value, const char *path, int flags, unsigned int len)
See io_uring_prep_setxattr.
auto async_send_zc(Fd sockfd, Buffer &&buf, int flags, unsigned zc_flags, FreeFunc &&func)
See io_uring_prep_send_zc.
auto async_openat2_direct(int dfd, const char *path, struct open_how *how, unsigned file_index)
See io_uring_prep_openat2_direct.
auto async_unlink(const char *path, int flags)
See io_uring_prep_unlinkat.
auto async_accept(Fd fd, struct sockaddr *addr, socklen_t *addrlen, int flags)
See io_uring_prep_accept.
auto async_mkdirat(int dfd, const char *path, mode_t mode)
See io_uring_prep_mkdirat.
auto async_readv(Fd fd, const struct iovec *iovecs, unsigned nr_vecs, __u64 offset, int flags)
See io_uring_prep_readv2.
auto async_openat(int dfd, const char *path, int flags, mode_t mode)
See io_uring_prep_openat.
auto async_timeout_multishot(struct __kernel_timespec *ts, unsigned count, unsigned flags, MultiShotFunc &&func)
See io_uring_prep_timeout.
auto async_linkat(int olddfd, const char *oldpath, int newdfd, const char *newpath, int flags)
See io_uring_prep_linkat.
auto async_uring_cmd(int cmd_op, Fd fd, CmdFunc &&cmd_func)
See io_uring_prep_uring_cmd.
auto async_pipe(int *fds, int pipe_flags)
See io_uring_prep_pipe.
auto async_futex_waitv(struct futex_waitv *futex, uint32_t nr_futex, unsigned int flags)
See io_uring_prep_futex_waitv.
auto async_shutdown(Fd fd, int how)
See io_uring_prep_shutdown.
auto async_socket(int domain, int type, int protocol, unsigned int flags)
See io_uring_prep_socket.
auto async_uring_cmd_multishot(int cmd_op, Fd fd, CmdFunc &&cmd_func, MultiShotFunc &&func)
See io_uring_prep_uring_cmd.