Condy v1.1.0
C++ Asynchronous System Call Layer for Linux
Loading...
Searching...
No Matches
condy Namespace Reference

The main namespace for the Condy library. More...

Namespaces

namespace  operators
 Operators for composing awaiters.
namespace  pmr
 Polymorphic memory resource (PMR) related types and utilities.

Classes

class  MutableBuffer
 Mutable buffer. More...
class  ConstBuffer
 Constant buffer. More...
class  Channel
 Thread-safe bounded channel for communication and synchronization. More...
class  Coro
 Coroutine type used to define a coroutine function. More...
struct  BufferInfo
 Information about buffers consumed from a provided buffer queue. More...
class  ProvidedBufferQueue
 Provided buffer queue. More...
struct  ProvidedBuffer
 Provided buffer. More...
class  ProvidedBufferPool
 Provided buffer pool. More...
class  FdTable
 File descriptor table for io_uring. More...
class  BufferTable
 Buffer table for io_uring. More...
class  RingSettings
 Settings manager for io_uring. More...
class  Runtime
 The event loop runtime for executing asynchronous. More...
struct  RuntimeOptions
 Runtime options. More...
class  Task
 Coroutine task that runs concurrently in the runtime. More...

Typedefs

template<typename Awaiter>
using RangedParallelAllAwaiter
 Awaiter to wait for all operations in a range to complete.
template<typename Awaiter>
using RangedParallelAnyAwaiter
 Awaiter to wait for any operation in a range to complete.
template<typename Awaiter>
using RangedWhenAllAwaiter
 Awaiter to wait for all operations in a range to complete.
template<typename Awaiter>
using RangedWhenAnyAwaiter
 Awaiter to wait for any operation in a range to complete.
template<typename Awaiter>
using RangedLinkAwaiter = RangedLinkAwaiterBase<IOSQE_IO_LINK, Awaiter>
 Awaiter that links multiple operations in a range using IO_LINK.
template<typename Awaiter>
using RangedHardLinkAwaiter = RangedLinkAwaiterBase<IOSQE_IO_HARDLINK, Awaiter>
 Awaiter that links multiple operations in a range using IO_HARDLINK.
template<typename... Awaiter>
using ParallelAllAwaiter
 Awaiter to wait for all operations to complete in parallel.
template<typename... Awaiter>
using ParallelAnyAwaiter
 Awaiter to wait for any operation to complete in parallel.
template<typename... Awaiter>
using WhenAllAwaiter
 Awaiter that waits for all operations to complete in parallel.
template<typename... Awaiter>
using WhenAnyAwaiter
 Awaiter that waits for any operation to complete in parallel.
template<typename... Awaiter>
using LinkAwaiter = LinkAwaiterBase<IOSQE_IO_LINK, Awaiter...>
 Awaiter that links multiple operations using IO_LINK.
template<typename... Awaiter>
using HardLinkAwaiter = LinkAwaiterBase<IOSQE_IO_HARDLINK, Awaiter...>
 Awaiter that links multiple operations using IO_HARDLINK.

Functions

template<FdLike Fd1, FdLike Fd2>
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.
template<FdLike Fd1, FdLike Fd2>
auto async_tee (Fd1 fd_in, Fd2 fd_out, unsigned int nbytes, unsigned int splice_flags)
 See io_uring_prep_tee.
template<FdLike Fd>
auto async_readv (Fd fd, const struct iovec *iovecs, unsigned nr_vecs, __u64 offset, int flags)
 See io_uring_prep_readv2.
template<FdLike Fd>
auto async_readv (Fd fd, detail::FixedBuffer< const iovec * > iovecs, unsigned nr_vecs, __u64 offset, int flags)
 See io_uring_prep_readv2.
template<FdLike Fd>
auto async_writev (Fd fd, const struct iovec *iovecs, unsigned int nr_vecs, __u64 offset, int flags)
 See io_uring_prep_writev2.
template<FdLike Fd>
auto async_writev (Fd fd, detail::FixedBuffer< const iovec * > iovecs, unsigned int nr_vecs, __u64 offset, int flags)
 See io_uring_prep_writev2.
template<FdLike Fd>
auto async_recvmsg (Fd fd, struct msghdr *msg, unsigned flags)
 See io_uring_prep_recvmsg.
template<FdLike Fd, typename MultiShotFunc, NotBundledBufferRing Buffer>
auto async_recvmsg_multishot (Fd fd, struct msghdr *msg, unsigned flags, Buffer &buf, MultiShotFunc &&func)
 See io_uring_prep_recvmsg_multishot.
template<FdLike Fd>
auto async_sendmsg (Fd fd, const struct msghdr *msg, unsigned flags)
 See io_uring_prep_sendmsg.
template<FdLike Fd, typename FreeFunc>
auto async_sendmsg_zc (Fd fd, const struct msghdr *msg, unsigned flags, FreeFunc &&func)
 See io_uring_prep_sendmsg_zc.
template<FdLike Fd, typename FreeFunc>
auto async_sendmsg_zc (Fd fd, detail::FixedBuffer< const msghdr * > msg, unsigned flags, FreeFunc &&func)
 See io_uring_prep_sendmsg_zc_fixed.
template<FdLike Fd>
auto async_fsync (Fd fd, unsigned fsync_flags)
 See io_uring_prep_fsync.
auto async_nop ()
 See io_uring_prep_nop.
auto async_timeout (struct __kernel_timespec *ts, unsigned count, unsigned flags)
 See io_uring_prep_timeout.
template<typename MultiShotFunc>
auto async_timeout_multishot (struct __kernel_timespec *ts, unsigned count, unsigned flags, MultiShotFunc &&func)
 See io_uring_prep_timeout.
template<FdLike Fd>
auto async_accept (Fd fd, struct sockaddr *addr, socklen_t *addrlen, int flags)
 See io_uring_prep_accept.
