|
ecor
|
Task type that represents an asynchronous operation that is implemented as a coroutine and is a sender. More...
#include <ecor.hpp>
Public Types | |
| using | completion_signatures = _sigs_append_t< _error_completions, _value_setter_t< T >, set_stopped_t() > |
| using | promise_type = _promise_type< task, CFG > |
| using | sender_concept = sender_t |
| using | value_type = T |
Public Member Functions | |
| template<receiver R> | |
| auto | connect (R receiver) && |
| Connect the task to a receiver. More... | |
| task & | operator= (task &&other) noexcept |
| task & | operator= (task const &)=delete |
| task (std::coroutine_handle< promise_type > handle, task_error error=task_error::none) noexcept | |
| Constructor used by promise_type for coroutine creation. | |
| task (task &&other) noexcept | |
| task (task const &)=delete | |
Task type that represents an asynchronous operation that is implemented as a coroutine and is a sender.
The task type is parameterized by the value type it provides, and an optional configuration type that specifies additional behavior during compilation.
Task expectes argument satisfying task_context concept to be passed to the coroutine as first argument. This is used to provide the task with necessary runtime resources, such as the task core for scheduling and the task memory resource for dynamic memory allocation.
Task can be scheduled and processed as normal sender in the sender/receiver framework. The task has capability to co_await any sender as long as:
Task always starts suspended and only starts execution after start() was called on the operation state returned by connect().
When co_awaiting on a sender, the task will suspend until the sender completes, value signal of sender does not immediately resume the task, but instead the task is scheduled to be resumed by the task core. In case of an error or stop signal from the sender, the task will not be resumed, but instead the error or stop signal will be immediately propagated to the task's receiver, and the task will be considered completed and will be destructed.
Task completion signature is always fixed and independent of the content of the coroutine itself, or the receiver environment:
|
inline |
Connect the task to a receiver.
This returns an operation state that can be started to begin the execution of the task.
The operation is expected to be destructive, the task can't be connected again after connect call.