Skip to content

Commit

Permalink
fix async-simple no discard when call spinlock::coScopedLock (#884)
Browse files Browse the repository at this point in the history
* fix async-simple no discard when call spinlock::coScopedLock

* remove useless header
  • Loading branch information
poor-circle authored Jan 20, 2025
1 parent 45d5061 commit c4fc58e
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions include/ylt/thirdparty/async_simple/coro/SpinLock.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,14 @@ class SpinLock {
}
}

void unlock() noexcept { _locked.store(false, std::memory_order_release); }
void unlock() noexcept {
assert(_locked.load(std::memory_order_acquire) == true);
_locked.store(false, std::memory_order_release);
}

Lazy<std::unique_lock<SpinLock>> coScopedLock() {
co_await coLock();
co_return std::unique_lock<SpinLock>{*this, std::adopt_lock};
[[nodiscard]] Lazy<std::unique_lock<SpinLock>> coScopedLock() {
co_await coLock();
co_return std::unique_lock<SpinLock>{*this, std::adopt_lock};
}

private:
Expand Down

0 comments on commit c4fc58e

Please sign in to comment.