Loading [MathJax]/extensions/tex2jax.js
Iros
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages Concepts
Loading...
Searching...
No Matches
di::execution Namespace Reference

Namespaces

namespace  as_awaitable_ns
 
namespace  async_generator_ns
 
namespace  async_net_ns
 
namespace  async_open_ns
 
namespace  async_read_exactly_ns
 
namespace  async_read_some_ns
 
namespace  async_write_exactly_ns
 
namespace  async_write_some_ns
 
namespace  bulk_ns
 
namespace  connect_awaitable_ns
 
namespace  counting_scope_ns
 
namespace  detail
 
namespace  dummy_ns
 
namespace  empty_sequence_ns
 
namespace  ensure_started_ns
 
namespace  execute_ns
 
namespace  filter_ns
 
namespace  first_value_ns
 
namespace  from_container_ns
 
namespace  get_sequence_cardinality_ns
 
namespace  ignore_all_ns
 
namespace  into_lockstep_sequence_ns
 
namespace  into_result_ns
 
namespace  into_variant_each_ns
 
namespace  into_variant_ns
 
namespace  ipc
 
namespace  ipc_binary_ns
 
namespace  is_always_lockstop_sequence_ns
 
namespace  is_debug_env_ns
 
namespace  just_from_ns
 
namespace  just_ns
 
namespace  just_or_error_ns
 
namespace  just_void_or_stopped_ns
 
namespace  lazy_ns
 
namespace  let_each_ns
 
namespace  let_ns
 
namespace  let_value_with_ns
 
namespace  make_env_ns
 
namespace  nest_ns
 
namespace  next_ns
 
namespace  on_ns
 
namespace  read_ns
 
namespace  receiver_interface_ns
 
namespace  repeat_effect_ns
 
namespace  repeat_effect_until_ns
 
namespace  repeat_ns
 
namespace  request_stop_ns
 
namespace  run_ns
 
namespace  schedule_from_ns
 
namespace  send_ns
 
namespace  sender_to_sequence_adaptor_ns
 
namespace  set_next_ns
 
namespace  spawn_future_ns
 
namespace  spawn_ns
 
namespace  split_ns
 
namespace  start_detached_ns
 
namespace  stopped_as_error_ns
 
namespace  stopped_as_optional_ns
 
namespace  subscribe_ns
 
namespace  sync_wait_ns
 
namespace  then_each_ns
 
namespace  then_ns
 
namespace  transfer_just_ns
 
namespace  transfer_ns
 
namespace  transform_each_ns
 
namespace  use_resources_ns
 
namespace  when_all_ns
 
namespace  with_env_ns
 
namespace  zip_ns
 

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.
 

Typedef Documentation

◆ AnyOperationState

template<typename Env = void, concepts::AnyStorage Storage = any::HybridStorage<any::StorageCategory::MoveOnly, 8 * sizeof(void*), alignof(void*)>, typename VTablePolicy = any::MaybeInlineVTable<3>>
using di::execution::AnyOperationState = Any<InterfaceWithEnv<meta::List<types::Tag<execution::start>>, Env>, Storage, VTablePolicy>

◆ AnyReceiver

template<concepts::ValidCompletionSignatures Sigs, typename Env = void, concepts::AnyStorage Storage = any::InlineStorage<2 * sizeof(void*), alignof(void*)>, typename VTablePolicy = any::MaybeInlineVTable<3>>
using di::execution::AnyReceiver = meta::Type<AnyReceiverT<Sigs, Env, Storage, VTablePolicy>>

◆ AnySender

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 di::execution::AnySender = meta::Type<AnySenderT<Sigs, Env, Storage, VTablePolicy, Op, Rec>>

◆ AnySenderOf

template<typename T = void>
using di::execution::AnySenderOf = meta::Type<AnySenderOfT<T>>

◆ AsyncGenerator

template<typename Ref, typename Value = void>
using di::execution::AsyncGenerator = meta::Type<async_generator_ns::AsyncGeneratorT<Ref, Value>>

◆ CountingScope

template<concepts::Allocator Alloc = platform::DefaultAllocator>
using di::execution::CountingScope = meta::Type<counting_scope_ns::CountingScopeT<Alloc>>

A scope that waits for all spawned senders to complete.

Template Parameters
AllocThe 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.

See also
use_resources
nest
spawn
spawn_future
request_stop

◆ InterfaceWithEnv

template<concepts::Interface Interface, typename Env>
using di::execution::InterfaceWithEnv
Initial value:
Definition core.h:128
detail::ConditionalHelper< value, T, U >::Type Conditional
Definition core.h:88
meta::Unique< meta::Concat< meta::Transform< Interfaces, meta::Quote< meta::Type > >... > > MergeInterfaces
Definition merge_interfaces.h:8
Definition core.h:5
Definition this.h:4

