Skip to content

Commit bff4e06

Browse files
committed
refactor: Do not discard try_lock() return value
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
1 parent 9fcdb9f commit bff4e06

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/sync.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,7 @@ 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()) {
168+
if (!Base::try_lock()) {
170169
LeaveCritical();
171170
}
172171
return Base::owns_lock();

0 commit comments

Comments
 (0)