Backport note: I removed the paragraph about LockAssertion, because the code example causes a false positive linter error, and this paragraph would anyway get removed anyway in a few commits (D10173)
This is a backport of core#19668 [5/5]
https://github.com/bitcoin/bitcoin/pull/19668/commits/ea74e10acf17903e44c85e3678853414653dd4e1