◆ MakeEnv

template<typename BaseEnv, typename... Withs>
using di::execution::MakeEnv = decltype(make_env(util::declval<BaseEnv>(), util::declval<Withs>()...))

Represent an environment with overrides for queries.

Template Parameters
BaseEnvThe base environment to use for forwarding queries that are not overridden.
WithsThe 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.

See also
make_env
with
With

◆ ReceiverAdaptor

template<concepts::ClassType Self, concepts::Receiver Base = receiver_interface_ns::fake_receiver::FakeReceiver>
using di::execution::ReceiverAdaptor = meta::Type<receiver_interface_ns::ReceiverAdaptor<Self, Base>>

◆ Stopped

using di::execution::Stopped = decltype(just_stopped())

◆ With

template<typename Tag, typename Val>
using di::execution::With = make_env_ns::With<Tag, Val>

Represent a override for an environment query.

Template Parameters
TagThe tag of the query to override.
ValThe 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.

See also
make_env
with
MakeEnv

◆ Without

template<typename Tag>
using di::execution::Without = make_env_ns::Without<Tag>

Represent a removal of an environment query value.

Template Parameters
TagThe 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.

See also
make_env
with
MakeEnv

Enumeration Type Documentation

◆ ForwardProgressGuarantee

Enumerator
Concurrent 
Parallel 
WeaklyParallel 

Variable Documentation

◆ as_awaitable

as_awaitable_ns::Function const di::execution::as_awaitable = {}
inlineconstexpr

◆ async_accept

auto di::execution::async_accept = async_net_ns::AsyncAccept {}
inlineconstexpr

◆ async_bind

auto di::execution::async_bind = async_net_ns::AsyncBind {}
inlineconstexpr

◆ async_connect

auto di::execution::async_connect = async_net_ns::AsyncConnect {}
inlineconstexpr

◆ async_listen

auto di::execution::async_listen = async_net_ns::AsyncListen {}
inlineconstexpr

◆ async_make_socket

auto di::execution::async_make_socket = async_net_ns::AsyncMakeSocket {}
inlineconstexpr

◆ async_open

auto di::execution::async_open = async_open_ns::Function {}
inlineconstexpr

◆ async_read_exactly

auto di::execution::async_read_exactly = async_read_exactly_ns::Function {}
inlineconstexpr

◆ async_read_some

auto di::execution::async_read_some = async_read_some_ns::Function {}
inlineconstexpr

◆ async_shutdown

auto di::execution::async_shutdown = async_net_ns::AsyncShutdown {}
inlineconstexpr

◆ async_write_exactly

auto di::execution::async_write_exactly = async_write_exactly_ns::Function {}
inlineconstexpr

◆ async_write_some

auto di::execution::async_write_some = async_write_some_ns::Function {}
inlineconstexpr

◆ bulk

auto di::execution::bulk = function::curry_back(bulk_ns::Function {}, c_<3ZU>)
inlineconstexpr

Bulk apply a function to a range of values.

Parameters
senderThe sender to send values from.
shapeThe number of values to send.
functionThe function to apply to each value.
Returns
A sender that applies the function to each value and sends the original values through unchanged.

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.

namespace execution = di::execution;
// NOTE: this could be a thread-pool scheduler instead.
auto scheduler = execution::InlineScheduler {};
constexpr usize count = 1000;
constexpr usize tile_count = 10;
struct CachelinePadded {
alignas(128) usize value;
};
auto numbers = di::range(count) | di::to<di::Vector>();
auto partials = di::repeat(CachelinePadded(0)) | di::take(tile_count) | di::to<di::Vector>();
auto work = execution::transfer_just(scheduler, di::move(numbers), di::move(partials)) |
execution::bulk(tile_count,
[](usize i, di::Vector<usize>& numbers, di::Vector<CachelinePadded>& partials) {
auto start = i * (numbers.size() / tile_count);
auto end = di::min((i + 1) * (numbers.size() / tile_count), numbers.size());
partials[i].value = di::sum(numbers | di::drop(start) | di::take(end - start));
}) |
execution::then([](di::Vector<usize>, di::Vector<CachelinePadded> partials) {
return di::sum(partials | di::transform(&CachelinePadded::value));
});
ASSERT_EQ(execution::sync_wait(di::move(work)), count * (count - 1) / 2);
Warning
The function must be thread-safe, if invoked on a parallel scheduler.

◆ connect

auto di::execution::connect = detail::ConnectFunction {}
inlineconstexpr

