[PATCH] Change base mutex implementations to use STL-provided mutexes

Zachary Turner zturner at google.com
Fri Jun 6 11:28:25 PDT 2014


On Fri, Jun 6, 2014 at 9:52 AM, Zachary Turner <zturner at google.com> wrote:
>
> By the way, there's another approach I could have taken, which is simply
> to delete llvm::sys::Mutex entirely, and embed std::mutex and
> std::recursive_mutex instances directly in the code.  We lose the Debug
> versions of the mutexes, but they seem to be not used heavily, so maybe
> this is ok.  I took the path of least resistance and made the semantics
> identical though, so if you think this other approach is better, I could
> change it.
>

Just to expand on this line of thought, a mutex's cost is directly
proportional to how heavily contended it is.  If there's zero contention,
which there will be in a single threaded app, locking a mutex is almost
free.  So I don't see too much of a problem with getting rid of this whole
concept of multi-threading only mode and going with raw std::mutex /
recursive_mutex in the code.  But let me know if there's something I
haven't considered or if anyone feels differently.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140606/d453245b/attachment.html>


More information about the llvm-commits mailing list