template<FdLike Fd>
auto async_accept_direct (Fd fd, struct sockaddr *addr, socklen_t *addrlen, int flags, unsigned int file_index)
 See io_uring_prep_accept_direct.
template<FdLike Fd, typename MultiShotFunc>
auto async_multishot_accept (Fd fd, struct sockaddr *addr, socklen_t *addrlen, int flags, MultiShotFunc &&func)
 See io_uring_prep_multishot_accept.
template<FdLike Fd, typename MultiShotFunc>
auto async_multishot_accept_direct (Fd fd, struct sockaddr *addr, socklen_t *addrlen, int flags, MultiShotFunc &&func)
 See io_uring_prep_multishot_accept_direct.
template<FdLike Fd>
auto async_cancel_fd (Fd fd, unsigned int flags)
 See io_uring_prep_cancel_fd.
auto async_link_timeout (struct __kernel_timespec *ts, unsigned flags)
 See io_uring_prep_link_timeout.
template<FdLike Fd>
auto async_connect (Fd fd, const struct sockaddr *addr, socklen_t addrlen)
 See io_uring_prep_connect.
auto async_files_update (int *fds, unsigned nr_fds, int offset)
 See io_uring_prep_files_update.
template<FdLike Fd>
auto async_fallocate (Fd fd, int mode, __u64 offset, __u64 len)
 See io_uring_prep_fallocate.
auto async_openat (int dfd, const char *path, int flags, mode_t mode)
 See io_uring_prep_openat.
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_open (const char *path, int flags, mode_t mode)
 See io_uring_prep_openat.
auto async_open_direct (const char *path, int flags, mode_t mode, unsigned file_index)
 See io_uring_prep_openat_direct.
auto async_close (int fd)
 See io_uring_prep_close.
auto async_close (detail::FixedFd fd)
 See io_uring_prep_close_direct.
template<FdLike Fd, BufferLike Buffer>
auto async_read (Fd fd, Buffer &&buf, __u64 offset)
 See io_uring_prep_read.
template<FdLike Fd, BufferLike Buffer>
auto async_read (Fd fd, detail::FixedBuffer< Buffer > buf, __u64 offset)
 See io_uring_prep_read_fixed.
template<FdLike Fd, NotBundledBufferRing Buffer>
auto async_read (Fd fd, Buffer &buf, __u64 offset)
 See io_uring_prep_read.
template<FdLike Fd, NotBundledBufferRing Buffer, typename MultiShotFunc>
auto async_read_multishot (Fd fd, Buffer &buf, __u64 offset, MultiShotFunc &&func)
 See io_uring_prep_read_multishot.
template<FdLike Fd, BufferLike Buffer>
auto async_write (Fd fd, Buffer &&buf, __u64 offset)
 See io_uring_prep_write.
template<FdLike Fd, BufferLike Buffer>
auto async_write (Fd fd, detail::FixedBuffer< Buffer > buf, __u64 offset)
 See io_uring_prep_write_fixed.
auto async_statx (int dfd, const char *path, int flags, unsigned mask, struct statx *statxbuf)
 See io_uring_prep_statx.
template<FdLike Fd>
auto async_fadvise (Fd fd, __u64 offset, off_t len, int advice)
 See io_uring_prep_fadvise.
template<FdLike Fd>
auto async_fadvise64 (Fd fd, __u64 offset, off_t len, int advice)
 See io_uring_prep_fadvise64.
auto async_madvise (void *addr, __u32 length, int advice)
 See io_uring_prep_madvise.
auto async_madvise64 (void *addr, off_t length, int advice)
 See io_uring_prep_madvise64.
template<FdLike Fd, BufferLike Buffer>
auto async_send (Fd sockfd, Buffer &&buf, int flags)
 See io_uring_prep_send.
template<FdLike Fd>
auto async_send (Fd sockfd, ProvidedBufferQueue &buf, int flags)
 See io_uring_prep_send.
template<FdLike Fd>
auto async_send (Fd sockfd, BundledProvidedBufferQueue &buf, int flags)
 See io_uring_prep_send.
template<FdLike Fd, BufferLike Buffer>
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.
template<FdLike Fd>
auto async_sendto (Fd sockfd, ProvidedBufferQueue &buf, int flags, const struct sockaddr *addr, socklen_t addrlen)
 See io_uring_prep_send and io_uring_prep_send_set_addr.
template<FdLike Fd>
auto async_sendto (Fd sockfd, BundledProvidedBufferQueue &buf, int flags, const struct sockaddr *addr, socklen_t addrlen)
 See io_uring_prep_send and io_uring_prep_send_set_addr.
template<FdLike Fd, typename Buffer, typename FreeFunc>
auto async_send_zc (Fd sockfd, Buffer &&buf, int flags, unsigned zc_flags, FreeFunc &&func)
 See io_uring_prep_send_zc.
template<FdLike Fd, BufferLike Buffer, typename FreeFunc>
auto async_send_zc (Fd sockfd, detail::FixedBuffer< Buffer > buf, int flags, unsigned zc_flags, FreeFunc &&func)
 See io_uring_prep_send_zc_fixed.
template<FdLike Fd, BufferLike Buffer, typename FreeFunc>
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.
template<FdLike Fd, BufferLike Buffer, typename FreeFunc>
auto async_sendto_zc (Fd sockfd, detail::FixedBuffer< Buffer > buf, int flags, const struct sockaddr *addr, socklen_t addrlen, unsigned zc_flags, FreeFunc &&func)
 See io_uring_prep_send_zc_fixed and io_uring_prep_send_set_addr.
template<FdLike Fd, BufferLike Buffer>
auto async_recv (Fd sockfd, Buffer &&buf, int flags)
 See io_uring_prep_recv.
template<FdLike Fd, NotBundledBufferRing Buffer>
auto async_recv (Fd sockfd, Buffer &buf, int flags)
 See io_uring_prep_recv.
