Skip to content

Commit

Permalink
reuse count_down in latch
Browse files Browse the repository at this point in the history
  • Loading branch information
kelbon committed Apr 24, 2024
1 parent bab4cdc commit 0193b93
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions include/kelcoro/latch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,7 @@ struct latch {
void await_suspend(std::coroutine_handle<> handle) noexcept {
node.task = handle;
l.stack.push(&node);
// copy logic from count down but never resume
assert(n >= 0 && n <= l.counter.load(std::memory_order::acquire));
ptrdiff_t c = l.counter.fetch_sub(n, std::memory_order::acq_rel);
assert(c >= n);
if (c == n) [[unlikely]]
l.wakeup_all();
l.count_down(n);
}
static void await_resume() noexcept {
}
Expand Down

0 comments on commit 0193b93

Please sign in to comment.