Skip to content

Commit

Permalink
feat(co): warn coroutine leak instead of assert
Browse files Browse the repository at this point in the history
  • Loading branch information
Codesire-Deng committed Nov 11, 2023
1 parent c13f24d commit c111145
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/co_context/co/semaphore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@
namespace co_context {

counting_semaphore::~counting_semaphore() noexcept {
assert(awaiting.load(std::memory_order_relaxed) == nullptr);
assert(to_resume == nullptr);
if constexpr (config::is_log_d) {
if (awaiting.load(std::memory_order_relaxed) != nullptr
|| to_resume != nullptr) {
log::d("[WARNING] ~counting_semaphore(): coroutine leak\n");
}
}
}

bool counting_semaphore::try_acquire() noexcept {
Expand Down

0 comments on commit c111145

Please sign in to comment.