template<FdLike Fd, BundledBufferRing Buffer>
auto async_recv (Fd sockfd, Buffer &buf, int flags)
 See io_uring_prep_recv.
template<FdLike Fd, NotBundledBufferRing Buffer, typename MultiShotFunc>
auto async_recv_multishot (Fd sockfd, Buffer &buf, int flags, MultiShotFunc &&func)
 See io_uring_prep_recv_multishot.
template<FdLike Fd, BundledBufferRing Buffer, typename MultiShotFunc>
auto async_recv_multishot (Fd sockfd, Buffer &buf, int flags, MultiShotFunc &&func)
 See io_uring_prep_recv_multishot.
auto async_openat2 (int dfd, const char *path, struct open_how *how)
 See io_uring_prep_openat2.
auto async_openat2_direct (int dfd, const char *path, struct open_how *how, unsigned file_index)
 See io_uring_prep_openat2_direct.
template<FdLike Fd>
auto async_shutdown (Fd fd, int how)
 See io_uring_prep_shutdown.
auto async_unlinkat (int dfd, const char *path, int flags)
 See io_uring_prep_unlinkat.
auto async_unlink (const char *path, int flags)
 See io_uring_prep_unlinkat.
auto async_renameat (int olddfd, const char *oldpath, int newdfd, const char *newpath, unsigned int flags)
 See io_uring_prep_renameat.
auto async_rename (const char *oldpath, const char *newpath)
 See io_uring_prep_renameat.
template<FdLike Fd>
auto async_sync_file_range (Fd fd, unsigned len, __u64 offset, int flags)
 See io_uring_prep_sync_file_range.
auto async_mkdirat (int dfd, const char *path, mode_t mode)
 See io_uring_prep_mkdirat.
auto async_mkdir (const char *path, mode_t mode)
 See io_uring_prep_mkdirat.
auto async_symlinkat (const char *target, int newdirfd, const char *linkpath)
 See io_uring_prep_symlinkat.
auto async_symlink (const char *target, const char *linkpath)
 See io_uring_prep_symlinkat.
auto async_linkat (int olddfd, const char *oldpath, int newdfd, const char *newpath, int flags)
 See io_uring_prep_linkat.
auto async_link (const char *oldpath, const char *newpath, int flags)
 See io_uring_prep_linkat.
auto async_getxattr (const char *name, char *value, const char *path, unsigned int len)
 See io_uring_prep_getxattr.
auto async_setxattr (const char *name, const char *value, const char *path, int flags, unsigned int len)
 See io_uring_prep_setxattr.
auto async_fgetxattr (int fd, const char *name, char *value, unsigned int len)
 See io_uring_prep_fgetxattr.
auto async_fsetxattr (int fd, const char *name, const char *value, int flags, unsigned int len)
 See io_uring_prep_fsetxattr.
auto async_socket (int domain, int type, int protocol, unsigned int flags)
 See io_uring_prep_socket.
auto async_socket_direct (int domain, int type, int protocol, unsigned file_index, unsigned int flags)
 See io_uring_prep_socket_direct.
template<FdLike Fd>
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_waitid (idtype_t idtype, id_t id, siginfo_t *infop, int options, unsigned int flags)
 See io_uring_prep_waitid.
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_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_futex_waitv (struct futex_waitv *futex, uint32_t nr_futex, unsigned int flags)
 See io_uring_prep_futex_waitv.
auto async_fixed_fd_install (int fixed_fd, unsigned int flags)
 See io_uring_prep_fixed_fd_install.
auto async_fixed_fd_send (FdTable &dst, int source_fd, int target_fd, unsigned int flags)
 See io_uring_prep_msg_ring_fd.
template<FdLike Fd>
auto async_ftruncate (Fd fd, loff_t len)
 See io_uring_prep_ftruncate.
template<FdLike Fd>
auto async_cmd_discard (Fd fd, uint64_t offset, uint64_t nbytes)
 See io_uring_prep_cmd_discard.
template<FdLike Fd>
auto async_bind (Fd fd, struct sockaddr *addr, socklen_t addrlen)
 See io_uring_prep_bind.
template<FdLike Fd>
auto async_listen (Fd fd, int backlog)
 See io_uring_prep_listen.
auto async_epoll_ctl (int epfd, int fd, int op, struct epoll_event *ev)
 See io_uring_prep_epoll_ctl.
auto async_epoll_wait (int fd, struct epoll_event *events, int maxevents, unsigned flags)
 See io_uring_prep_epoll_wait.
auto async_pipe (int *fds, int pipe_flags)
 See io_uring_prep_pipe.
auto async_pipe_direct (int *fds, int pipe_flags, unsigned int file_index)
 See io_uring_prep_pipe_direct.
template<typename Func, typename... Args>
auto make_op_awaiter (Func &&func, Args &&...args)
 This function creates a variant of OpAwaiter. OpAwaiter represents an asynchronous operation that can be awaited. It is basically a wrapper around an io_uring sqe preparation function.
template<typename MultiShotFunc, typename Func, typename... Args>
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 be awaited. It is basically a wrapper around an io_uring sqe preparation function.
template<BufferRingLike Br, typename Func, typename... Args>
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 be awaited. It is basically a wrapper around an io_uring sqe preparation function.
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)
 This function creates a variant of OpAwaiter. OpAwaiter represents an asynchronous operation that can be awaited. It is basically a wrapper around an io_uring sqe preparation function.
template<BufferRingLike Br, typename Func, typename... Args>
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 be awaited. It is basically a wrapper around an io_uring sqe preparation function.
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)
 This function creates a variant of OpAwaiter. OpAwaiter represents an asynchronous operation that can be awaited. It is basically a wrapper around an io_uring sqe preparation function.
template<typename FreeFunc, typename Func, typename... Args>
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 be awaited. It is basically a wrapper around an io_uring sqe preparation function.
template<unsigned int Flags, AwaiterLike Awaiter>
auto flag (Awaiter &&awaiter)
 Decorates an awaiter with specific io_uring sqe flags.
