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

Side by Side 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, 4 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 unified diff | Download patch
« no previous file with comments | « bench/MutexBench.cpp ('k') | include/core/SkThread.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 8
9 #ifndef SkInstCnt_DEFINED 9 #ifndef SkInstCnt_DEFINED
10 #define SkInstCnt_DEFINED 10 #define SkInstCnt_DEFINED
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 static int32_t* GetInstanceCountPtr() { \ 66 static int32_t* GetInstanceCountPtr() { \
67 static int32_t gInstanceCount; \ 67 static int32_t gInstanceCount; \
68 return &gInstanceCount; \ 68 return &gInstanceCount; \
69 } \ 69 } \
70 \ 70 \
71 static SkTArray<int (*)(int, bool)>*& GetChildren() { \ 71 static SkTArray<int (*)(int, bool)>*& GetChildren() { \
72 static SkTArray<int (*)(int, bool)>* gChildren; \ 72 static SkTArray<int (*)(int, bool)>* gChildren; \
73 return gChildren; \ 73 return gChildren; \
74 } \ 74 } \
75 \ 75 \
76 static void create_mutex(SkMutex** mutex) { \
77 *mutex = SkNEW(SkMutex); \
78 } \
76 static SkBaseMutex& GetChildrenMutex() { \ 79 static SkBaseMutex& GetChildrenMutex() { \
77 SK_DECLARE_STATIC_MUTEX(childrenMutex); \ 80 static SkMutex* childrenMutex; \
78 return childrenMutex; \ 81 SK_DECLARE_STATIC_ONCE(once); \
82 SkOnce(&once, className::SkInstanceCountHelper::create_mutex, &child renMutex);\
83 return *childrenMutex; \
bungeman-skia 2014/07/25 15:44:07 Making this body look like SK_DECLARE_STATIC_LAZY
79 } \ 84 } \
80 \ 85 \
81 } fInstanceCountHelper; \ 86 } fInstanceCountHelper; \
82 \ 87 \
83 static int32_t GetInstanceCount() { \ 88 static int32_t GetInstanceCount() { \
84 return *SkInstanceCountHelper::GetInstanceCountPtr(); \ 89 return *SkInstanceCountHelper::GetInstanceCountPtr(); \
85 } \ 90 } \
86 \ 91 \
87 static void exitPrint() { \ 92 static void exitPrint() { \
88 CheckInstanceCount(0, true); \ 93 CheckInstanceCount(0, true); \
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 #define SK_DECLARE_INST_COUNT(className) static void AddInstChild() { INHERITED: :AddInstChild(); } 138 #define SK_DECLARE_INST_COUNT(className) static void AddInstChild() { INHERITED: :AddInstChild(); }
134 #define SK_DECLARE_INST_COUNT_ROOT(className) static void AddInstChild() { } 139 #define SK_DECLARE_INST_COUNT_ROOT(className) static void AddInstChild() { }
135 #endif 140 #endif
136 141
137 // Following are deprecated. They are defined only for backwards API compatibili ty. 142 // Following are deprecated. They are defined only for backwards API compatibili ty.
138 #define SK_DECLARE_INST_COUNT_TEMPLATE(className) SK_DECLARE_INST_COUNT(classNam e) 143 #define SK_DECLARE_INST_COUNT_TEMPLATE(className) SK_DECLARE_INST_COUNT(classNam e)
139 #define SK_DEFINE_INST_COUNT(className) 144 #define SK_DEFINE_INST_COUNT(className)
140 #define SK_DEFINE_INST_COUNT_TEMPLATE(templateInfo, className) 145 #define SK_DEFINE_INST_COUNT_TEMPLATE(templateInfo, className)
141 146
142 #endif // SkInstCnt_DEFINED 147 #endif // SkInstCnt_DEFINED
OLDNEW
« 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