File tree Expand file tree Collapse file tree 3 files changed +17
-5
lines changed
Expand file tree Collapse file tree 3 files changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -28,7 +28,13 @@ class GatherAwaiter: NonCopyable {
2828 void await_suspend (std::coroutine_handle<Promise> continuation) noexcept {
2929 continuation_ = &continuation.promise ();
3030 // set continuation_ to PENDING, don't schedule anymore, until it resume continuation_
31- continuation_->set_state (PromiseState::PENDING);
31+ continuation.promise ().set_state (PromiseState::PENDING);
32+ }
33+
34+ ~GatherAwaiter () {
35+ if (continuation_) {
36+ continuation_->set_state (PromiseState::UNSCHEDULED);
37+ }
3238 }
3339
3440 template <concepts::Awaitable... Futs>
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ enum class PromiseState: uint8_t {
1515 PENDING,
1616};
1717
18- struct Handle {
18+ struct Handle { // type erase for EventLoop
1919 virtual void run () = 0;
2020 std::string frame_name () const {
2121 const auto & frame_info = get_frame_info ();
Original file line number Diff line number Diff line change @@ -21,10 +21,16 @@ struct WaitForAwaiter: NonCopyable {
2121 }
2222
2323 template <typename Promise>
24- void await_suspend (std::coroutine_handle<Promise> caller ) noexcept {
25- continuation_ = &caller .promise ();
24+ void await_suspend (std::coroutine_handle<Promise> continuation ) noexcept {
25+ continuation_ = &continuation .promise ();
2626 // set continuation_ to PENDING, don't schedule anymore, until it resume continuation_
27- continuation_->set_state (PromiseState::PENDING);
27+ continuation.promise ().set_state (PromiseState::PENDING);
28+ }
29+
30+ ~WaitForAwaiter () {
31+ if (continuation_) {
32+ continuation_->set_state (PromiseState::UNSCHEDULED);
33+ }
2834 }
2935
3036 template <concepts::Awaitable Fut>
You can’t perform that action at this time.
0 commit comments