[Lldb-commits] [PATCH] D35083: [TypeSystem] Guard the global `ASTSourceMap` with a mutex

Jim Ingham via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Mon Jul 10 18:51:31 PDT 2017

jingham added a comment.

This is a fairly common idiom in lldb and seems to me quite obvious.  If the API to get an object requires a lock guard of some sort, then you have to hold the lock while using the object.

As a general practice requiring a wrapper like this for every use of a should be locked object would make the code noisy and hard to read.  The only error you would be protecting against is that somebody used the entity after the lock went out of scope.  You could use some kind of markup to enforce this requirement, but you also have to be pretty sloppy to make this kind of error, so I'm not sure this it worth going to great lengths to protect against.

In this limited use, I guess I don't object seriously, but don't like this as a general pattern.



More information about the lldb-commits mailing list