template<AwaiterLike Awaiter>
auto drain (Awaiter &&awaiter)
 Mark an awaiter as drain operation.
template<AwaiterLike Awaiter>
auto always_async (Awaiter &&awaiter)
 Mark an awaiter to always execute asynchronously.
template<template< AwaiterLike... Awaiter > typename AwaiterType, AwaiterLike... Awaiter>
auto parallel (Awaiter &&...awaiters)
 Compose multiple awaiters into a single awaiter that executes them in parallel.
template<template< typename Awaiter > typename RangedAwaiterType, AwaiterRange Range>
auto parallel (Range &&range)
 Compose multiple awaiters from a range into a single awaiter that executes them in parallel.
template<AwaiterLike... Awaiters>
auto when_all (Awaiters &&...awaiters)
 Compose multiple awaiters into a single awaiter that completes when all of them complete.
template<AwaiterRange Range>
auto when_all (Range &&range)
 Compose multiple awaiters from a range into a single awaiter that completes when all of them complete.
template<AwaiterLike... Awaiters>
auto when_any (Awaiters &&...awaiters)
 Compose multiple awaiters into a single awaiter that completes when any of them complete.
template<AwaiterRange Range>
auto when_any (Range &&range)
 Compose multiple awaiters from a range into a single awaiter that completes when any of them complete.
template<AwaiterLike... Awaiters>
auto link (Awaiters &&...awaiters)
 Compose multiple awaiters into a single awaiter that executes them in sequence.
template<AwaiterRange Range>
auto link (Range &&range)
 Compose multiple awaiters from a range into a single awaiter that executes them in sequence.
template<AwaiterLike... Awaiters>
auto hard_link (Awaiters &&...awaiters)
 Compose multiple awaiters into a single awaiter that executes them in sequence and continues even if one of them fails.
template<AwaiterRange Range>
auto hard_link (Range &&range)
 Compose multiple awaiters from a range into a single awaiter that executes them in sequence and continues even if one of them fails.
MutableBuffer buffer (void *data, size_t size)
 Create a buffer object from various data sources.
ConstBuffer buffer (const void *data, size_t size)
 Create a buffer object from various data sources.
template<typename PodType, size_t N>
MutableBuffer buffer (PodType(&arr)[N])
 Create a buffer object from various data sources.
template<typename PodType, size_t N>
ConstBuffer buffer (const PodType(&arr)[N])
 Create a buffer object from various data sources.
template<typename PodType, size_t N>
MutableBuffer buffer (std::array< PodType, N > &arr)
 Create a buffer object from various data sources.
template<typename PodType, size_t N>
ConstBuffer buffer (const std::array< PodType, N > &arr)
 Create a buffer object from various data sources.
template<typename PodType>
MutableBuffer buffer (std::vector< PodType > &vec)
 Create a buffer object from various data sources.
template<typename PodType>
ConstBuffer buffer (const std::vector< PodType > &vec)
 Create a buffer object from various data sources.
MutableBuffer buffer (std::string &str)
 Create a buffer object from various data sources.
ConstBuffer buffer (const std::string &str)
 Create a buffer object from various data sources.
ConstBuffer buffer (std::string_view strv)
 Create a buffer object from various data sources.
MutableBuffer buffer (iovec &iov)
 Create a buffer object from various data sources.
template<typename CoroFunc>
auto will_spawn (CoroFunc &&coro)
 Helper to build an invocable that spawns a coroutine on invocation.
template<typename Channel>
auto will_push (Channel &channel)
 Helper to build an invocable that pushes the result to a channel on invocation.
auto fixed (int fd)
 Mark a file descriptor as fixed for io_uring operations.
template<BufferLike Buffer>
auto fixed (int buf_index, Buffer &&buf)
 Mark a buffer as fixed for io_uring operations.
auto fixed (int buf_index, const struct iovec *iov)
 Mark iovecs as fixed for io_uring operations.
auto fixed (int buf_index, const struct msghdr *msg)
 Mark msghdr as fixed for io_uring operations.
auto & bundled (ProvidedBufferPool &buffer)
 Get the bundled variant of a provided buffer pool. This will enable buffer bundling feature of io_uring.
auto & bundled (ProvidedBufferQueue &buffer)
 Get the bundled variant of a provided buffer queue. This will enable buffer bundling feature of io_uring.
auto & current_runtime ()
 Get the current runtime.
void set_current_cred_id (uint16_t id)
 Set the current cred id object.
template<typename T, typename Allocator>
sync_wait (Runtime &runtime, Coro< T, Allocator > coro)
 Synchronously wait for a coroutine to complete in the given runtime.
RuntimeOptionsdefault_runtime_options ()
 Get the default runtime options. This options will be used when using sync_wait without specifying runtime.
template<typename T, typename Allocator>
sync_wait (Coro< T, Allocator > coro)
 Synchronously wait for a coroutine to complete using a default runtime. The runtime will be created and destroyed for each call.
template<typename T, typename Allocator>
Task< T, Allocator > co_spawn (Runtime &runtime, Coro< T, Allocator > coro)
 Spawn a coroutine as a task in the given runtime.
template<typename T, typename Allocator>
Task< T, Allocator > co_spawn (Coro< T, Allocator > coro)
 Spawn a coroutine as a task in the current runtime.
detail::SwitchAwaiter co_switch (Runtime &runtime)
 Switch current coroutine task to the given runtime.
template<typename Func>
Defer defer (Func &&func)
 Defer the execution of a function until the current scope ends.

Detailed Description

The main namespace for the Condy library.

All classes, functions, and types provided by the Condy library are encapsulated within this namespace.

Typedef Documentation

◆ HardLinkAwaiter

template<typename... Awaiter>
using condy::HardLinkAwaiter = LinkAwaiterBase<IOSQE_IO_HARDLINK, Awaiter...>

