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

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

Issue 806473006: namespace {} trick for SK_DECLARE_STATIC_ONCE (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 11 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
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
(...skipping 13 matching lines...) Expand all
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 "SkDynamicAnnotations.h" 30 #include "SkDynamicAnnotations.h"
31 #include "SkThread.h" 31 #include "SkThread.h"
32 #include "SkTypes.h" 32 #include "SkTypes.h"
33 33
34 // This must be used in a global or function scope, not as a class member. 34 // This must be used in a global scope, not in fuction scope or as a class membe r.
35 #define SK_DECLARE_STATIC_ONCE(name) static SkOnceFlag name 35 #define SK_DECLARE_STATIC_ONCE(name) namespace {} static SkOnceFlag name
36 36
37 class SkOnceFlag; 37 class SkOnceFlag;
38 38
39 inline void SkOnce(SkOnceFlag* once, void (*f)()); 39 inline void SkOnce(SkOnceFlag* once, void (*f)());
40 40
41 template <typename Arg> 41 template <typename Arg>
42 inline void SkOnce(SkOnceFlag* once, void (*f)(Arg), Arg arg); 42 inline void SkOnce(SkOnceFlag* once, void (*f)(Arg), Arg arg);
43 43
44 // If you've already got a lock and a flag to use, this variant lets you avoid a n extra SkOnceFlag. 44 // If you've already got a lock and a flag to use, this variant lets you avoid a n extra SkOnceFlag.
45 template <typename Lock> 45 template <typename Lock>
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 inline void SkOnce(SkOnceFlag* once, void (*func)()) { 135 inline void SkOnce(SkOnceFlag* once, void (*func)()) {
136 return SkOnce(once, sk_once_no_arg_adaptor, func); 136 return SkOnce(once, sk_once_no_arg_adaptor, func);
137 } 137 }
138 138
139 template <typename Lock> 139 template <typename Lock>
140 inline void SkOnce(bool* done, Lock* lock, void (*func)()) { 140 inline void SkOnce(bool* done, Lock* lock, void (*func)()) {
141 return SkOnce(done, lock, sk_once_no_arg_adaptor, func); 141 return SkOnce(done, lock, sk_once_no_arg_adaptor, func);
142 } 142 }
143 143
144 #endif // SkOnce_DEFINED 144 #endif // SkOnce_DEFINED
OLDNEW
« no previous file with comments | « no previous file | src/ports/SkGlobalInitialization_chromium.cpp » ('j') | src/utils/win/SkDWrite.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698