Execution control library (since C++26)
From cppreference.com
< cpp
The Execution control library provides a framework for managing asynchronous execution on generic execution resources.
The library aims to provide vocabulary types for asynchronous operations and to allow the construction of task execution graphs in a simple, composable way.
Contents |
[edit] Library-wide definitions
- Sender: A description of asynchronous work to be sent for execution. Produces an operation state (below).
- Senders asynchronously “send” their results to listeners called “receivers” (below).
- Senders can be composed into task graphs using generic algorithms.
- Sender factories and adaptors are generic algorithms that capture common async patterns in objects satisfying the sender concept.
- Receiver: A generalized callback that consumes or “receives” the asynchronous results produced by a sender.
- Receivers have three different “channels” through which a sender may propagate results: success, failure, and canceled, so-named “value”, “error”, and “stopped”.
- Receivers provide an extensible execution environment: a set of key/value pairs that the consumer can use to parameterize the asynchronous operation.
- Operation State: An object that contains the state needed by the asynchronous operation.
- A sender and receiver are connected when passed to the std::execution::connect function.
- The result of connecting a sender and a receiver is an operation state.
- Work is not enqueued for execution until “
start
” is called on an operation state. - Once started, the operation state’s lifetime cannot end before the async operation is complete, and its address must be stable.
- Scheduler: A lightweight handle to an execution context.
- An execution context is a source of asynchronous execution such as a thread pool or a GPU stream.
- A scheduler is a factory for a sender that completes its receiver from a thread of execution owned by the execution context.
[edit] Library utilities
[edit] Concepts
[edit] Schedulers
Defined in header
<execution> | |
Defined in namespace
std::execution | |
(C++26) |
specifies that a type is a scheduler (concept) |
[edit] Senders
Defined in header
<execution> | |
Defined in namespace
std::execution | |
(C++26) |
specifies that a type is a sender (concept) |
(C++26) |
specifies a sender that can create asynchronous operations for given associated environment type (concept) |
(C++26) |
specifies a sender that can connect with a specific receiver type (concept) |
[edit] Receivers
Defined in header
<execution> | |
Defined in namespace
std::execution | |
(C++26) |
specifies that a type is a receiver (concept) |
(C++26) |
specifies that a type is a receiver for given completion signatures (concept) |
[edit] Operation states
Defined in header
<execution> | |
Defined in namespace
std::execution | |
(C++26) |
specifies that a type is an operation state (concept) |
[edit] Utility components
[edit] Execution contexts
Defined in header
<execution> | |
Defined in namespace
std::execution | |
(C++26) |
execution resource holding a thread-safe MPSC task queue and a manually-driven event loop (class) |
[edit] Execution domains
Defined in header
<execution> | |
Defined in namespace
std::execution | |
(C++26) |
default execution domain tag type that dispatches transformations from a sender tag (class) |
(C++26) |
transforms into a new sender under a given execution domain tag (function template) |
(C++26) |
transforms into a new queryable object under a given execution domain tag (function template) |
(C++26) |
consumes a sender using a given sender consumer tag with a set of arguments and returns its result under a given execution domain tag (function template) |
[edit] Forward progress guarantee
Defined in header
<execution> | |
Defined in namespace
std::execution | |
specifies a forward progress guarantee of execution agents created by the scheduler's associated execution resource (enum) |
[edit] Environments
Defined in header
<execution> | |
Defined in namespace
std::execution | |
(C++26) |
builds a queryable object from a query object and a value (class template) |
(C++26) |
aggregates several queryable objects into one queryable object (class template) |
(C++26) |
returns the associated queryable object for its given argument (customization point object) |
[edit] Queries
Defined in header
<execution> | |
(C++26) |
asks a query object whether it should be forwarded through queryable adaptors (customization point object) |
(C++26) |
asks a queryable object for its associated allocator (customization point object) |
(C++26) |
asks a queryable object for its associated stop token (customization point object) |
(C++26) |
asks a queryable object for its associated execution domain tag (customization point object) |
(C++26) |
asks a queryable object for its associated scheduler (customization point object) |
asks a queryable object for a scheduler that can be used to delegate work to for the purpose of forward progress delegation (customization point object) | |
obtains the completion scheduler associated with a completion tag from a sender's attributes (customization point object) | |
asks a scheduler about its execution::forward_progress_guarantee (customization point object) |
[edit] Completion signatures
Defined in header
<execution> | |
Defined in namespace
std::execution | |
type that encodes a set of completion signatures (class template) | |
obtains the completion signatures of a sender (customization point object) | |
transforms one set of completion signatures into another (alias template) | |
transforms completion signatures of a sender (alias template) | |
(C++26) |
obtains the tag type of a sender (alias template) |
(C++26) |
obtains the value completion type of a sender (alias template) |
(C++26) |
obtains the error completion type of a sender (alias template) |
(C++26) |
determines whether the sender supports stopped completion (variable template) |
[edit] Coroutine utility
Defined in header
<execution> | |
Defined in namespace
std::execution | |
(C++26) |
transforms an expression into awaitable object within a particular coroutine (customization point object) |
when used as the base class of a coroutine promise type, enables senders to be awaitable within that coroutine type (class template) |
[edit] Core operations
[edit] Operation state
Defined in header
<execution> | |
Defined in namespace
std::execution | |
(C++26) |
connects a sender with a receiver (customization point object) |
(C++26) |
starts the asynchronous operation associated with an operation_state object(customization point object) |
[edit] Completion functions
These functions are called by senders to announce the completion of the work to their receivers.
Defined in header
<execution> | |
Defined in namespace
std::execution | |
(C++26) |
value completion function indicating successful completion (customization point object) |
(C++26) |
error completion function indicating that an error occurred during calculation or scheduling (customization point object) |
(C++26) |
stopped completion function indicating that an operation ended before it could achieve success or failure (customization point object) |
[edit] Sender algorithms
This section is incomplete Reason: WIP update to current standard in progress |
[edit] Sender factories
A sender factory is a function that returns a sender and whose parameters have types for which the sender
concept is false.
The following are sender factories:
Defined in header
|