This PR is a simple 3-line scripted diff followed by a documentation cleanup. The scripted diff does three things:
- Deletes all existing AssertLockHeldcalls. Since #19668,AssertLockHeldhas had anEXCLUSIVE_LOCKS_REQUIREDannotation which has guaranteed (though ongoing travis and cirrus CI builds since #19668 was merged) that theseAssertLockHeldcalls are redundant withEXCLUSIVE_LOCKS_REQUIREDorEXCLUSIVE_LOCK_FUNCTIONannotations already present in surrounding code, and specifically that:
- There is no way the assert calls can trigger any behavior at runtime.
- The assert calls provide no new thread safety information to the compiler.
- 
Reverts AssertLockHeldimplementation which got changed in #19668 to it’s original pre-#19668 state. In #19668,AssertLockHeldwas changed to have anEXCLUSIVE_LOCKS_REQUIREDannotation instead of having anASSERT_EXCLUSIVE_LOCKannotation. As described above, having anEXCLUSIVE_LOCKS_REQUIREDannotation on an assert statement is only useful as proof that the assert statement doesn’t do anything or convey any new information. By contrast, having anASSERT_EXCLUSIVE_LOCKannotation on an assert statement can be an actually useful way of conveying to the compiler than a specific mutex is locked at a specific place in the code, when the compiler thread safety analysis can’t determine that on its own (because of lost type information).
- 
Removes LockAssertionclass, replacing all current uses with calls toAssertLockHeld. Ever since theLockAssertionclass was first introduced in #14437 (asLockAnnotation), it has always been an inferior alternative toAssertLockHeldand not had a reason to exist. (#14437 was originally written before #13423 which added ASSERT_EXCLUSIVE_LOCK annotation. It was justified when the code was first written, but no longer necessary by the time it was merged).
Motivation for this PR is to get rid of confusion between different types of lock assertions and only keep one assertion: AssertLockHeld which goes back to the implementation it’s had since #13423 was merged until #19668 was merged. After this PR, AssertLockHeld only needs to be used sparingly to augment compile-time thread safety annotations, which are a superior alternative to runtime checks for guaranteeing thread safety.
PR is compared with alternatives in https://github.com/bitcoin-core/bitcoin-devwiki/wiki/AssertLockHeld-PRs