STEllAR-GROUP / hpx

The C++ Standard Library for Parallelism and Concurrency
https://hpx.stellar-group.org
Boost Software License 1.0
2.53k stars 430 forks source link

[Senders/Receivers] `as_awaitable` #5838

Closed SAtacker closed 1 year ago

SAtacker commented 2 years ago

Expected Behavior

All awaitables are senders Quoting from P2300

as_awaitable is used to transform an object into one that is awaitable within a particular coroutine

This function needs to be implemented for Senders/Receivers

Usage

To make non-awaitable senders as awaitable.

Possible cues to implementation

type sender-awaitable as described in the above P2300 and type checking for Senders using templates to check if they have co_await method/free operator

CC @hkaiser

SAtacker commented 2 years ago

For the case when the sender is not an awaitable we should have a base for awaitable which consists of a coroutine_handle, promise object defined in libs/core/futures/include/hpx/futures/promise.hpp, and hpx::execution::operation state defined in libs/core/execution/include/hpx/execution/algorithms/just.hppif I am not wrong?