mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-18 22:35:39 +01:00
Merge bitcoin/bitcoin#27116: doc: clarify that LOCK() internally checks whether the mutex is held
91d0888921sync: unpublish LocksHeld() which is used only in sync.cpp (Vasil Dimov)3df37e0c78doc: clarify that LOCK() does AssertLockNotHeld() internally (Vasil Dimov) Pull request description: Constructs like ```cpp AssertLockNotHeld(m); LOCK(m); ``` are equivalent to (almost, modulo some logging differences, see below) ```cpp LOCK(m); ``` for non-recursive mutexes, so it is ok to omit `AssertLockNotHeld()` in such cases. Requests to do the former keep coming during review process. `developer-notes.md` explicitly states "Combine annotations in function declarations with run-time asserts in function definitions", but that seems to be too strong or unclear. `LOCK()` is also a run-time assert in this case. Also remove `LocksHeld()` from the public interface in `sync.h` since it is only used in `sync.cpp`. ACKs for top commit: achow101: ACK91d0888921hebasto: ACK91d0888921, I have reviewed the code and it looks OK. Tree-SHA512: c4b7ef2c0bfeb28d1c4f55f497810f629873137e02f5a92137c02cb1ff603ac76473dcd2171e594491494a5cb87b8c0c803e06b86f190d4acb231791e28e802d
This commit is contained in:
@@ -950,7 +950,9 @@ Threads and synchronization
|
||||
internal to a class (private or protected) rather than public.
|
||||
|
||||
- Combine annotations in function declarations with run-time asserts in
|
||||
function definitions:
|
||||
function definitions (`AssertLockNotHeld()` can be omitted if `LOCK()` is
|
||||
called unconditionally after it because `LOCK()` does the same check as
|
||||
`AssertLockNotHeld()` internally, for non-recursive mutexes):
|
||||
|
||||
```C++
|
||||
// txmempool.h
|
||||
|
||||
Reference in New Issue
Block a user