| 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 SkOnce_DEFINED |    8 #ifndef SkOnce_DEFINED | 
|    9 #define SkOnce_DEFINED |    9 #define SkOnce_DEFINED | 
|   10  |   10  | 
| (...skipping 11 matching lines...) Expand all  Loading... | 
|   22 //     SkOnce(&once, set_up_my_singleton, &singleton); |   22 //     SkOnce(&once, set_up_my_singleton, &singleton); | 
|   23 //     SkASSERT(NULL != singleton); |   23 //     SkASSERT(NULL != singleton); | 
|   24 //     return *singleton; |   24 //     return *singleton; | 
|   25 // } |   25 // } | 
|   26 // |   26 // | 
|   27 // OnceTest.cpp also should serve as a few other simple examples. |   27 // OnceTest.cpp also should serve as a few other simple examples. | 
|   28 // |   28 // | 
|   29 // You may optionally pass SkOnce a second function to be called at exit for cle
     anup. |   29 // You may optionally pass SkOnce a second function to be called at exit for cle
     anup. | 
|   30  |   30  | 
|   31 #include "SkDynamicAnnotations.h" |   31 #include "SkDynamicAnnotations.h" | 
|   32 #include "SkThread.h" |  | 
|   33 #include "SkTypes.h" |   32 #include "SkTypes.h" | 
|   34  |   33  | 
 |   34 #include "../../src/core/SkThread.h" | 
 |   35  | 
|   35 #define SK_ONCE_INIT { false, { 0, SkDEBUGCODE(0) } } |   36 #define SK_ONCE_INIT { false, { 0, SkDEBUGCODE(0) } } | 
|   36 #define SK_DECLARE_STATIC_ONCE(name) static SkOnceFlag name = SK_ONCE_INIT |   37 #define SK_DECLARE_STATIC_ONCE(name) static SkOnceFlag name = SK_ONCE_INIT | 
|   37  |   38  | 
|   38 struct SkOnceFlag;  // If manually created, initialize with SkOnceFlag once = SK
     _ONCE_INIT |   39 struct SkOnceFlag;  // If manually created, initialize with SkOnceFlag once = SK
     _ONCE_INIT | 
|   39  |   40  | 
|   40 template <typename Func, typename Arg> |   41 template <typename Func, typename Arg> | 
|   41 inline void SkOnce(SkOnceFlag* once, Func f, Arg arg, void(*atExit)() = NULL); |   42 inline void SkOnce(SkOnceFlag* once, Func f, Arg arg, void(*atExit)() = NULL); | 
|   42  |   43  | 
|   43 // 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. | 
|   44 template <typename Lock, typename Func, typename Arg> |   45 template <typename Lock, typename Func, typename Arg> | 
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  168 } |  169 } | 
|  169  |  170  | 
|  170 template <typename Func, typename Arg> |  171 template <typename Func, typename Arg> | 
|  171 inline void SkOnce(SkOnceFlag* once, Func f, Arg arg, void(*atExit)()) { |  172 inline void SkOnce(SkOnceFlag* once, Func f, Arg arg, void(*atExit)()) { | 
|  172     return SkOnce(&once->done, &once->lock, f, arg, atExit); |  173     return SkOnce(&once->done, &once->lock, f, arg, atExit); | 
|  173 } |  174 } | 
|  174  |  175  | 
|  175 #undef SK_ANNOTATE_BENIGN_RACE |  176 #undef SK_ANNOTATE_BENIGN_RACE | 
|  176  |  177  | 
|  177 #endif  // SkOnce_DEFINED |  178 #endif  // SkOnce_DEFINED | 
| OLD | NEW |