I always felt that pattern was a bit too clever than it was a good design.
with lock {
// do stuff
}
design. This could be C++ too to be honest because lambdas exist but RAII is just too common for people to design their locks like this.