OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 #ifndef SkMutex_pthread_DEFINED | 8 #ifndef SkMutex_pthread_DEFINED |
9 #define SkMutex_pthread_DEFINED | 9 #define SkMutex_pthread_DEFINED |
10 | 10 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 default: | 82 default: |
83 SkDebugf("pthread error [%d] unknown\n", status); | 83 SkDebugf("pthread error [%d] unknown\n", status); |
84 break; | 84 break; |
85 } | 85 } |
86 } | 86 } |
87 }; | 87 }; |
88 | 88 |
89 #define SK_BASE_MUTEX_INIT { PTHREAD_MUTEX_INITIALIZER, SkDEBUGCODE(0) } | 89 #define SK_BASE_MUTEX_INIT { PTHREAD_MUTEX_INITIALIZER, SkDEBUGCODE(0) } |
90 | 90 |
91 // Using POD-style initialization prevents the generation of a static initialize
r. | 91 // Using POD-style initialization prevents the generation of a static initialize
r. |
| 92 // |
92 // Without magic statics there are no thread safety guarantees on initialization | 93 // Without magic statics there are no thread safety guarantees on initialization |
93 // of local statics (even POD). | 94 // of local statics (even POD). As a result, it is illegal to use |
94 // As a result, it is illegal to SK_DECLARE_STATIC_MUTEX in a function. | 95 // SK_DECLARE_STATIC_MUTEX in a function. |
95 #define SK_DECLARE_STATIC_MUTEX(name) \ | 96 // |
96 static inline void SK_MACRO_APPEND_LINE(name)(){} \ | 97 // Because SkBaseMutex is not a primitive, a static SkBaseMutex cannot be |
97 static SkBaseMutex name = SK_BASE_MUTEX_INIT | 98 // initialized in a class with this macro. |
| 99 #define SK_DECLARE_STATIC_MUTEX(name) namespace {} static SkBaseMutex name = SK_
BASE_MUTEX_INIT |
98 | 100 |
99 #endif | 101 #endif |
OLD | NEW |