◆ empty_sequence

auto di::execution::empty_sequence = empty_sequence_ns::Function {}
inlineconstexpr

A sequence sender that completes immediately without ever sending a value.

◆ enable_receiver

template<typename R>
bool di::execution::enable_receiver = requires { typename R::is_receiver; }
inlineconstexpr

◆ enable_sender

template<typename S>
bool di::execution::enable_sender = requires { typename S::is_sender; }
inlineconstexpr

◆ enable_sender< S >

template<concepts::IsAwaitable< EnvPromise< types::EmptyEnv > > S>
bool di::execution::enable_sender< S > = true
inlineconstexpr

◆ enable_sequence_sender

template<typename S>
bool di::execution::enable_sequence_sender = false
inlineconstexpr

◆ enable_sequence_sender< S >

template<typename S>
requires (concepts::AwaitableAsyncRange<S>)
bool di::execution::enable_sequence_sender< S > = true
inlineconstexpr

◆ ensure_started

auto di::execution::ensure_started = ensure_started_ns::Function {}
inlineconstexpr

Eagerly start a sender.

Parameters
senderThe sender to start.
allocatorThe allocator to use for the shared state (optional).
Returns
A sender that represents the original sender, but with the guarantee that it has started.

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.

See also
spawn_future

◆ execute

auto di::execution::execute = execute_ns::Function {}
inlineconstexpr

Executes a function on a scheduler.

Parameters
schedulerThe scheduler to execute the function on.
functionThe function which runs on the provided scheduler.
allocatorThe allocator used to allocate the operation state (optional).
Returns
Possibly an error indicating the operaiton state could not be allocated.

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.

See also
start_detached
then
schedule

◆ filter

auto di::execution::filter = function::curry_back(filter_ns::Function {}, meta::c_<2ZU>)
inlineconstexpr

Filter the values of a sequence.

Parameters
sequenceThe sequence.
predicateThe function to filter the values of the sequence.
Returns
The filtered sequence.
Note
The predicate function must be lvalue callable for each set of values produced by the sequence, and return a sender which yields a bool. If the sequence item is an error, the predicate function is not called. If the predicate function returns an error, that error is propagated as the result of the sequence.
Warning
If the underlying sequence is not always lock-step, the predicate function must be thread-safe. If using a non-thread-safe predicate function, first call execution::into_lockstep_sequence() on the sequence.

◆ first_value

auto di::execution::first_value = first_value_ns::Function {}
inlineconstexpr

Transform a sequence into a sender of its first value.

Parameters
sequenceThe sequence to transform.
Returns
A sender of the first value of the sequence.

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:

namespace execution = di::execution;
// first_value() returns the first value of a sequence.
auto sequence = execution::from_container(execution::valid_lifetime, di::range(1, 5)) | execution::first_value;
ASSERT_EQ(execution::sync_wait(sequence), 1);
// first_value() propogates stops if no items are emitted.
auto empty = execution::empty_sequence() | execution::first_value;
ASSERT_EQ(execution::sync_wait(empty), di::Unexpected(di::BasicError::OperationCanceled));

◆ forwarding_query

auto di::execution::forwarding_query = ForwardingQuery {}
inlineconstexpr

◆ from_container

auto di::execution::from_container = from_container_ns::Function {}
inlineconstexpr

Creates a sequence sender from a container.

Parameters
containerThe container.
Returns
A sequence sender which emits all values from the container.
Note
The container is decay copied into sequence. When using a view instead, pass the execution::valid_lifetime tag as the first argument, which allows the caller to assert that the view references data which will be valid for the lifetime of the sequence. This should only be used for data with static lifetime (e.g. string literals), or when referencing data which is stored in an operation state, when using a algorithm like let_value().
If the receiver's stop token is not an unstoppable token, the sequence will stop sending values if a stop is requested.

◆ get_allocator

auto di::execution::get_allocator = detail::GetAllocatorFunction {}
inlineconstexpr

◆ get_completion_scheduler

template<concepts::OneOf< SetValue, SetError, SetStopped > CPO>
auto di::execution::get_completion_scheduler = GetCompletionScheduler<CPO> {}
inlineconstexpr

◆ get_completion_signatures

auto di::execution::get_completion_signatures = detail::GetCompletionSignaturesFunction {}
inlineconstexpr

◆ get_delegatee_scheduler

auto di::execution::get_delegatee_scheduler = detail::GetDelegateeSchedulerFunction {}
inlineconstexpr

◆ get_env

auto di::execution::get_env = detail::GetEnvFunction {}
inlineconstexpr

◆ get_forward_progress_guarantee

