Classes | |
struct | AnyReceiverT |
struct | AnySenderOfT |
struct | AnySenderT |
struct | EnvPromise |
struct | ForwardingQuery |
struct | GetCompletionScheduler |
struct | InlineScheduler |
class | Lazy |
struct | Protocol |
class | RunLoop |
struct | SequenceTag |
struct | SetError |
struct | SetStopped |
struct | SetValue |
class | WithAwaitableSenders |
struct | WithAwaitTransform |
Concepts | |
concept | Scope |
A type which models an async scope. | |
Typedefs | |
using | Stopped = decltype(just_stopped()) |
template<concepts::Interface Interface, typename Env> | |
using | InterfaceWithEnv |
template<typename Env = void, concepts::AnyStorage Storage = any::HybridStorage<any::StorageCategory::MoveOnly, 8 * sizeof(void*), alignof(void*)>, typename VTablePolicy = any::MaybeInlineVTable<3>> | |
using | AnyOperationState = Any<InterfaceWithEnv<meta::List<types::Tag<execution::start>>, Env>, Storage, VTablePolicy> |
template<concepts::ValidCompletionSignatures Sigs, typename Env = void, concepts::AnyStorage Storage = any::InlineStorage<2 * sizeof(void*), alignof(void*)>, typename VTablePolicy = any::MaybeInlineVTable<3>> | |
using | AnyReceiver = meta::Type<AnyReceiverT<Sigs, Env, Storage, VTablePolicy>> |
template<concepts::ValidCompletionSignatures Sigs, typename Env = void, concepts::AnyStorage Storage = any::HybridStorage<>, typename VTablePolicy = any::MaybeInlineVTable<3>, concepts::OperationState Op = AnyOperationState<>, typename Rec = AnyReceiver<detail::AnySigs<Sigs>>> | |
using | AnySender = meta::Type<AnySenderT<Sigs, Env, Storage, VTablePolicy, Op, Rec>> |
template<typename T = void> | |
using | AnySenderOf = meta::Type<AnySenderOfT<T>> |
template<typename Tag, typename Val> | |
using | With = make_env_ns::With<Tag, Val> |
Represent a override for an environment query. | |
template<typename Tag> | |
using | Without = make_env_ns::Without<Tag> |
Represent a removal of an environment query value. | |
template<typename BaseEnv, typename... Withs> | |
using | MakeEnv = decltype(make_env(util::declval<BaseEnv>(), util::declval<Withs>()...)) |
Represent an environment with overrides for queries. | |
template<concepts::ClassType Self, concepts::Receiver Base = receiver_interface_ns::fake_receiver::FakeReceiver> | |
using | ReceiverAdaptor = meta::Type<receiver_interface_ns::ReceiverAdaptor<Self, Base>> |
template<concepts::Allocator Alloc = platform::DefaultAllocator> | |
using | CountingScope = meta::Type<counting_scope_ns::CountingScopeT<Alloc>> |
A scope that waits for all spawned senders to complete. | |
template<typename Ref, typename Value = void> | |
using | AsyncGenerator = meta::Type<async_generator_ns::AsyncGeneratorT<Ref, Value>> |
Enumerations | |
enum class | ForwardProgressGuarantee { Concurrent , Parallel , WeaklyParallel } |
Variables | |
constexpr auto | bulk = function::curry_back(bulk_ns::Function {}, c_<3ZU>) |
Bulk apply a function to a range of values. | |
constexpr auto | ensure_started = ensure_started_ns::Function {} |
Eagerly start a sender. | |
constexpr auto | execute = execute_ns::Function {} |
Executes a function on a scheduler. | |
constexpr auto | into_result = into_result_ns::Function {} |
constexpr auto | into_variant_result = into_result_ns::VariantFunction {} |
constexpr auto | into_variant = into_variant_ns::Function {} |
constexpr auto | just = just_ns::Function {} |
constexpr auto | just_error = just_ns::ErrorFunction {} |
constexpr auto | just_stopped = just_ns::StoppedFunction {} |
constexpr auto | stopped = just_stopped() |
constexpr auto | just_from = just_from_ns::Function {} |
Creates a sender from a function. | |
constexpr auto | just_or_error = just_or_error_ns::Function {} |
constexpr auto | just_void_or_stopped = just_void_or_stopped_ns::Function {} |
constexpr auto | let_value = function::curry_back(let_ns::Function<SetValue> {}, meta::c_<2ZU>) |
constexpr auto | let_error = function::curry_back(let_ns::Function<SetError> {}, meta::c_<2ZU>) |
constexpr auto | let_stopped = function::curry_back(let_ns::Function<SetStopped> {}, meta::c_<2ZU>) |
constexpr auto | let_value_with = let_value_with_ns::Function {} |
Inject values into an operation state. | |
constexpr auto | on = on_ns::Function {} |
constexpr auto | read = read_ns::Function {} |
constexpr auto | repeat_effect = repeat_effect_ns::Function {} |
constexpr auto | repeat_effect_until = function::curry_back(repeat_effect_until_ns::Function {}, meta::c_<2ZU>) |
constexpr auto | schedule_from = schedule_from_ns::Function {} |
constexpr auto | split = function::curry_back(split_ns::Function {}, c_<2ZU>) |
Split a sender into a sender which sends the same value to multiple receivers. | |
constexpr auto | start_detached = start_detached_ns::Function {} |
Start a sender without waiting for it to complete. | |
constexpr auto | stopped_as_error = function::curry_back(stopped_as_error_ns::Function {}, meta::c_<2ZU>) |
constexpr auto | stopped_as_optional = stopped_as_optional_ns::Function {} |
constexpr auto | sync_wait = sync_wait_ns::Function {} |
constexpr auto | sync_wait_with_variant = sync_wait_ns::WithVariantFunction {} |
constexpr auto | sync_wait_on = function::curry(sync_wait_ns::OnFunction {}, meta::c_<2ZU>) |
constexpr auto | sync_wait_with_variant_on |
constexpr auto | then = function::curry_back(then_ns::ValueFunction {}, c_<2ZU>) |
A sender that maps values into another value. | |
constexpr auto | upon_error = function::curry_back(then_ns::ErrorFunction {}, c_<2ZU>) |
A sender that maps an error into a value. | |
constexpr auto | upon_stopped = function::curry_back(then_ns::StoppedFunction {}, c_<2ZU>) |
A sender that maps the stop signal into a value. | |
constexpr auto | transfer = function::curry_back(transfer_ns::Function {}, meta::c_<2ZU>) |
constexpr auto | transfer_just = transfer_just_ns::Function {} |
constexpr auto | use_resources = use_resources_ns::Function {} |
Use async resources. | |
constexpr auto | when_all = when_all_ns::Function {} |
constexpr auto | when_all_with_variant = when_all_ns::VariantFunction {} |
constexpr auto | transfer_when_all = when_all_ns::TransferFunction {} |
constexpr auto | transfer_when_all_with_variant = when_all_ns::TransferVariantFunction {} |
constexpr auto | with_env = function::curry(with_env_ns::Function {}, c_<2ZU>) |
Adapts a sender to run with a specified environment. | |
constexpr auto | with_debug_env = with_env_ns::DebugFunction {} |
Adapts a sender to run with a debug environment. | |
constexpr as_awaitable_ns::Function | as_awaitable = {} |
constexpr auto | connect = detail::ConnectFunction {} |
template<typename S> | |
constexpr bool | enable_sender = requires { typename S::is_sender; } |
template<concepts::IsAwaitable< EnvPromise< types::EmptyEnv > > S> | |
constexpr bool | enable_sender< S > = true |
constexpr auto | get_env = detail::GetEnvFunction {} |
constexpr auto | run = run_ns::Function {} |
Obtain access to an async resource. | |
constexpr auto | schedule = detail::ScheduleFunction {} |
constexpr auto | start = detail::StartFunction {} |
constexpr auto | async_make_socket = async_net_ns::AsyncMakeSocket {} |
constexpr auto | async_accept = async_net_ns::AsyncAccept {} |
constexpr auto | async_bind = async_net_ns::AsyncBind {} |
constexpr auto | async_connect = async_net_ns::AsyncConnect {} |
constexpr auto | async_listen = async_net_ns::AsyncListen {} |
constexpr auto | async_shutdown = async_net_ns::AsyncShutdown {} |
constexpr auto | async_open = async_open_ns::Function {} |
constexpr auto | async_read_exactly = async_read_exactly_ns::Function {} |
constexpr auto | async_read_some = async_read_some_ns::Function {} |
constexpr auto | async_write_exactly = async_write_exactly_ns::Function {} |
constexpr auto | async_write_some = async_write_some_ns::Function {} |
template<concepts::InstanceOf< Protocol > Proto> | |
constexpr auto | ipc_binary_connect_to_client = ipc_binary_ns::ConnectToClientFunction<Proto> {} |
template<concepts::InstanceOf< Protocol > Proto> | |
constexpr auto | ipc_binary_connect_to_server = ipc_binary_ns::ConnectToServerFunction<Proto> {} |
constexpr auto | send = send_ns::Function {} |
constexpr auto | forwarding_query = ForwardingQuery {} |
constexpr auto | get_allocator = detail::GetAllocatorFunction {} |
template<concepts::OneOf< SetValue, SetError, SetStopped > CPO> | |
constexpr auto | get_completion_scheduler = GetCompletionScheduler<CPO> {} |
constexpr auto | get_completion_signatures = detail::GetCompletionSignaturesFunction {} |
constexpr auto | get_delegatee_scheduler = detail::GetDelegateeSchedulerFunction {} |
constexpr auto | get_forward_progress_guarantee = detail::GetForwardProgressGuaranteeFunction {} |
constexpr auto | get_scheduler = detail::GetSchedulerFunction {} |
constexpr auto | get_sequence_cardinality = get_sequence_cardinality_ns::Function {} |
A query that returns the cardinality of a sequence. | |
constexpr auto | get_stop_token = detail::GetStopTokenFunction {} |
constexpr auto | is_always_lockstep_sequence = is_always_lockstop_sequence_ns::Function {} |
A query that returns whether or not a sequence is always lockstep. | |
constexpr auto | is_debug_env = is_debug_env_ns::Function {} |
Returns whether the given environment is a debug environment. | |
constexpr auto | with = make_env_ns::WithFunction {} |
Specify an override for an environment query. | |
constexpr auto | without = make_env_ns::WithoutFunction {} |
Specify a removal of an environment query override. | |
constexpr auto | make_env = make_env_ns::Function {} |
Create an environment with overrides for queries. | |
template<typename R> | |
constexpr bool | enable_receiver = requires { typename R::is_receiver; } |
constexpr auto | set_error = SetError {} |
constexpr auto | set_stopped = SetStopped {} |
constexpr auto | set_value = SetValue {} |
constexpr auto | request_stop = request_stop_ns::Function {} |
Request that a scope stop. | |
constexpr auto | nest = nest_ns::Function {} |
Nest a sender inside a scope. | |
constexpr auto | spawn = spawn_ns::Function {} |
Spawn a sender inside a scope. | |
constexpr auto | spawn_future = spawn_future_ns::Function {} |
Spawn a sender inside a scope, and return a future to the result. | |
constexpr auto | next = next_ns::Function {} |
Get the next value of a async range in a coroutine. | |
constexpr auto | empty_sequence = empty_sequence_ns::Function {} |
A sequence sender that completes immediately without ever sending a value. | |
constexpr auto | filter = function::curry_back(filter_ns::Function {}, meta::c_<2ZU>) |
Filter the values of a sequence. | |
constexpr auto | first_value = first_value_ns::Function {} |
Transform a sequence into a sender of its first value. | |
constexpr auto | valid_lifetime = from_container_ns::ValidLifetimeTag {} |
Tag type to indicate that the container lifetime is valid for the async sequence. | |
constexpr auto | from_container = from_container_ns::Function {} |
Creates a sequence sender from a container. | |
constexpr auto | ignore_all = ignore_all_ns::Function {} |
Adapt a sequence sender to a regular sender of void, ignoring the sequence's values. | |
constexpr auto | into_lockstep_sequence = into_lockstep_sequence_ns::Function {} |
Converts a sequence into a lockstep sequence. | |
constexpr auto | into_variant_each = into_variant_each_ns::Function {} |
Transform the values of a sequence into a variant. | |
constexpr auto | let_value_each = function::curry_back(let_each_ns::ValueFunction {}, meta::c_<2ZU>) |
Transform the values of a sequence into new senders. | |
constexpr auto | let_error_each = function::curry_back(let_each_ns::ErrorFunction {}, meta::c_<2ZU>) |
Transform the errors of a sequence into new senders. | |
constexpr auto | let_stopped_each = function::curry_back(let_each_ns::StoppedFunction {}, meta::c_<2ZU>) |
Transform the stopped signal of a sequence into new senders. | |
constexpr auto | repeat = repeat_ns::Function {} |
Transform a copyable sender into an infinite sequence sender. | |
constexpr auto | set_next = set_next_ns::Function {} |
Set the next sender of a sequence. | |
template<typename S> | |
constexpr bool | enable_sequence_sender = false |
template<typename S> requires (concepts::AwaitableAsyncRange<S>) | |
constexpr bool | enable_sequence_sender< S > = true |
constexpr auto | subscribe = subscribe_ns::Function {} |
Subscribe a receiver to a sequence. | |
constexpr auto | then_each = function::curry_back(then_each_ns::Function {}, meta::c_<2ZU>) |
Transform the values of a sequence directly. | |
constexpr auto | upon_error_each = function::curry_back(then_each_ns::ErrorFunction {}, meta::c_<2ZU>) |
Transform the errors of a sequence directly. | |
constexpr auto | upon_stopped_each = function::curry_back(then_each_ns::StoppedFunction {}, meta::c_<2ZU>) |
Transform stopped values of a sequence directly. | |
constexpr auto | transform_each = function::curry_back(transform_each_ns::Function {}, meta::c_<2ZU>) |
Transform each sender of a sequence. | |
constexpr auto | zip = zip_ns::Function {} |
Zip multiple sequences together. | |
constexpr auto | zip_with_variant = zip_ns::VariantFunction {} |
Zip multiple sequences together, allowing them to send different types of values. | |
using di::execution::AnyOperationState = Any<InterfaceWithEnv<meta::List<types::Tag<execution::start>>, Env>, Storage, VTablePolicy> |
using di::execution::AnyReceiver = meta::Type<AnyReceiverT<Sigs, Env, Storage, VTablePolicy>> |
using di::execution::AnySender = meta::Type<AnySenderT<Sigs, Env, Storage, VTablePolicy, Op, Rec>> |
using di::execution::AnySenderOf = meta::Type<AnySenderOfT<T>> |
using di::execution::AsyncGenerator = meta::Type<async_generator_ns::AsyncGeneratorT<Ref, Value>> |
using di::execution::CountingScope = meta::Type<counting_scope_ns::CountingScopeT<Alloc>> |
A scope that waits for all spawned senders to complete.
Alloc | The allocator to use for the scope. |
CountingScope is a scope that waits for all spawned senders to complete, using the async resource mechanism. This means that it can only be accessed using the execution::use_resources function. The provided token allows spawning work, and the async "destructor" will wait for all spawned work to complete.
This limited API allows the scope to be implemented efficently, with only an atomic counter. This is possible only because the resource API guarantees that we will wait for all spawned work exactly once. More advanced use cases may need to wait multiple times, or store the scope in non-async storage, and would need to use a different scope implementation.
using di::execution::InterfaceWithEnv |
using di::execution::MakeEnv = decltype(make_env(util::declval<BaseEnv>(), util::declval<Withs>()...)) |
Represent an environment with overrides for queries.
BaseEnv | The base environment to use for forwarding queries that are not overridden. |
Withs | The overrides to use for queries. |
This template is used to deduce the return type of the execution::make_env
function. This is used by sender algorithms which customize the environment to properly query a sender's completion signatures, which vary based on the environment they are invoked in.
using di::execution::ReceiverAdaptor = meta::Type<receiver_interface_ns::ReceiverAdaptor<Self, Base>> |
using di::execution::Stopped = decltype(just_stopped()) |
using di::execution::With = make_env_ns::With<Tag, Val> |
Represent a override for an environment query.
Tag | The tag of the query to override. |
Val | The value to use for the override. |
This type is used as a parameter to execution::MakeEnv
template to specify an override for a query. This is useful to deduce the return type of the execution::make_env
function.
using di::execution::Without = make_env_ns::Without<Tag> |
Represent a removal of an environment query value.
Tag | The tag of the query to remove the override for. |
This type is used as a parameter to execution::MakeEnv
template to specify a removal of an existing environment value. This is useful to deduce the return type of the execution::make_env
function.
|
strong |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
Bulk apply a function to a range of values.
sender | The sender to send values from. |
shape | The number of values to send. |
function | The function to apply to each value. |
This function is similar to container::for_each except that it is applied for every index in the specified shape. The adapted sender will send the original values through unchanged, unless the function returns an error, in which case the returned sender will send the error to the receiver.
On schedulers which support parallel execution, the scheduler should customize execution::bulk, which enables the function to be applied in parallel.
The following example demonstrates how to sum over a vector of values in parallel, using a vector of intemediate results to avoid contention.
|
inlineconstexpr |
|
inlineconstexpr |
A sequence sender that completes immediately without ever sending a value.
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
Eagerly start a sender.
sender | The sender to start. |
allocator | The allocator to use for the shared state (optional). |
This function is used to eagerly start a sender, while still being able to retrieve its result later. It is implemented using a shared state, which is allocated using the provided allocator. If no allocator is provided, the default allocator is used.
If the returned sender is destroyed before it has been started, the eagerly started sender will be signalled by means of a stop token, possibly causing it to be cancelled. When the eagerly started sender completes, its values are decayed copied into the shared state, which is then used to complete the returned sender.
This function is an unstructured version of execution::spawn_future(), which is used to eagerly start a sender in a provided async scope. This ensures that the eagerly started sender completes before the async scope is destroyed.
|
inlineconstexpr |
Executes a function on a scheduler.
scheduler | The scheduler to execute the function on. |
function | The function which runs on the provided scheduler. |
allocator | The allocator used to allocate the operation state (optional). |
This function is like execution::start_detached() but does does not take a sender. Instead, it takes a function which is invoked by the provided scheduler, which ensures all work is executed on the scheduler.
|
inlineconstexpr |
Filter the values of a sequence.
sequence | The sequence. |
predicate | The function to filter the values of the sequence. |
|
inlineconstexpr |
Transform a sequence into a sender of its first value.
sequence | The sequence to transform. |
This function will return the first error or value of the sequence after it completes. Any errors or values after the first will be ignored. However, if the cleanup action of the sequence sends an error, that error will be sent in place of the first value. If the sequence itself is empty, the returned sender will complete with a stopped signal.
See the following for an example:
|
inlineconstexpr |
|
inlineconstexpr |
Creates a sequence sender from a container.
container | The container. |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
A query that returns the cardinality of a sequence.
env | The sequence's environment. |
di::Constexpr<usize>
instance.This query allows optimizing the execution of a sequence by having a static upper bound on the number of values it will send. This could be used to know how many values to pre-allocate for a sequence, or to verify that a sequence only sends a single value (for an async resource).
This property should be queried using the meta::SequenceCardinality
template, which will return the cardinality of a sequence, or 1 in the case of a regular sender.
di::Constexpr<usize>
instance, so if this property varies at run-time (like for a type-erased sequence), it should return math::NumericLimits<usize>::max
.
|
inlineconstexpr |
|
inlineconstexpr |
Adapt a sequence sender to a regular sender of void, ignoring the sequence's values.
sequence | The sequence sender to adapt. |
If the sequence sender sends an error, the first error encountered is decay copied and forwarded to the receiver once the sequence completes. If instead the first non-value completion sent is a stop, the receiver is sent a stop when the sequence completes. Otherwise, the sent values are discarded and the receiver is sent an empty completion when the sequence completes.
|
inlineconstexpr |
Converts a sequence into a lockstep sequence.
sequence | The sequence to convert. |
This function is a no-op for sequences that are already lockstep. For non-lockstep sequences, this function will return a lockstep sequence, hopefully by using an atomic instrusive queue of operation states, but this is not yet implemented.
This function is useful for sequence algorithms which require lockstep sequences, like execution::zip and execution::fold, or any algorithm which cannot process results in parallel (which includes consuming sequences in a coroutine).
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
Transform the values of a sequence into a variant.
sequence | The sequence to transform. |
This function is like execution::into_variant(), but for sequences.
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
A query that returns whether or not a sequence is always lockstep.
env | The sequence's environment. |
di::Constexpr<bool>
instance.This query allows optimizing the execution of a sequence by guaranteeing that it does not ever make concurrent calls to execution::set_next()
. In particular, another call to execution::set_next()
can only be made once the sender returned by the previous call to execution::set_next()
has completed.
This is true for sequences such as those that are created by execution::AsyncGenerator
or execution::from_container
. This is also true for most sequence algorithms which operate on lockstep sequences, and for algorithms which must transform input sequences to be lockstep (like execution::zip and execution::fold). Additionally, this is true for sequences which only send a single value, including regular senders. However, since this is used as an optimization, it defaults to false, since falsely returning true will most likely will result in undefined behavior.
This property should be queried using the concepts::AlwaysLockstepSequence
concept, which will return true if the sequence is a regular sender or a lockstep sequence. Additionally, any sequence with a cardinality less than or equal to 1 will automatically true.
di::Constexpr<bool>
instance, so if this property varies at run-time (like for a type-erased sequence), it must return false.
|
inlineconstexpr |
Returns whether the given environment is a debug environment.
env | The environment to query. |
This is a debug mechanism, which forces the execution::connect or execution::subscribe CPOs to call be valid even if no customization is valid. This is useful for seeing why a customization is not valid, since it will cause a compiler error when trying to call the CPO.
This mechanism is nice since it does not require manually editing the CPO to remove the constraints, which was the previous debugging mechanism.
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
Creates a sender from a function.
function | The function which is invoked to send a value. |
This function is like execution::just() but does does not take a value. Instead, it takes a function which is called when the operation is started. This is a shorthand for:
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
Transform the errors of a sequence into new senders.
sequence | The sequence to transform. |
transformer | The function to transform the errors, which returns a sender. |
This function allows mapping the errors of a sequence into values, which can be used to make the sequence complete successfully.
|
inlineconstexpr |
|
inlineconstexpr |
Transform the stopped signal of a sequence into new senders.
sequence | The sequence to transform. |
transformer | The function to transform the stopped signal, which returns a sender. |
This function allows mapping the stopped signal of a sequence into values, which can be used to make the sequence never stop.
|
inlineconstexpr |
|
inlineconstexpr |
Transform the values of a sequence into new senders.
sequence | The sequence to transform. |
transformer | The function to transform the values, which returns a sender. |
|
inlineconstexpr |
Inject values into an operation state.
function | The function to invoke with the injected values. |
factories | The factories to use to create the injected values. |
This function allows the injection of values into an operation state. These are given the the provided function as lvalues. And the function returns a sender which is allowed access to these values. This is particularly useful for creating immovable objects, which cannot be stored in a sender because senders must be movable.
The following example creates an injects a regular value, as well as an immovable value into the operation state. This demonstrates the function::make_deferred helper function, which binds arguments to a constructor, as well as the fact that normal lambdas can be used as a factory function.
|
inlineconstexpr |
Create an environment with overrides for queries.
base_env | The base environment to use for forwarding queries that are not overridden. |
overrides | The overrides to use for queries. |
This function creates an environment with the specified overrides. The overrides are specified as a list of objects returned from the execution::with
function. The overrides are required to be unique.
This function is also useful when creating an environment with no overrides, as it will only forward queries which have opted-in to be forwarded. This is useful when writng sender algorithms, which don't need to customize the environment but cannot pass the environment through directly to respect the forwarding-ness of the query.
See the execution::with_env() function for an example.
|
inlineconstexpr |
Nest a sender inside a scope.
scope | The scope to nest the sender inside. |
sender | The sender to nest. |
This is the most primitive way to nest a sender inside a scope. Nesting a sender inside of a scope means that the sender is required to complete before the scope is destroyed. This is useful in cases where we need to use a scope to manage the lifetime of a sender, as is the case any time the number of senders to be run is not known at compile time.
This function does not allocate any memory, and is therefore the most efficient way to nest a sender inside a scope, but is also the most inconvenient. In most cases, it is more desirable to use execution::spawn() or execution::spawn_future() instead. However, these functions can be implemented in terms of this function.
The following example demonstrates simple usage of execution::nest():
|
inlineconstexpr |
Get the next value of a async range in a coroutine.
async_range | The lvalue async range to get the next value from. |
This function is used in conjunction with co_await to consume an async sequence in a coroutine. For instance:
The key points are that the awaitable returned by execution::next() will return a vocab::Optional<T>, with the null value present once the sequence has been exhausted. This allows the sequence to be consumed in a while loop.
|
inlineconstexpr |
execution::on() takes a scheduler and sender, and returns a new sender whose which "runs" the provided sender on designated scheduler.
This is implemented by "connect"ing to the result of execution::schedule(), and only starting the provided sender when that completes. Additionally, execution::on() wraps any provided receivers with a new enviornment which adverties the scheduler for execution::get_scheduler().
|
inlineconstexpr |
|
inlineconstexpr |
Transform a copyable sender into an infinite sequence sender.
sender | The sender to repeat. |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
Request that a scope stop.
scope | The scope to request stop on. |
This is used to request that a scope stop. In most cases, this is done by forwarding the request to the scope's underlyign stop source. Since this is a CPO, this provides a uniform interface to this functionality.
|
inlineconstexpr |
Obtain access to an async resource.
resource | The resource to access. |
This function is an internal CPO which is used by async resources. This function is not intended to be called directly. Resources should instead be consumed by using the execution::use_resources function.
Custom async resources must override this function to provide access to the resource. The returned sequence must send exactly one value and should complete when this value is accepted. The sent value should be some sort of token is used to access the resource. After the value is accepted, cleanup of the resource should be started if needed. Sending the value or completing can send errors if it makes sense to do so.
See the Execution document for more information on the async resource model.
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
Set the next sender of a sequence.
receiver | The receiver of the sequence. |
sender | The sender to set as the next sender in the sequence. |
sender
to model di::concepts::NextSender.See the Execution document for more information on the async sequence model.
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
Spawn a sender inside a scope.
scope | The scope to spawn the sender inside. |
sender | The sender to spawn. |
This function is used to spawn a sender inside a scope. Spawning a sender inside a scope means that the sender is eagerly started, and the scope will not be destroyed until the sender completes. This is useful in cases where we need to run a dynamic amount of work, and make sure not to leak resources.
This function allocates the operation to be run on the heap, and is therefore less efficient than using execution::nest(). However, it is more convenient, since it eagerly starts the sender, and still manages the memory properly. However, for this reason, if the underlying allocator is fallible, this function can return an error.
In cases where the result of the sender is needed, execution::spawn_future() should be used instead.
The following example uses execution::spawn() to start 10 tasks in parallel, and then waits for them to complete:
|
inlineconstexpr |
Spawn a sender inside a scope, and return a future to the result.
scope | The scope to spawn the sender inside. |
sender | The sender to spawn. |
This function is used to spawn a sender inside a scope, and return a future to the result. Spawning a sender means it is eagerly started, and the scope will not be destroyed until the sender completes. This differs from execution::nest(), which does not eagerly start the sender.
This function is useful in cases where the result of the sender is needed. However, it is less efficient than both execution::nest() and execution::spawn(), since it allocates the operation to be run on the heap, and must resolve the race condition between the eagerly started sender completing, and the returned future being started.
The following example uses execution::spawn_future() to start 4 tasks in parallel, and sums the results:
|
inlineconstexpr |
Split a sender into a sender which sends the same value to multiple receivers.
sender | The sender to split. |
allocator | The allocator to use for the shared state (optional). |
This function enables a sender to be split into multiple receivers. The returned sender will send the same value to all receivers. This requires an atomic queue of waiting receivers, which is stored in a heap-allocated shared state. The underlying sender is only started when the first operation is started.
|
inlineconstexpr |
|
inlineconstexpr |
Start a sender without waiting for it to complete.
sender | The sender to start. |
allocator | The allocator to use for the operation state (optional). |
This function is used to start a sender in a fire-and-forget manner. The operation state is heap allocated using the provided allocator. If no allocator is provided, the default allocator is used. If allocation is failible, this function will return an error.
This function is like execution::spawn() but does not require a scope to be provided. This means that the sender may remain pending for an arbitrary amount of time, and the operation state will not be destroyed until the sender completes. As such, this function should be used with care, since it can easily lead to unpredictable resource usage.
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
Subscribe a receiver to a sequence.
sequence | The sequence to subscribe to. |
receiver | The receiver to subscribe. |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
A sender that maps values into another value.
sender | The sender to map. |
function | The function to map the value with. |
This function synchronously maps values into another value. Additionally, the function can return an di::Expected, which will be mapped into a value or an error.
If the transformation function wants to be asynchronous, use execution::let_value() instead, which allows the function to return a sender.
The following examples show how to use this function:
|
inlineconstexpr |
Transform the values of a sequence directly.
sequence | The sequence to transform. |
transformer | The function to transform the values. |
This function is the equivalent of view::transform(), but for sequences. However, the transformer is allowed to return a vocab::Result<T> instead of a T, which will propogate the error out of the sequence.
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
Transform each sender of a sequence.
sequence | The sequence. |
transformer | The function to transform each sender of the sequence. |
|
inlineconstexpr |
A sender that maps an error into a value.
sender | The sender to map. |
function | The function to map the error with. |
This function is like execution::then(), but instead of mapping values into another value, it maps an error into a value. Additionally, the function can return an di::Expected, which will be mapped into a value or an error.
|
inlineconstexpr |
Transform the errors of a sequence directly.
sequence | The sequence to transform. |
transformer | The function to transform the errors. |
This function is execution::then_each(), but maps errors instead of values. The transformer is allowed to return a vocab::Result<T> instead of a T, which will propogate the error out of the sequence.
|
inlineconstexpr |
A sender that maps the stop signal into a value.
sender | The sender to map. |
function | The function to map the stop signal with. |
This function is like execution::then(), but instead of mapping values into another value, it maps the stop signal into a value. Additionally, the function can return an di::Expected, which will be mapped into a value or an error.
|
inlineconstexpr |
Transform stopped values of a sequence directly.
sequence | The sequence to transform. |
transformer | The function to transform the stopped values. |
This function is execution::then_each(), but runs when the sequence sends stopped instead of values. The transformer is allowed to return a vocab::Result<T> instead of a T, which will propogate the error out of the sequence.
|
inlineconstexpr |
Use async resources.
function | The function which accepts the resources. |
deferred | Possibly multiple factories which return async resources. |
This function allows consuming multiple async resources in parallel. If any resource fails to be acquired, the returned sender sends an error. Likewise, if any cleanup fails, the returned sender sends an error. The provided function is only invoked if all resources are successfully acquired. The values sent by the function are forwarded to the returned sender.
The values passed to the function are the async resource tokens. These are regular types which internally have reference semantics. They refer to the actual resouce objects, which are stored in an internal operation state. This function is the recommended way to consume async resources, since it guarantees that the resources are acquired and released, and even does so in parallel.
See the following usage example:
|
inlineconstexpr |
Tag type to indicate that the container lifetime is valid for the async sequence.
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
Specify an override for an environment query.
tag | The tag of the query to override. |
value | The value to use for the override. |
execution::make_env
functionThis function is used as a parameter to execution::make_env
function to specify an override for a query. The query values are required to be copy constructible, they are decay copied into the environment, and they are copied out when the environment is queried.
See the execution::with_env() function for an example.
|
inlineconstexpr |
Adapts a sender to run with a debug environment.
sender | The sender to adapt. |
This function is equivalent to calling with_env() with a debug environment.
|
inlineconstexpr |
Adapts a sender to run with a specified environment.
env | The environment to run the sender with. |
sender | The sender to adapt. |
This functions allows injecting an environment into a sender. The environment is accessible within the sender using execution::read(), and allows the sender to dynamically get things like a stop token, allocator, or current scheduler.
The following is an example of a sender that uses its injected stop token to know if it should stop itself:
|
inlineconstexpr |
Specify a removal of an environment query override.
tag | The tag of the query to remove the override for. |
execution::make_env
functionThis function is used as a parameter to execution::make_env
function to specify a removal an existing environment value. This is useful when forwarding an environment, but removing a value that is not valid in the new environment.
See the execution::with_env() function for an example.
|
inlineconstexpr |
Zip multiple sequences together.
sequences | The sequences to zip together. |
This function is like view::zip() for ranges, but for sequences. Like when_all(), the senders are required to only send a single type of values. If you need to send multiple types of values, use zip_with_variant().
This function is used to combine multiple sequences together into a single sequence. For example:
The sequences passed to this function will first be converted to lockstep sequences using into_lockstep_sequence(). As a result, the sequence returned by this function will be a lockstep sequence.
|
inlineconstexpr |
Zip multiple sequences together, allowing them to send different types of values.
sequences | The sequences to zip together. |
This function is like view::zip() for ranges, but for sequences. Unlike zip(), the senders are allowed to send different types of values. The values will be sent as a variant.