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
bff4e068b6
hebasto
commented at 9:38 pm on September 27, 2022:
member
ajtowns
commented at 9:53 pm on September 27, 2022:
contributor
Concept ACK.
This seems to have been introduced in 712fd182b72b0f5a1bcf843f171c29ec0a49b50f (April 2012) by @sipa – the old code for TryEnter did result = mutex.try_lock(); if (!result) pop_lock(); return result; the new code discarded the result for try_lock() and instead then checked !lock.owns().
DrahtBot
commented at 10:28 pm on September 27, 2022:
contributor
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
Conflicts
Reviewers, this pull request conflicts with the following ones:
#25081 (tracing: lock contention analysis by martinus)
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
DrahtBot added the label
Refactoring
on Sep 28, 2022
vasild approved
vasild
commented at 8:37 am on September 28, 2022:
contributor
ACKbff4e068b69edd40a00466156f860bde2df29268
The old and new code should have identical behavior. The new code is shorter and silences a warning.
This is a metadata mirror of the GitHub repository
bitcoin/bitcoin.
This site is not affiliated with GitHub.
Content is generated from a GitHub metadata backup.
generated: 2024-12-22 06:12 UTC
This site is hosted by @0xB10C More mirrored repositories can be found on mirror.b10c.me