fix an issue of a possibility of race condition in unlocking mutex

This commit is contained in:
falsycat 2022-11-03 11:53:28 +09:00
parent 8f6ff99136
commit f0c4f893bd

View File

@ -120,7 +120,8 @@ class Mutex::Lock {
~Lock() noexcept {
// Ensure that the Sync's destructor is called on worker thread.
ctx_->env().ExecSub(ctx_, [sync = sync_](){});
ctx_->env().ExecSub(
ctx_, [sync = std::move(sync_)]() mutable { sync = nullptr; });
}
private: