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