Awaiter that links multiple operations using IO_HARDLINK.

An awaiter that links multiple operations using IO_HARDLINK.

Template Parameters
AwaiterThe types of the awaiters.
Returns
std::tuple<...> A tuple of results from each awaiter.

◆ LinkAwaiter

template<typename... Awaiter>
using condy::LinkAwaiter = LinkAwaiterBase<IOSQE_IO_LINK, Awaiter...>

Awaiter that links multiple operations using IO_LINK.

An awaiter that links multiple operations using IO_LINK.

Template Parameters
AwaiterThe types of the awaiters.
Returns
std::tuple<...> A tuple of results from each awaiter.

◆ ParallelAllAwaiter

template<typename... Awaiter>
using condy::ParallelAllAwaiter
Initial value:
ParallelAwaiterBase<
ParallelAllFinishHandle<typename Awaiter::HandleType...>, Awaiter...>

Awaiter to wait for all operations to complete in parallel.

An awaiter that waits for all operations to complete in parallel. Unlike WhenAllAwaiter, this awaiter will also return the order of completion.

Template Parameters
AwaiterThe types of the awaiters.
Returns
std::pair<std::array<size_t, N>, std::tuple<...>> A pair containing an array of completion orders and a tuple of results from each awaiter.

◆ ParallelAnyAwaiter

template<typename... Awaiter>
using condy::ParallelAnyAwaiter
Initial value:
ParallelAwaiterBase<
ParallelAnyFinishHandle<typename Awaiter::HandleType...>, Awaiter...>

Awaiter to wait for any operation to complete in parallel.

An awaiter that waits for any operation to complete in parallel. Unlike WhenAnyAwaiter, this awaiter will return the order of completion of all operations and the result of each awaiter.

Template Parameters
AwaiterThe types of the awaiters.
Returns
std::pair<std::array<size_t, N>, std::tuple<...>> A pair containing an array of completion orders and a tuple of results from each awaiter.

◆ RangedHardLinkAwaiter

template<typename Awaiter>
using condy::RangedHardLinkAwaiter = RangedLinkAwaiterBase<IOSQE_IO_HARDLINK, Awaiter>

Awaiter that links multiple operations in a range using IO_HARDLINK.

An awaiter that links multiple operations in a range using IO_HARDLINK.

Template Parameters
AwaiterThe type of the awaiters in the range.
Returns
std::vector<...> A vector of results from each awaiter.

◆ RangedLinkAwaiter

template<typename Awaiter>
using condy::RangedLinkAwaiter = RangedLinkAwaiterBase<IOSQE_IO_LINK, Awaiter>

Awaiter that links multiple operations in a range using IO_LINK.

An awaiter that links multiple operations in a range using IO_LINK.

Template Parameters
AwaiterThe type of the awaiters in the range.
Returns
std::vector<...> A vector of results from each awaiter.

◆ RangedParallelAllAwaiter

template<typename Awaiter>
using condy::RangedParallelAllAwaiter
Initial value:
RangedParallelAwaiterBase<
RangedParallelAllFinishHandle<typename Awaiter::HandleType>, Awaiter>

Awaiter to wait for all operations in a range to complete.

An awaiter that waits for all operations in a range to complete. Unlike RangedWhenAllAwaiter, this awaiter will also return the order of completion.

Template Parameters
AwaiterThe type of the awaiters in the range.
Returns
std::pair<std::vector<size_t>, std::vector<...>> A pair containing a vector of completion orders and a vector of results from each awaiter.

◆ RangedParallelAnyAwaiter

template<typename Awaiter>
using condy::RangedParallelAnyAwaiter
Initial value:
RangedParallelAwaiterBase<
RangedParallelAnyFinishHandle<typename Awaiter::HandleType>, Awaiter>

Awaiter to wait for any operation in a range to complete.

An awaiter that waits for any operation in a range to complete. Unlike RangedWhenAnyAwaiter, this awaiter will return the order of completion of all operations and the result of each awaiter.

Template Parameters
AwaiterThe type of the awaiters in the range.
Returns
std::pair<std::vector<size_t>, std::vector<...>> A pair containing a vector of completion orders and a vector of results from each awaiter.

◆ RangedWhenAllAwaiter

template<typename Awaiter>
using condy::RangedWhenAllAwaiter
Initial value:
RangedParallelAwaiterBase<
RangedWhenAllFinishHandle<typename Awaiter::HandleType>, Awaiter>

Awaiter to wait for all operations in a range to complete.

An awaiter that waits for all operations in a range to complete.

Template Parameters
AwaiterThe type of the awaiters in the range.
Returns
std::vector<...> A vector of results from each awaiter.

◆ RangedWhenAnyAwaiter

template<typename Awaiter>
using condy::RangedWhenAnyAwaiter
Initial value:
RangedParallelAwaiterBase<
RangedWhenAnyFinishHandle<typename Awaiter::HandleType>, Awaiter>

Awaiter to wait for any operation in a range to complete.

An awaiter that waits for any operation in a range to complete.

Template Parameters
AwaiterThe type of the awaiters in the range.
Returns
std::pair<size_t, ...> A pair containing the index of the completed awaiter and its result.

◆ WhenAllAwaiter

template<typename... Awaiter>
using condy::WhenAllAwaiter
Initial value:
ParallelAwaiterBase<WhenAllFinishHandle<typename Awaiter::HandleType...>,
Awaiter...>

Awaiter that waits for all operations to complete in parallel.

An awaiter that waits for all operations to complete in parallel.

Template Parameters
AwaiterThe types of the awaiters.
Returns
std::tuple<...> A tuple of results from each awaiter.

◆ WhenAnyAwaiter

template<typename... Awaiter>
using condy::WhenAnyAwaiter
Initial value:
ParallelAwaiterBase<WhenAnyFinishHandle<typename Awaiter::HandleType...>,
Awaiter...>