auto di::execution::get_forward_progress_guarantee = detail::GetForwardProgressGuaranteeFunction {}
inlineconstexpr

◆ get_scheduler

auto di::execution::get_scheduler = detail::GetSchedulerFunction {}
inlineconstexpr

◆ get_sequence_cardinality

auto di::execution::get_sequence_cardinality = get_sequence_cardinality_ns::Function {}
inlineconstexpr

A query that returns the cardinality of a sequence.

Parameters
envThe sequence's environment.
Returns
A 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.

Note
This query must return a 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.
See also
meta::SequenceCardinality

◆ get_stop_token

auto di::execution::get_stop_token = detail::GetStopTokenFunction {}
inlineconstexpr

◆ ignore_all

auto di::execution::ignore_all = ignore_all_ns::Function {}
inlineconstexpr

Adapt a sequence sender to a regular sender of void, ignoring the sequence's values.

Parameters
sequenceThe sequence sender to adapt.
Returns
A sender which sends an empty completion when the sequence completes.

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.

Warning
Calling di::execution::ignore_all() with a sequence sender corresponding to an infinte sequence will result in a sender which never completes.

◆ into_lockstep_sequence

auto di::execution::into_lockstep_sequence = into_lockstep_sequence_ns::Function {}
inlineconstexpr

Converts a sequence into a lockstep sequence.

Parameters
sequenceThe sequence to convert.
Returns
A lockstep sequence.

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).

See also
execution::is_always_lockstep_sequence
concepts::AlwaysLockstepSequence

◆ into_result

auto di::execution::into_result = into_result_ns::Function {}
inlineconstexpr

◆ into_variant

auto di::execution::into_variant = into_variant_ns::Function {}
inlineconstexpr

◆ into_variant_each

auto di::execution::into_variant_each = into_variant_each_ns::Function {}
inlineconstexpr

Transform the values of a sequence into a variant.

Parameters
sequenceThe sequence to transform.
Returns
A sequence sender that can only send a single value.

This function is like execution::into_variant(), but for sequences.

See also
into_variant
transform_each

◆ into_variant_result

auto di::execution::into_variant_result = into_result_ns::VariantFunction {}
inlineconstexpr

◆ ipc_binary_connect_to_client

template<concepts::InstanceOf< Protocol > Proto>
auto di::execution::ipc_binary_connect_to_client = ipc_binary_ns::ConnectToClientFunction<Proto> {}
inlineconstexpr

◆ ipc_binary_connect_to_server

template<concepts::InstanceOf< Protocol > Proto>
auto di::execution::ipc_binary_connect_to_server = ipc_binary_ns::ConnectToServerFunction<Proto> {}
inlineconstexpr

◆ is_always_lockstep_sequence

auto di::execution::is_always_lockstep_sequence = is_always_lockstop_sequence_ns::Function {}
inlineconstexpr

A query that returns whether or not a sequence is always lockstep.

Parameters
envThe sequence's environment.
Returns
A 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.

Note
This query must return a di::Constexpr<bool> instance, so if this property varies at run-time (like for a type-erased sequence), it must return false.
See also
concepts::AlwaysLockstepSequence

◆ is_debug_env

auto di::execution::is_debug_env = is_debug_env_ns::Function {}
inlineconstexpr

Returns whether the given environment is a debug environment.

Parameters
envThe environment to query.
Returns
Whether the given environment is a debug environment.

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.

See also
connect
subscribe
with_debug_env

◆ just

auto di::execution::just = just_ns::Function {}
inlineconstexpr

◆ just_error

auto di::execution::just_error = just_ns::ErrorFunction {}
inlineconstexpr

◆ just_from

auto di::execution::just_from = just_from_ns::Function {}
inlineconstexpr

Creates a sender from a function.

Parameters
functionThe function which is invoked to send a value.
Returns
A sender which invokes the provided function 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:

constexpr auto then
A sender that maps values into another value.
Definition then.h:276
constexpr auto just
Definition just.h:86
Definition as_bool.h:8
See also
just
then

◆ just_or_error

auto di::execution::just_or_error = just_or_error_ns::Function {}
inlineconstexpr

◆ just_stopped

auto di::execution::just_stopped = just_ns::StoppedFunction {}
inlineconstexpr

◆ just_void_or_stopped

auto di::execution::just_void_or_stopped = just_void_or_stopped_ns::Function {}
inlineconstexpr

◆ let_error

auto di::execution::let_error = function::curry_back(let_ns::Function<SetError> {}, meta::c_<2ZU>)
inlineconstexpr

◆ let_error_each

auto di::execution::let_error_each = function::curry_back(let_each_ns::ErrorFunction {}, meta::c_<2ZU>)
inlineconstexpr

