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

Side by Side Diff: include/core/SkOnce.h

Issue 1369333004: Move SkAtomics.h to private. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 2 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 | « include/core/SkAtomics.h ('k') | include/core/SkPixelRef.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 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 SkOnce_DEFINED 8 #ifndef SkOnce_DEFINED
9 #define SkOnce_DEFINED 9 #define SkOnce_DEFINED
10 10
11 // Before trying SkOnce, see if SkLazyPtr or SkLazyFnPtr will work for you. 11 // Before trying SkOnce, see if SkLazyPtr or SkLazyFnPtr will work for you.
12 // They're smaller and faster, if slightly less versatile. 12 // They're smaller and faster, if slightly less versatile.
13 13
14 14
15 // SkOnce.h defines SK_DECLARE_STATIC_ONCE and SkOnce(), which you can use 15 // SkOnce.h defines SK_DECLARE_STATIC_ONCE and SkOnce(), which you can use
16 // together to create a threadsafe way to call a function just once. E.g. 16 // together to create a threadsafe way to call a function just once. E.g.
17 // 17 //
18 // static void register_my_stuff(GlobalRegistry* registry) { 18 // static void register_my_stuff(GlobalRegistry* registry) {
19 // registry->register(...); 19 // registry->register(...);
20 // } 20 // }
21 // ... 21 // ...
22 // void EnsureRegistered() { 22 // void EnsureRegistered() {
23 // SK_DECLARE_STATIC_ONCE(once); 23 // SK_DECLARE_STATIC_ONCE(once);
24 // SkOnce(&once, register_my_stuff, GetGlobalRegistry()); 24 // SkOnce(&once, register_my_stuff, GetGlobalRegistry());
25 // } 25 // }
26 // 26 //
27 // No matter how many times you call EnsureRegistered(), register_my_stuff will be called just once. 27 // No matter how many times you call EnsureRegistered(), register_my_stuff will be called just once.
28 // OnceTest.cpp also should serve as a few other simple examples. 28 // OnceTest.cpp also should serve as a few other simple examples.
29 29
30 #include "SkAtomics.h" 30 #include "../private/SkAtomics.h"
31 #include "SkSpinlock.h" 31 #include "SkSpinlock.h"
32 32
33 // This must be used in a global scope, not in function scope or as a class memb er. 33 // This must be used in a global scope, not in function scope or as a class memb er.
34 #define SK_DECLARE_STATIC_ONCE(name) namespace {} static SkOnceFlag name 34 #define SK_DECLARE_STATIC_ONCE(name) namespace {} static SkOnceFlag name
35 35
36 class SkOnceFlag; 36 class SkOnceFlag;
37 37
38 inline void SkOnce(SkOnceFlag* once, void (*f)()); 38 inline void SkOnce(SkOnceFlag* once, void (*f)());
39 39
40 template <typename Arg> 40 template <typename Arg>
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 inline void SkOnce(SkOnceFlag* once, void (*func)()) { 130 inline void SkOnce(SkOnceFlag* once, void (*func)()) {
131 return SkOnce(once, sk_once_no_arg_adaptor, func); 131 return SkOnce(once, sk_once_no_arg_adaptor, func);
132 } 132 }
133 133
134 template <typename Lock> 134 template <typename Lock>
135 inline void SkOnce(bool* done, Lock* lock, void (*func)()) { 135 inline void SkOnce(bool* done, Lock* lock, void (*func)()) {
136 return SkOnce(done, lock, sk_once_no_arg_adaptor, func); 136 return SkOnce(done, lock, sk_once_no_arg_adaptor, func);
137 } 137 }
138 138
139 #endif // SkOnce_DEFINED 139 #endif // SkOnce_DEFINED
OLDNEW
« no previous file with comments | « include/core/SkAtomics.h ('k') | include/core/SkPixelRef.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698