Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Unified Diff: include/core/SkInstCnt.h

Issue 419113002: Fix thread unsafe mutex initialization. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: gcc also wants impls to be inline or used. Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « bench/MutexBench.cpp ('k') | include/core/SkThread.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkInstCnt.h
diff --git a/include/core/SkInstCnt.h b/include/core/SkInstCnt.h
index 1839ee1dbdc6720d9c6b0870ea10e52dbe901c7a..e4b43d130b94b6a2ab9303c3c6c1170f7c3722ff 100644
--- a/include/core/SkInstCnt.h
+++ b/include/core/SkInstCnt.h
@@ -73,9 +73,14 @@ extern bool gPrintInstCount;
return gChildren; \
} \
\
+ static void create_mutex(SkMutex** mutex) { \
+ *mutex = SkNEW(SkMutex); \
+ } \
static SkBaseMutex& GetChildrenMutex() { \
- SK_DECLARE_STATIC_MUTEX(childrenMutex); \
- return childrenMutex; \
+ static SkMutex* childrenMutex; \
+ SK_DECLARE_STATIC_ONCE(once); \
+ SkOnce(&once, className::SkInstanceCountHelper::create_mutex, &childrenMutex);\
+ return *childrenMutex; \
bungeman-skia 2014/07/25 15:44:07 Making this body look like SK_DECLARE_STATIC_LAZY
} \
\
} fInstanceCountHelper; \
« no previous file with comments | « bench/MutexBench.cpp ('k') | include/core/SkThread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698