From a7a658171b748f318096323e0387335de869f8f5 Mon Sep 17 00:00:00 2001 From: div72 Date: Thu, 7 Dec 2023 22:35:04 +0300 Subject: [PATCH] refactor: use the try_lock result in TryEnter --- src/sync.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/sync.h b/src/sync.h index 62f57365fd..f9bbdf6913 100644 --- a/src/sync.h +++ b/src/sync.h @@ -160,10 +160,11 @@ class SCOPED_LOCKABLE UniqueLock : public Base bool TryEnter(const char* pszName, const char* pszFile, int nLine) { EnterCritical(pszName, pszFile, nLine, (void*)(Base::mutex()), true); - Base::try_lock(); - if (!Base::owns_lock()) - LeaveCritical(); - return Base::owns_lock(); + if (Base::try_lock()) { + return true; + } + LeaveCritical(); + return false; } public: