Commit 47f10b10 authored by Xavier Thompson's avatar Xavier Thompson

Add discard methods for optimisation

parent 863803a3
...@@ -74,12 +74,34 @@ namespace typon ...@@ -74,12 +74,34 @@ namespace typon
return awaitable { _coroutine }; return awaitable { _coroutine };
} }
auto discard() && noexcept
{
struct awaitable : suspend_always
{
coroutine_handle<promise_type> _coroutine;
coroutine_handle<> await_suspend(coroutine_handle<> awaiting_coroutine) noexcept
{
_coroutine.promise()._continuation = awaiting_coroutine;
return _coroutine;
}
};
return awaitable { {}, _coroutine };
}
decltype(auto) call() && decltype(auto) call() &&
{ {
_coroutine.promise()._continuation = noop_coroutine(); _coroutine.promise()._continuation = noop_coroutine();
_coroutine.resume(); _coroutine.resume();
return _coroutine.promise().get(); return _coroutine.promise().get();
} }
void call_discard() &&
{
_coroutine.promise()._continuation = noop_coroutine();
_coroutine.resume();
}
}; };
} }
......
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