| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 SkLazyPtr_DEFINED | 8 #ifndef SkLazyPtr_DEFINED |
| 9 #define SkLazyPtr_DEFINED | 9 #define SkLazyPtr_DEFINED |
| 10 | 10 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 * | 40 * |
| 41 * | 41 * |
| 42 * You can think of SK_DECLARE_STATIC_LAZY_PTR as a cheaper specialization of | 42 * You can think of SK_DECLARE_STATIC_LAZY_PTR as a cheaper specialization of |
| 43 * SkOnce. There is no mutex or extra storage used past the pointer itself. | 43 * SkOnce. There is no mutex or extra storage used past the pointer itself. |
| 44 * In debug mode, each lazy pointer will be cleaned up at process exit so we | 44 * In debug mode, each lazy pointer will be cleaned up at process exit so we |
| 45 * can check that we've not leaked or freed them early. | 45 * can check that we've not leaked or freed them early. |
| 46 * | 46 * |
| 47 * We may call Create more than once, but all threads will see the same pointer | 47 * We may call Create more than once, but all threads will see the same pointer |
| 48 * returned from get(). Any extra calls to Create will be cleaned up. | 48 * returned from get(). Any extra calls to Create will be cleaned up. |
| 49 * | 49 * |
| 50 * These macros must be used in a global or function scope, not as a class memb
er. | 50 * These macros must be used in a global scope, not in function scope or as a c
lass member. |
| 51 */ | 51 */ |
| 52 | 52 |
| 53 #define SK_DECLARE_STATIC_LAZY_PTR(T, name, ...) \ | 53 #define SK_DECLARE_STATIC_LAZY_PTR(T, name, ...) \ |
| 54 static Private::SkLazyPtr<T, ##__VA_ARGS__> name | 54 namespace {} static Private::SkLazyPtr<T, ##__VA_ARGS__> name |
| 55 | 55 |
| 56 #define SK_DECLARE_STATIC_LAZY_PTR_ARRAY(T, name, N, ...) \ | 56 #define SK_DECLARE_STATIC_LAZY_PTR_ARRAY(T, name, N, ...) \ |
| 57 static Private::SkLazyPtrArray<T, N, ##__VA_ARGS__> name | 57 namespace {} static Private::SkLazyPtrArray<T, N, ##__VA_ARGS__> name |
| 58 | 58 |
| 59 // namespace {} forces these macros to only be legal in global scopes. Chrome h
as thread-safety |
| 60 // problems with them in function-local statics because it uses -fno-threadsafe-
statics, and even |
| 61 // in builds with threadsafe statics, those threadsafe statics are just unnecess
ary overhead. |
| 59 | 62 |
| 60 | 63 |
| 61 // Everything below here is private implementation details. Don't touch, don't
even look. | 64 // Everything below here is private implementation details. Don't touch, don't
even look. |
| 62 | 65 |
| 63 #include "SkDynamicAnnotations.h" | 66 #include "SkDynamicAnnotations.h" |
| 64 #include "SkThread.h" | 67 #include "SkThread.h" |
| 65 #include "SkThreadPriv.h" | 68 #include "SkThreadPriv.h" |
| 66 | 69 |
| 67 // See FIXME below. | 70 // See FIXME below. |
| 68 class SkFontConfigInterfaceDirect; | 71 class SkFontConfigInterfaceDirect; |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 } | 152 } |
| 150 #endif | 153 #endif |
| 151 | 154 |
| 152 private: | 155 private: |
| 153 void* fArray[N]; | 156 void* fArray[N]; |
| 154 }; | 157 }; |
| 155 | 158 |
| 156 } // namespace Private | 159 } // namespace Private |
| 157 | 160 |
| 158 #endif//SkLazyPtr_DEFINED | 161 #endif//SkLazyPtr_DEFINED |
| OLD | NEW |