You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Lazy execution of the coroutine, especially to allow control of execution cost. (For future support of Concurrency TS or Executor TS)
initial: suspend_always
final: suspend_never
#include<coroutine/return.h>
[[nodiscard]] autoimpl(int a, int b) -> std::packaged_task<int(void)> {
co_await std::suspend_never{};
co_return a + b;
}
voidusage(){
auto task = impl(1, 1);
auto f = task.get_future();
task();
assert(f.get() == 2);
}
Concerns
std::packaged_task<R(P, ...)> requires std::future<R> support.
It is highly possible to be heavy more than necessary.
Considering combination of
initial_suspend
/final_suspend
, we need at least 4 return types.Idea
I'd like to reuse existing types for coroutines' return whenever possible.
*_frame_t
for controlled destruction?(final suspend returns
suspend_always
)std::nullptr_t/void
Something like
null_frame_t
. (previouslyno_return
)suspend_never
suspend_never
Or if compiler allows,
void
can be an option. (GCC-10 requires the type must beclass
)passive_frame_t
Usually for manual start(initiate) / cleanup(destroy) of the frame.
suspend_always
suspend_always
std::packaged_task<R(P, ...)>Lazy execution of the coroutine, especially to allow control of execution cost. (For future support of Concurrency TS or Executor TS)
suspend_always
suspend_never
Concerns
std::packaged_task<R(P, ...)>
requiresstd::future<R>
support.It is highly possible to be heavy more than necessary.
frame_t
Controlled destruction of the coroutine frame.
suspend_never
suspend_always
The text was updated successfully, but these errors were encountered: