File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99#include < cppcoro/fmap.hpp>
1010
1111#include < cppcoro/detail/continuation.hpp>
12+ #include < cppcoro/detail/dummy_coroutine.hpp>
1213
1314#include < atomic>
1415#include < exception>
@@ -53,16 +54,22 @@ namespace cppcoro
5354 return m_promise.m_state .load (std::memory_order_acquire) == state::consumer_detached;
5455 }
5556
56- // If resuming awaiter can potentially throw what state would that leave this coroutine in?
57- bool await_suspend ( std::experimental::coroutine_handle<>) noexcept
57+ std::experimental::coroutine_handle<> await_suspend (
58+ std::experimental::coroutine_handle<> coroutine ) noexcept
5859 {
5960 state oldState = m_promise.m_state .exchange (state::finished, std::memory_order_acq_rel);
6061 if (oldState == state::consumer_suspended)
6162 {
62- m_promise.m_continuation .resume ();
63+ return m_promise.m_continuation .tail_call_resume ();
64+ }
65+ else if (oldState == state::consumer_detached)
66+ {
67+ return coroutine;
68+ }
69+ else
70+ {
71+ return detail::dummy_coroutine::handle ();
6372 }
64-
65- return oldState != state::consumer_detached;
6673 }
6774
6875 void await_resume () noexcept
You can’t perform that action at this time.
0 commit comments