Skip to content

Commit 1730f6c

Browse files
committed
Merge bitcoin/bitcoin#26189: refactor: Do not discard try_lock() return value
30cc1c6 refactor: Drop `owns_lock()` call (Hennadii Stepanov) bff4e06 refactor: Do not discard `try_lock()` return value (Hennadii Stepanov) Pull request description: Microsoft's C++ Standard Library uses the `[[nodiscard]]` attribute for `try_lock()`. See: https://github.com/microsoft/STL/blob/main/stl/inc/mutex This change allows to drop the current suppression for the warning C4838 and helps to prevent the upcoming warning C4858. See: microsoft/STL@539c26c Fixes bitcoin/bitcoin#26017. Split from bitcoin/bitcoin#25819. ACKs for top commit: vasild: ACK 30cc1c6 Tree-SHA512: ce17404e1c78af4f763129753caf8e5a0e1c91ba398778fe912f9fcc56a847e8112460d1a1a35bf905a593b7d8e0b16c6b099ad74976b67dca5f4f3eda6ff621
2 parents b92b12e + 30cc1c6 commit 1730f6c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/sync.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,11 @@ class SCOPED_LOCKABLE UniqueLock : public Base
165165
bool TryEnter(const char* pszName, const char* pszFile, int nLine)
166166
{
167167
EnterCritical(pszName, pszFile, nLine, Base::mutex(), true);
168-
Base::try_lock();
169-
if (!Base::owns_lock()) {
170-
LeaveCritical();
168+
if (Base::try_lock()) {
169+
return true;
171170
}
172-
return Base::owns_lock();
171+
LeaveCritical();
172+
return false;
173173
}
174174

175175
public:

0 commit comments

Comments
 (0)