Awaiter that waits for any operation to complete in parallel.

An awaiter that waits for any operation to complete in parallel.

Template Parameters
AwaiterThe types of the awaiters.
Returns
std::variant<...> A variant containing the result of the completed awaiter.

Function Documentation

◆ always_async()

template<AwaiterLike Awaiter>
auto condy::always_async ( Awaiter && awaiter)

Mark an awaiter to always execute asynchronously.

Parameters
awaiterThe awaiter to decorate.

◆ buffer() [1/12]

template<typename PodType, size_t N>
ConstBuffer condy::buffer ( const PodType(&) arr[N])
inline

Create a buffer object from various data sources.

These overloaded functions construct either MutableBuffer or ConstBuffer from raw pointers, arrays, std::array, std::vector, std::string, std::string_view, or iovec. They provide a unified way to convert different types of memory regions into buffer objects for use in asynchronous operations.

◆ buffer() [2/12]

template<typename PodType, size_t N>
ConstBuffer condy::buffer ( const std::array< PodType, N > & arr)
inline

Create a buffer object from various data sources.

These overloaded functions construct either MutableBuffer or ConstBuffer from raw pointers, arrays, std::array, std::vector, std::string, std::string_view, or iovec. They provide a unified way to convert different types of memory regions into buffer objects for use in asynchronous operations.

◆ buffer() [3/12]

ConstBuffer condy::buffer ( const std::string & str)
inline

Create a buffer object from various data sources.

These overloaded functions construct either MutableBuffer or ConstBuffer from raw pointers, arrays, std::array, std::vector, std::string, std::string_view, or iovec. They provide a unified way to convert different types of memory regions into buffer objects for use in asynchronous operations.

◆ buffer() [4/12]

template<typename PodType>
ConstBuffer condy::buffer ( const std::vector< PodType > & vec)
inline

Create a buffer object from various data sources.

These overloaded functions construct either MutableBuffer or ConstBuffer from raw pointers, arrays, std::array, std::vector, std::string, std::string_view, or iovec. They provide a unified way to convert different types of memory regions into buffer objects for use in asynchronous operations.

◆ buffer() [5/12]

ConstBuffer condy::buffer ( const void * data,
size_t size )
inline

Create a buffer object from various data sources.

These overloaded functions construct either MutableBuffer or ConstBuffer from raw pointers, arrays, std::array, std::vector, std::string, std::string_view, or iovec. They provide a unified way to convert different types of memory regions into buffer objects for use in asynchronous operations.

◆ buffer() [6/12]

MutableBuffer condy::buffer ( iovec & iov)
inline

Create a buffer object from various data sources.

These overloaded functions construct either MutableBuffer or ConstBuffer from raw pointers, arrays, std::array, std::vector, std::string, std::string_view, or iovec. They provide a unified way to convert different types of memory regions into buffer objects for use in asynchronous operations.

◆ buffer() [7/12]

template<typename PodType, size_t N>
MutableBuffer condy::buffer ( PodType(&) arr[N])
inline

Create a buffer object from various data sources.

These overloaded functions construct either MutableBuffer or ConstBuffer from raw pointers, arrays, std::array, std::vector, std::string, std::string_view, or iovec. They provide a unified way to convert different types of memory regions into buffer objects for use in asynchronous operations.

◆ buffer() [8/12]

template<typename PodType, size_t N>
MutableBuffer condy::buffer ( std::array< PodType, N > & arr)
inline

Create a buffer object from various data sources.

These overloaded functions construct either MutableBuffer or ConstBuffer from raw pointers, arrays, std::array, std::vector, std::string, std::string_view, or iovec. They provide a unified way to convert different types of memory regions into buffer objects for use in asynchronous operations.

◆ buffer() [9/12]

MutableBuffer condy::buffer ( std::string & str)
inline

Create a buffer object from various data sources.

These overloaded functions construct either MutableBuffer or ConstBuffer from raw pointers, arrays, std::array, std::vector, std::string, std::string_view, or iovec. They provide a unified way to convert different types of memory regions into buffer objects for use in asynchronous operations.

◆ buffer() [10/12]

ConstBuffer condy::buffer ( std::string_view strv)
inline

Create a buffer object from various data sources.

These overloaded functions construct either MutableBuffer or ConstBuffer from raw pointers, arrays, std::array, std::vector, std::string, std::string_view, or iovec. They provide a unified way to convert different types of memory regions into buffer objects for use in asynchronous operations.

◆ buffer() [11/12]

template<typename PodType>
MutableBuffer condy::buffer ( std::vector< PodType > & vec)
inline

Create a buffer object from various data sources.

These overloaded functions construct either MutableBuffer or ConstBuffer from raw pointers, arrays, std::array, std::vector, std::string, std::string_view, or iovec. They provide a unified way to convert different types of memory regions into buffer objects for use in asynchronous operations.

◆ buffer() [12/12]

MutableBuffer condy::buffer ( void * data,
size_t size )
inline

Create a buffer object from various data sources.

These overloaded functions construct either MutableBuffer or ConstBuffer from raw pointers, arrays, std::array, std::vector, std::string, std::string_view, or iovec. They provide a unified way to convert different types of memory regions into buffer objects for use in asynchronous operations.

◆ bundled() [1/2]

auto & condy::bundled ( ProvidedBufferPool & buffer)
inline

Get the bundled variant of a provided buffer pool. This will enable buffer bundling feature of io_uring.

Parameters
bufferThe provided buffer pool.
Returns
auto& The bundled variant of the provided buffer.
Note
When using bundled provided buffer pool, the return type of async operations will be a vector of ProvidedBuffer instead of a single buffer.

◆ bundled() [2/2]

auto & condy::bundled ( ProvidedBufferQueue & buffer)
inline

Get the bundled variant of a provided buffer queue. This will enable buffer bundling feature of io_uring.

Parameters
bufferThe provided buffer queue.
Returns
auto& The bundled variant of the provided buffer.

◆ co_spawn() [1/2]

template<typename T, typename Allocator>
Task< T, Allocator > condy::co_spawn ( Coro< T, Allocator > coro)
inline

Spawn a coroutine as a task in the current runtime.

Template Parameters
TReturn type of the coroutine.
AllocatorAllocator type used for memory management.
Parameters
coroThe coroutine to be spawned.
Returns
Task<T, Allocator> The spawned task.
Exceptions
std::logic_errorIf there is no current runtime.

◆ co_spawn() [2/2]

template<typename T, typename Allocator>
Task< T, Allocator > condy::co_spawn ( Runtime & runtime,
Coro< T, Allocator > coro )
inline

Spawn a coroutine as a task in the given runtime.

Template Parameters
TReturn type of the coroutine.
AllocatorAllocator type used for memory management.
Parameters
runtimeThe runtime to spawn the coroutine in.
coroThe coroutine to be spawned.
Returns
Task<T, Allocator> The spawned task.

This function schedules the given coroutine to run as a task in the specified runtime. The coroutine will be executed concurrently in the runtime.

◆ co_switch()

detail::SwitchAwaiter condy::co_switch ( Runtime & runtime)
inline

Switch current coroutine task to the given runtime.

Parameters
runtimeThe runtime to switch to.
Returns
detail::SwitchAwaiter Awaiter object for the switch operation.

This function suspends the current coroutine and reschedules it to run in the specified runtime. The caller coroutine will be resumed in the target runtime.

◆ current_runtime()

auto & condy::current_runtime ( )
inline

Get the current runtime.

Returns
Runtime& Reference to the current running runtime.
Note
This function assumes that there is a current runtime. Calling this function outside of a coroutine will lead to undefined behavior.

◆ default_runtime_options()

RuntimeOptions & condy::default_runtime_options ( )
inline

Get the default runtime options. This options will be used when using sync_wait without specifying runtime.

Returns
RuntimeOptions& Reference to the default runtime options.

◆ defer()

template<typename Func>
Defer condy::defer ( Func && func)

Defer the execution of a function until the current scope ends.

Parameters
funcThe function to be executed upon scope exit.
Returns
Defer object that will execute the function when it goes out of scope.

◆ drain()

template<AwaiterLike Awaiter>
auto condy::drain ( Awaiter && awaiter)

Mark an awaiter as drain operation.

Parameters
awaiterThe awaiter to decorate.

◆ fixed() [1/4]

template<BufferLike Buffer>
auto condy::fixed ( int buf_index,
Buffer && buf )

Mark a buffer as fixed for io_uring operations.

The async_* functions can identify the fixed buffer and set the appropriate flags for io_uring operations.

Template Parameters
BufferType of the buffer.
Parameters
bufThe buffer to be marked as fixed.
buf_indexThe index in the registered buffer table.
Returns
auto A helper object representing the fixed buffer.

◆ fixed() [2/4]

auto condy::fixed ( int buf_index,
const struct iovec * iov )
inline

Mark iovecs as fixed for io_uring operations.

The async_* functions can identify the fixed iovec buffer and set the appropriate flags for io_uring operations.

Parameters
buf_indexThe index in the registered buffer table.
iovPointer to the iovec array.
Returns
auto A helper object representing the fixed iovec buffer.

◆ fixed() [3/4]

auto condy::fixed ( int buf_index,
const struct msghdr * msg )
inline

Mark msghdr as fixed for io_uring operations.

The async_* functions can identify the fixed msghdr buffer and set the appropriate flags for io_uring operations.

Parameters
buf_indexThe index in the registered buffer table.
msgPointer to the msghdr structure.
Returns
auto A helper object representing the fixed msghdr buffer.

◆ fixed() [4/4]

auto condy::fixed ( int fd)
inline

Mark a file descriptor as fixed for io_uring operations.

The async_* functions can identify the fixed file descriptor and set the appropriate flags for io_uring operations.

Parameters
fdThe file descriptor to be marked as fixed. A fixed file descriptor points to the index in the registered file descriptor table.
Returns
auto A helper object representing the fixed file descriptor.

◆ flag()

template<unsigned int Flags, AwaiterLike Awaiter>
auto condy::flag ( Awaiter && awaiter)

Decorates an awaiter with specific io_uring sqe flags.

Template Parameters
FlagsThe io_uring sqe flags to set.
Parameters
awaiterThe awaiter to decorate.
Returns
auto The decorated awaiter.

◆ hard_link() [1/2]

template<AwaiterLike... Awaiters>
auto condy::hard_link ( Awaiters &&... awaiters)

Compose multiple awaiters into a single awaiter that executes them in sequence and continues even if one of them fails.

Template Parameters
AwaitersTypes of the awaiters to compose.
Parameters
awaitersThe awaiters to compose.
Returns
HardLinkAwaiter The composed awaiter.

◆ hard_link() [2/2]

template<AwaiterRange Range>
auto condy::hard_link ( Range && range)

Compose multiple awaiters from a range into a single awaiter that executes them in sequence and continues even if one of them fails.

Template Parameters
RangeType of the range containing the awaiters.
Parameters
rangeThe range of awaiters to compose.
Returns
RangedHardLinkAwaiter The composed awaiter.

◆ link() [1/2]

template<AwaiterLike... Awaiters>
auto condy::link ( Awaiters &&... awaiters)

Compose multiple awaiters into a single awaiter that executes them in sequence.

Template Parameters
AwaitersTypes of the awaiters to compose.
Parameters
awaitersThe awaiters to compose.
Returns
LinkAwaiter The composed awaiter.

◆ link() [2/2]

template<AwaiterRange Range>
auto condy::link ( Range && range)

Compose multiple awaiters from a range into a single awaiter that executes them in sequence.

Template Parameters
RangeType of the range containing the awaiters.
Parameters
rangeThe range of awaiters to compose.
Returns
RangedLinkAwaiter The composed awaiter.

◆ make_bundle_select_buffer_op_awaiter()

template<BufferRingLike Br, typename Func, typename... Args>
auto condy::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 be awaited. It is basically a wrapper around an io_uring sqe preparation function.

◆ make_multishot_bundle_select_buffer_op_awaiter()

template<typename MultiShotFunc, BufferRingLike Br, typename Func, typename... Args>
auto condy::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 be awaited. It is basically a wrapper around an io_uring sqe preparation function.

◆ make_multishot_op_awaiter()

template<typename MultiShotFunc, typename Func, typename... Args>
auto condy::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 be awaited. It is basically a wrapper around an io_uring sqe preparation function.

◆ make_multishot_select_buffer_op_awaiter()

template<typename MultiShotFunc, BufferRingLike Br, typename Func, typename... Args>
auto condy::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 be awaited. It is basically a wrapper around an io_uring sqe preparation function.

◆ make_select_buffer_op_awaiter()

template<BufferRingLike Br, typename Func, typename... Args>
auto condy::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 be awaited. It is basically a wrapper around an io_uring sqe preparation function.

◆ make_zero_copy_op_awaiter()

template<typename FreeFunc, typename Func, typename... Args>
auto condy::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 be awaited. It is basically a wrapper around an io_uring sqe preparation function.

◆ parallel() [1/2]

template<template< AwaiterLike... Awaiter > typename AwaiterType, AwaiterLike... Awaiter>
auto condy::parallel ( Awaiter &&... awaiters)

Compose multiple awaiters into a single awaiter that executes them in parallel.

Template Parameters
AwaiterTypeAwaiter template to use for composing the awaiters.
AwaiterTypes of the awaiters to compose.
Parameters
awaitersThe awaiters to compose.
Returns
auto The composed awaiter.

◆ parallel() [2/2]

template<template< typename Awaiter > typename RangedAwaiterType, AwaiterRange Range>
auto condy::parallel ( Range && range)

Compose multiple awaiters from a range into a single awaiter that executes them in parallel.

Template Parameters
RangedAwaiterTypeAwaiter template to use for composing the awaiters.
RangeType of the range containing the awaiters.
Parameters
rangeThe range of awaiters to compose.
Returns
auto The composed awaiter.

◆ set_current_cred_id()

void condy::set_current_cred_id ( uint16_t id)
inline

Set the current cred id object.

Parameters
idThe cred id to set, which is generated by RingSettings::apply_personality().

◆ sync_wait() [1/2]

template<typename T, typename Allocator>
T condy::sync_wait ( Coro< T, Allocator > coro)

Synchronously wait for a coroutine to complete using a default runtime. The runtime will be created and destroyed for each call.

Template Parameters
TType of the coroutine result.
AllocatorAllocator type used for memory management.
Parameters
coroThe coroutine to be run.
Returns
T The result of the coroutine.
Note
This function will exit after all coroutines are completed.

◆ sync_wait() [2/2]

template<typename T, typename Allocator>
T condy::sync_wait ( Runtime & runtime,
Coro< T, Allocator > coro )

Synchronously wait for a coroutine to complete in the given runtime.

Template Parameters
TType of the coroutine result.
AllocatorAllocator type used for memory management.
Parameters
runtimeThe runtime to run the coroutine in.
coroThe coroutine to be run.
Returns
T The result of the coroutine.
Note
This function will exit after all coroutines are completed.

◆ when_all() [1/2]

template<AwaiterLike... Awaiters>
auto condy::when_all ( Awaiters &&... awaiters)

Compose multiple awaiters into a single awaiter that completes when all of them complete.

Template Parameters
AwaitersTypes of the awaiters to compose.
Parameters
awaitersThe awaiters to compose.
Returns
WhenAllAwaiter The composed awaiter.

◆ when_all() [2/2]

template<AwaiterRange Range>
auto condy::when_all ( Range && range)

Compose multiple awaiters from a range into a single awaiter that completes when all of them complete.

Template Parameters
RangeType of the range containing the awaiters.
Parameters
rangeThe range of awaiters to compose.
Returns
RangedWhenAllAwaiter The composed awaiter.

◆ when_any() [1/2]

template<AwaiterLike... Awaiters>
auto condy::when_any ( Awaiters &&... awaiters)

Compose multiple awaiters into a single awaiter that completes when any of them complete.

Template Parameters
AwaitersTypes of the awaiters to compose.
Parameters
awaitersThe awaiters to compose.
Returns
WhenAnyAwaiter The composed awaiter.
Note
If multiple awaiters complete simultaneously, the result will only contain one of the results.

◆ when_any() [2/2]

template<AwaiterRange Range>
auto condy::when_any ( Range && range)

Compose multiple awaiters from a range into a single awaiter that completes when any of them complete.

Template Parameters
RangeType of the range containing the awaiters.
Parameters
rangeThe range of awaiters to compose.
Returns
RangedWhenAnyAwaiter The composed awaiter.

◆ will_push()

template<typename Channel>
auto condy::will_push ( Channel & channel)

Helper to build an invocable that pushes the result to a channel on invocation.

Template Parameters
ChannelType of the channel.
Parameters
channelThe channel to push to.
Returns
An invocable object that pushes to the channel when invoked.

The use case of this helper is to pass the invocable to an async operation that accepts a completion callback. For example, async_read_multishot().

◆ will_spawn()

template<typename CoroFunc>
auto condy::will_spawn ( CoroFunc && coro)

Helper to build an invocable that spawns a coroutine on invocation.

Template Parameters
CoroFuncType of the coroutine function.
Parameters
coroThe coroutine function to be spawned.
Returns
An invocable object that spawns the coroutine when invoked.

The use case of this helper is to pass the invocable to an async operation that accepts a completion callback. For example, async_multishot_accept().