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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 ~SkMutex() { | 66 ~SkMutex() { |
67 SkDEBUGCODE(int rc = )pthread_mutex_destroy(&fMutex); | 67 SkDEBUGCODE(int rc = )pthread_mutex_destroy(&fMutex); |
68 SkASSERT(0 == rc); | 68 SkASSERT(0 == rc); |
69 } | 69 } |
70 | 70 |
71 private: | 71 private: |
72 SkMutex(const SkMutex&); | 72 SkMutex(const SkMutex&); |
73 SkMutex& operator=(const SkMutex&); | 73 SkMutex& operator=(const SkMutex&); |
74 }; | 74 }; |
75 | 75 |
76 #if defined(SK_DEBUG) && defined(PTHREAD_ERRORCHECK_MUTEX_INITIALIZER) | 76 #if defined(SK_DEBUG) && defined(PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP) |
77 // When possible we want to use error-check mutexes in Debug builds. See th
e note at the top. | 77 // When possible we want to use error-check mutexes in Debug builds. See th
e note at the top. |
78 #define SK_BASE_MUTEX_INIT { PTHREAD_ERRORCHECK_MUTEX_INITIALIZER, kNoOwner
} | 78 #define SK_BASE_MUTEX_INIT { PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP, kNoOwn
er } |
79 #elif defined(SK_DEBUG) | 79 #elif defined(SK_DEBUG) |
80 // Macs don't support PTHREAD_ERRORCHECK_MUTEX_INITIALIZER when targeting <1
0.7. We target 10.6. | 80 // Macs don't support PTHREAD_ERRORCHECK_MUTEX_INITIALIZER when targeting <1
0.7. We target 10.6. |
81 #define SK_BASE_MUTEX_INIT { PTHREAD_MUTEX_INITIALIZER, kNoOwner } | 81 #define SK_BASE_MUTEX_INIT { PTHREAD_MUTEX_INITIALIZER, kNoOwner } |
82 #else | 82 #else |
83 #define SK_BASE_MUTEX_INIT { PTHREAD_MUTEX_INITIALIZER } | 83 #define SK_BASE_MUTEX_INIT { PTHREAD_MUTEX_INITIALIZER } |
84 #endif | 84 #endif |
85 | 85 |
86 // Using POD-style initialization prevents the generation of a static initialize
r. | 86 // Using POD-style initialization prevents the generation of a static initialize
r. |
87 // | 87 // |
88 // Without magic statics there are no thread safety guarantees on initialization | 88 // Without magic statics there are no thread safety guarantees on initialization |
89 // of local statics (even POD). As a result, it is illegal to use | 89 // of local statics (even POD). As a result, it is illegal to use |
90 // SK_DECLARE_STATIC_MUTEX in a function. | 90 // SK_DECLARE_STATIC_MUTEX in a function. |
91 // | 91 // |
92 // Because SkBaseMutex is not a primitive, a static SkBaseMutex cannot be | 92 // Because SkBaseMutex is not a primitive, a static SkBaseMutex cannot be |
93 // initialized in a class with this macro. | 93 // initialized in a class with this macro. |
94 #define SK_DECLARE_STATIC_MUTEX(name) namespace {} static SkBaseMutex name = SK_
BASE_MUTEX_INIT | 94 #define SK_DECLARE_STATIC_MUTEX(name) namespace {} static SkBaseMutex name = SK_
BASE_MUTEX_INIT |
95 | 95 |
96 #endif | 96 #endif |
OLD | NEW |