Commit 9171a165 authored by Xavier Thompson's avatar Xavier Thompson

WIP Eager coroutines design

parent f6f9c8be
...@@ -30,7 +30,7 @@ namespace typon ...@@ -30,7 +30,7 @@ namespace typon
return { std::coroutine_handle<promise_type>::from_promise(*this) }; return { std::coroutine_handle<promise_type>::from_promise(*this) };
} }
std::suspend_always initial_suspend() noexcept std::suspend_never initial_suspend() noexcept
{ {
return {}; return {};
} }
...@@ -41,7 +41,11 @@ namespace typon ...@@ -41,7 +41,11 @@ namespace typon
{ {
std::coroutine_handle<> await_suspend(std::coroutine_handle<promise_type> coroutine) noexcept std::coroutine_handle<> await_suspend(std::coroutine_handle<promise_type> coroutine) noexcept
{ {
return coroutine.promise()._continuation; if (coroutine.promise()._continuation)
{
return coroutine.promise()._continuation;
}
return std::noop_coroutine();
} }
}; };
...@@ -57,7 +61,7 @@ namespace typon ...@@ -57,7 +61,7 @@ namespace typon
bool await_ready() noexcept bool await_ready() noexcept
{ {
return false; return _coroutine.done();
} }
std::coroutine_handle<> await_suspend(std::coroutine_handle<> awaiting_coroutine) noexcept std::coroutine_handle<> await_suspend(std::coroutine_handle<> awaiting_coroutine) noexcept
...@@ -77,8 +81,6 @@ namespace typon ...@@ -77,8 +81,6 @@ namespace typon
decltype(auto) call() const&& decltype(auto) call() const&&
{ {
_coroutine.promise()._continuation = std::noop_coroutine();
_coroutine.resume();
return _coroutine.promise().get(); return _coroutine.promise().get();
} }
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment