1
0
Fork 0
mirror of https://gitlab.com/niansa/libcrosscoro.git synced 2025-03-06 20:53:32 +01:00
libcrosscoro/inc/coro/promise.hpp
Josh Baldwin c548433dd9
Correctly implement sync_wait and when_all_awaitable (#8)
See issue for more details, in general attempting to
implement a coro::thread_pool exposed that the coro::sync_wait
and coro::when_all only worked if the coroutines executed on
that same thread.  They should now possibly have the ability
to execute on another thread, to be determined in a later issue.

Fixes #7
2020-10-25 20:54:19 -06:00

25 lines
613 B
C++

#pragma once
#include "coro/awaitable.hpp"
#include <concepts>
namespace coro
{
template<typename T, typename return_type>
concept promise_type = requires(T t)
{
{ t.get_return_object() } -> std::convertible_to<std::coroutine_handle<>>;
{ t.initial_suspend() } -> awaiter_type;
{ t.final_suspend() } -> awaiter_type;
{ t.yield_value() } -> awaitable_type;
} &&
requires(T t, return_type return_value)
{
std::same_as<decltype(t.return_void()), void> ||
std::same_as<decltype(t.return_value(return_value)), void> ||
requires { t.yield_value(return_value); };
};
} // namespace coro