diff options
author | Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> | 2022-08-10 23:18:45 +0100 |
---|---|---|
committer | Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> | 2022-09-27 22:35:16 +0100 |
commit | bff4e068b69edd40a00466156f860bde2df29268 (patch) | |
tree | c72a7191448fc084e917c6baf1159e3cf9d4d189 /src/sync.h | |
parent | 9fcdb9f3a044330d3d7515fa35709102c98534d2 (diff) |
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: https://github.com/microsoft/STL/commit/539c26c923b38cd0b5eba2bb11de4bea9d5c6e43
Diffstat (limited to 'src/sync.h')
-rw-r--r-- | src/sync.h | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/src/sync.h b/src/sync.h index c34d969041..a4f4d1ac8d 100644 --- a/src/sync.h +++ b/src/sync.h @@ -165,8 +165,7 @@ private: bool TryEnter(const char* pszName, const char* pszFile, int nLine) { EnterCritical(pszName, pszFile, nLine, Base::mutex(), true); - Base::try_lock(); - if (!Base::owns_lock()) { + if (!Base::try_lock()) { LeaveCritical(); } return Base::owns_lock(); |