[PATCH] D19412: [libcxx] Refactor pthread usage - II

Ben Craig via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 27 13:03:21 PDT 2016


bcraig added inline comments.

================
Comment at: src/algorithm.cpp:51
@@ -50,3 +50,3 @@
 #ifndef _LIBCPP_HAS_NO_THREADS
-static pthread_mutex_t __rs_mut = PTHREAD_MUTEX_INITIALIZER;
+static mutex __rs_mut;
 #endif
----------------
rmaprath wrote:
> mclow.lists wrote:
> > What happened to the initializer here?
> I'm expecting the constructor of `mutex` to be run here at load time (before `main`). Note that this a libc++ mutex rather than a pthreads mutex (which does not required a constructor call like this). Would that be too much of an overhead?
std::mutex's default ctor is constexpr.  As long as the compiler supports constexpr, this initialization shouldn't require runtime code.


http://reviews.llvm.org/D19412





More information about the cfe-commits mailing list