Transform the errors of a sequence into new senders.

Parameters
sequenceThe sequence to transform.
transformerThe function to transform the errors, which returns a sender.
Returns
A sequence sender that transforms the errors of the sequence into new senders.

This function allows mapping the errors of a sequence into values, which can be used to make the sequence complete successfully.

Note
Like execution::let_error, the transformer function is passed lvalues internally stored in the operation state. This means they are safe to capture by reference in the transformer function.
See also
let_error
transform_each

◆ let_stopped

auto di::execution::let_stopped = function::curry_back(let_ns::Function<SetStopped> {}, meta::c_<2ZU>)
inlineconstexpr

◆ let_stopped_each

auto di::execution::let_stopped_each = function::curry_back(let_each_ns::StoppedFunction {}, meta::c_<2ZU>)
inlineconstexpr

Transform the stopped signal of a sequence into new senders.

Parameters
sequenceThe sequence to transform.
transformerThe function to transform the stopped signal, which returns a sender.
Returns
A sequence sender that transforms the stopped signal of the sequence into new senders.

This function allows mapping the stopped signal of a sequence into values, which can be used to make the sequence never stop.

See also
let_stopped
transform_each

◆ let_value

auto di::execution::let_value = function::curry_back(let_ns::Function<SetValue> {}, meta::c_<2ZU>)
inlineconstexpr

◆ let_value_each

auto di::execution::let_value_each = function::curry_back(let_each_ns::ValueFunction {}, meta::c_<2ZU>)
inlineconstexpr

Transform the values of a sequence into new senders.

Parameters
sequenceThe sequence to transform.
transformerThe function to transform the values, which returns a sender.
Returns
A sequence sender that transforms the values of the sequence into new senders.
Note
Like execution::let_value, the transformer function is passed lvalues internally stored in the operation state. This means they are safe to capture by reference in the transformer function.
See also
let_value
transform_each

◆ let_value_with

auto di::execution::let_value_with = let_value_with_ns::Function {}
inlineconstexpr

Inject values into an operation state.

Parameters
functionThe function to invoke with the injected values.
factoriesThe factories to use to create the injected values.
Returns
A sender that injects the values into the operation state and invokes the function.

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.

namespace execution = di::execution;
struct Y : di::Immovable {
explicit Y(int value) : y(value) {}
int y;
};
auto a = execution::let_value_with(
[](int& x, Y& y) {
return execution::just(x + y.y);
},
[] {
return 10;
},
ASSERT_EQ(execution::sync_wait(di::move(a)), 42);
See also
function::make_deferred

◆ make_env

auto di::execution::make_env = make_env_ns::Function {}
inlineconstexpr

Create an environment with overrides for queries.

Parameters
base_envThe base environment to use for forwarding queries that are not overridden.
overridesThe overrides to use for queries.
Returns
An environment with the specified overrides.

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.

See also
with
with_env

◆ nest

auto di::execution::nest = nest_ns::Function {}
inlineconstexpr

Nest a sender inside a scope.

Parameters
scopeThe scope to nest the sender inside.
senderThe sender to nest.
Returns
A sender that will run the sender inside the scope.

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():

auto nest_sender = execution::use_resources(
[](auto scope) {
return execution::when_all(execution::nest(scope, execution::just(11)),
execution::nest(scope, execution::just(22)),
execution::nest(scope, execution::just(33)));
},
ASSERT_EQ(execution::sync_wait(nest_sender), di::make_tuple(11, 22, 33));
See also
spawn
spawn_future

◆ next

auto di::execution::next = next_ns::Function {}
inlineconstexpr

Get the next value of a async range in a coroutine.

Parameters
async_rangeThe lvalue async range to get the next value from.
Returns
An awaitable which will return the next value of the sequence.

This function is used in conjunction with co_await to consume an async sequence in a coroutine. For instance:

namespace ex = di::execution;
co_yield 1;
co_yield 2;
co_yield 3;
co_return {};
}
auto f() -> di::Lazy<> {
auto sequence = co_await g();
while (di::concepts::Optional auto next = co_await ex::next(sequence)) {
dius::println("{}"_sv, *next);
}
}
Definition lazy.h:120
Definition vocab.h:77
Definition bulk.h:30
meta::Type< async_generator_ns::AsyncGeneratorT< Ref, Value > > AsyncGenerator
Definition async_generator.h:223
constexpr auto next
Get the next value of a async range in a coroutine.
Definition async_range.h:52
constexpr auto sequence
Definition sequence.h:34
constexpr auto println
Definition print.h:34

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.

◆ on

auto di::execution::on = on_ns::Function {}
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().

◆ read

auto di::execution::read = read_ns::Function {}
inlineconstexpr

◆ repeat

auto di::execution::repeat = repeat_ns::Function {}
inlineconstexpr

Transform a copyable sender into an infinite sequence sender.

Parameters
senderThe sender to repeat.
Returns
A sequence sender that will repeat the input sender infinitely.

◆ repeat_effect

auto di::execution::repeat_effect = repeat_effect_ns::Function {}
inlineconstexpr

◆ repeat_effect_until

auto di::execution::repeat_effect_until = function::curry_back(repeat_effect_until_ns::Function {}, meta::c_<2ZU>)
inlineconstexpr

◆ request_stop

auto di::execution::request_stop = request_stop_ns::Function {}
inlineconstexpr

Request that a scope stop.

Parameters
scopeThe scope to request stop on.
Returns
true if the scope was stopped, false if it was already.

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.

◆ run

auto di::execution::run = run_ns::Function {}
inlineconstexpr

Obtain access to an async resource.

Parameters
resourceThe resource to access.
Returns
A sequence sender that can be used to access the resource.

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.

See also
use_resources

◆ schedule

auto di::execution::schedule = detail::ScheduleFunction {}
inlineconstexpr

◆ schedule_from

auto di::execution::schedule_from = schedule_from_ns::Function {}
inlineconstexpr

◆ send

auto di::execution::send = send_ns::Function {}
inlineconstexpr

◆ set_error

auto di::execution::set_error = SetError {}
inlineconstexpr

◆ set_next

auto di::execution::set_next = set_next_ns::Function {}
inlineconstexpr

Set the next sender of a sequence.

Parameters
receiverThe receiver of the sequence.
senderThe sender to set as the next sender in the sequence.
Returns
A sender which will adapt the values sent by sender to model di::concepts::NextSender.

See the Execution document for more information on the async sequence model.

◆ set_stopped

auto di::execution::set_stopped = SetStopped {}
inlineconstexpr

◆ set_value

auto di::execution::set_value = SetValue {}
inlineconstexpr

◆ spawn

auto di::execution::spawn = spawn_ns::Function {}
inlineconstexpr

Spawn a sender inside a scope.

Parameters
scopeThe scope to spawn the sender inside.
senderThe sender to spawn.
Returns
void if the sender was spawned successfully, otherwise an error.

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:

auto count = 0;
auto spawn_sender = execution::use_resources(
[&](auto scope) {
di::for_each(di::range(10), [&](auto) {
execution::spawn(scope, execution::just_from([&count] {
++count;
}));
});
return execution::just();
},
ASSERT(execution::sync_wait(spawn_sender));
ASSERT_EQ(count, 10);
Note
The sender must not send any values or complete with an error (since the result is ignored). The only completion signatures allowed are di::SetValue() and di::SetStopped().
See also
nest
spawn_future

◆ spawn_future

auto di::execution::spawn_future = spawn_future_ns::Function {}
inlineconstexpr

Spawn a sender inside a scope, and return a future to the result.

Parameters
scopeThe scope to spawn the sender inside.
senderThe sender to spawn.
Returns
A sender to the result of the sender.

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:

auto spawn_future_sender = execution::use_resources(
[&](auto scope) {
return execution::get_scheduler() | execution::let_value([scope](auto scheduler) {
return execution::when_all(
execution::spawn_future(scope, execution::on(scheduler, execution::just(11))),
execution::spawn_future(scope, execution::on(scheduler, execution::just(22))),
execution::spawn_future(scope, execution::on(scheduler, execution::just(33)))) |
execution::then([](auto... values) {
return (values + ...);
});
});
},
ASSERT_EQ(execution::sync_wait(spawn_future_sender), 66);
See also
nest
spawn

◆ split

auto di::execution::split = function::curry_back(split_ns::Function {}, c_<2ZU>)
inlineconstexpr

Split a sender into a sender which sends the same value to multiple receivers.

Parameters
senderThe sender to split.
allocatorThe allocator to use for the shared state (optional).
Returns
A sender which sends the same value to multiple receivers, or an error if allocation failed.

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.

Note
The returned sender does not copy-out the values, but passes them by const reference.

◆ start

auto di::execution::start = detail::StartFunction {}
inlineconstexpr

◆ start_detached

auto di::execution::start_detached = start_detached_ns::Function {}
inlineconstexpr

Start a sender without waiting for it to complete.

Parameters
senderThe sender to start.
allocatorThe allocator to use for the operation state (optional).
Returns
Possibly an error indicating the operaiton state could not be allocated.

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.

Note
The sender must not send any values or complete with an error (since the result is ignored). The only completion signatures allowed are di::SetValue() and di::SetStopped().
See also
spawn

◆ stopped

auto di::execution::stopped = just_stopped()
inlineconstexpr

◆ stopped_as_error

auto di::execution::stopped_as_error = function::curry_back(stopped_as_error_ns::Function {}, meta::c_<2ZU>)
inlineconstexpr

◆ stopped_as_optional

auto di::execution::stopped_as_optional = stopped_as_optional_ns::Function {}
inlineconstexpr

◆ subscribe

auto di::execution::subscribe = subscribe_ns::Function {}
inlineconstexpr

Subscribe a receiver to a sequence.

Parameters
sequenceThe sequence to subscribe to.
receiverThe receiver to subscribe.
Returns
An operation state which models di::concepts::OperationState.

◆ sync_wait

auto di::execution::sync_wait = sync_wait_ns::Function {}
inlineconstexpr

◆ sync_wait_on

auto di::execution::sync_wait_on = function::curry(sync_wait_ns::OnFunction {}, meta::c_<2ZU>)
inlineconstexpr

◆ sync_wait_with_variant

auto di::execution::sync_wait_with_variant = sync_wait_ns::WithVariantFunction {}
inlineconstexpr

◆ sync_wait_with_variant_on

auto di::execution::sync_wait_with_variant_on
inlineconstexpr
Initial value:
=
constexpr auto curry
Definition curry.h:140
constexpr auto c_
A value of type Constexpr<val>.
Definition constexpr.h:252

◆ then

auto di::execution::then = function::curry_back(then_ns::ValueFunction {}, c_<2ZU>)
inlineconstexpr

A sender that maps values into another value.

Parameters
senderThe sender to map.
functionThe function to map the value with.
Returns
A sender that maps values into another value.

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:

namespace execution = di::execution;
di::Sender auto work = execution::just(42) | execution::then([](int x) {
return x * 2;
});
ASSERT_EQ(execution::sync_wait(work), 84);
auto failure = execution::just() | execution::then([] {
return di::Result<int>(di::Unexpected(di::BasicError::InvalidArgument));
});
ASSERT_EQ(execution::sync_wait(failure), di::Unexpected(di::BasicError::InvalidArgument));
See also
let_value

◆ then_each

auto di::execution::then_each = function::curry_back(then_each_ns::Function {}, meta::c_<2ZU>)
inlineconstexpr

Transform the values of a sequence directly.

Parameters
sequenceThe sequence to transform.
transformerThe function to transform the values.
Returns
A sequence sender that transforms the values of the sequence directly.

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.

Note
Like execution::then, the transformer function is passed values directly, so parameters should be taken by value.
See also
then
transform_each
view::transform

◆ transfer

auto di::execution::transfer = function::curry_back(transfer_ns::Function {}, meta::c_<2ZU>)
inlineconstexpr

◆ transfer_just

auto di::execution::transfer_just = transfer_just_ns::Function {}
inlineconstexpr

◆ transfer_when_all

auto di::execution::transfer_when_all = when_all_ns::TransferFunction {}
inlineconstexpr

◆ transfer_when_all_with_variant

auto di::execution::transfer_when_all_with_variant = when_all_ns::TransferVariantFunction {}
inlineconstexpr

◆ transform_each

auto di::execution::transform_each = function::curry_back(transform_each_ns::Function {}, meta::c_<2ZU>)
inlineconstexpr

Transform each sender of a sequence.

Parameters
sequenceThe sequence.
transformerThe function to transform each sender of the sequence.
Returns
The transformed sequence.
Note
The transformer function must be lvalue callable for each sender of the sequence, and return a sender. Additionally, the completion signatures of the return sender must only depend on the completion signatures of the input sender, as the determination of completion signatures is done without any knowledge of the exact type of the sequence's senders.
Warning
If the underlying sequence is not always lock-step, the transformer function must be thread-safe. If using a non-thread-safe transformer function, first call execution::into_lockstep_sequence() on the sequence.

◆ upon_error

auto di::execution::upon_error = function::curry_back(then_ns::ErrorFunction {}, c_<2ZU>)
inlineconstexpr

A sender that maps an error into a value.

Parameters
senderThe sender to map.
functionThe function to map the error with.
Returns
A sender that maps an error into a value.

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.

See also
then

◆ upon_error_each

auto di::execution::upon_error_each = function::curry_back(then_each_ns::ErrorFunction {}, meta::c_<2ZU>)
inlineconstexpr

Transform the errors of a sequence directly.

Parameters
sequenceThe sequence to transform.
transformerThe function to transform the errors.
Returns
A sequence sender that transforms the errors of the sequence directly.

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.

Note
Like execution::upon_error, the transformer function is passed errors directly, so parameters should be taken by value.
See also
upon_error
then_each
transform_each

◆ upon_stopped

auto di::execution::upon_stopped = function::curry_back(then_ns::StoppedFunction {}, c_<2ZU>)
inlineconstexpr

A sender that maps the stop signal into a value.

Parameters
senderThe sender to map.
functionThe function to map the stop signal with.
Returns
A sender that maps the stop signal into a value.

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.

See also
then

◆ upon_stopped_each

auto di::execution::upon_stopped_each = function::curry_back(then_each_ns::StoppedFunction {}, meta::c_<2ZU>)
inlineconstexpr

Transform stopped values of a sequence directly.

Parameters
sequenceThe sequence to transform.
transformerThe function to transform the stopped values.
Returns
A sequence sender that transforms the stopped values of the sequence directly.

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.

See also
upon_stopped
then_each
transform_each

◆ use_resources

auto di::execution::use_resources = use_resources_ns::Function {}
inlineconstexpr

Use async resources.

Parameters
functionThe function which accepts the resources.
deferredPossibly multiple factories which return async resources.
Returns
A sender which runs the sender returned from the function.

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:

See also
run

◆ valid_lifetime

auto di::execution::valid_lifetime = from_container_ns::ValidLifetimeTag {}
inlineconstexpr

Tag type to indicate that the container lifetime is valid for the async sequence.

See also
from_container

◆ when_all

auto di::execution::when_all = when_all_ns::Function {}
inlineconstexpr

◆ when_all_with_variant

auto di::execution::when_all_with_variant = when_all_ns::VariantFunction {}
inlineconstexpr

◆ with

auto di::execution::with = make_env_ns::WithFunction {}
inlineconstexpr

Specify an override for an environment query.

Parameters
tagThe tag of the query to override.
valueThe value to use for the override.
Returns
An override object that can be passed to the execution::make_env function

This 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.

See also
make_env
with_env

◆ with_debug_env

auto di::execution::with_debug_env = with_env_ns::DebugFunction {}
inlineconstexpr

Adapts a sender to run with a debug environment.

Parameters
senderThe sender to adapt.
Returns
A sender that runs the specified sender with a debug environment.

This function is equivalent to calling with_env() with a debug environment.

See also
with_env
is_debug_env

◆ with_env

auto di::execution::with_env = function::curry(with_env_ns::Function {}, c_<2ZU>)
inlineconstexpr

Adapts a sender to run with a specified environment.

Parameters
envThe environment to run the sender with.
senderThe sender to adapt.
Returns
A sender that runs the specified sender with the specified environment.

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:

namespace execution = di::execution;
auto stop_source = di::InPlaceStopSource {};
auto env =
execution::make_env(di::empty_env, execution::with(execution::get_stop_token, stop_source.get_stop_token()));
auto send = execution::read(execution::get_stop_token) | execution::let_value([](auto stop_token) {
return execution::just_void_or_stopped(stop_token.stop_requested());
});
// The sender will run to completion if stop is not .
ASSERT(execution::sync_wait(execution::with_env(env, send)));
// After requesting stop, the sender will return cancelled.
stop_source.request_stop();
ASSERT(!execution::sync_wait(execution::with_env(env, send)));
See also
with
make_env
read

◆ without

auto di::execution::without = make_env_ns::WithoutFunction {}
inlineconstexpr

Specify a removal of an environment query override.

Parameters
tagThe tag of the query to remove the override for.
Returns
An override object that can be passed to the execution::make_env function

This 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.

See also
make_env
with_env

◆ zip

auto di::execution::zip = zip_ns::Function {}
inlineconstexpr

Zip multiple sequences together.

Parameters
sequencesThe sequences to zip together.
Returns
A sequence sender that sends each value of each sequence 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:

namespace execution = di::execution;
// zip() works in normal conditions.
auto sequence = execution::zip(execution::from_container(di::Array { 1, 2, 3 }),
execution::from_container(di::Array { 4, 5, 6 }));
auto sum = 0;
ASSERT(execution::sync_wait(execution::ignore_all(sequence | execution::then_each([&](int x, int y) {
sum += x * y;
}))));
ASSERT_EQ(sum, 32);

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.

See also
zip_with_variant
view::zip

◆ zip_with_variant

auto di::execution::zip_with_variant = zip_ns::VariantFunction {}
inlineconstexpr

Zip multiple sequences together, allowing them to send different types of values.

Parameters
sequencesThe sequences to zip together.
Returns
A sequence sender that sends each value of each sequence 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.

See also
zip
view::zip
into_variant_each