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

Side by Side Diff: include/private/SkOncePtr.h

Issue 1311893010: Specialize SkOncePtr<T[]>. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 3 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/SkColorTable.h ('k') | src/core/SkColorTable.cpp » ('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 2015 Google Inc. 2 * Copyright 2015 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 SkOncePtr_DEFINED 8 #ifndef SkOncePtr_DEFINED
9 #define SkOncePtr_DEFINED 9 #define SkOncePtr_DEFINED
10 10
(...skipping 22 matching lines...) Expand all
33 } 33 }
34 34
35 operator T*() const { 35 operator T*() const {
36 return (T*)fOnce; 36 return (T*)fOnce;
37 } 37 }
38 38
39 private: 39 private:
40 SkBaseOncePtr<T> fOnce; 40 SkBaseOncePtr<T> fOnce;
41 }; 41 };
42 42
43 // If you ask for SkOncePtr<T[]>, we'll clean up with delete[] by default.
44 template <typename T>
45 class SkOncePtr<T[]> : public SkOncePtr<T, skstd::default_delete<T[]>> {};
46
43 /* TODO(mtklein): in next CL 47 /* TODO(mtklein): in next CL
44 typedef SkBaseOncePtr<void> SkOnceFlag; 48 typedef SkBaseOncePtr<void> SkOnceFlag;
45 #define SK_DECLARE_STATIC_ONCE(name) namespace {} static SkOnceFlag name 49 #define SK_DECLARE_STATIC_ONCE(name) namespace {} static SkOnceFlag name
46 50
47 template <typename F> 51 template <typename F>
48 inline void SkOnce(SkOnceFlag* once, const F& f) { 52 inline void SkOnce(SkOnceFlag* once, const F& f) {
49 once->get([&]{ f(); return (void*)2; }); 53 once->get([&]{ f(); return (void*)2; });
50 } 54 }
51 */ 55 */
52 56
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 } 98 }
95 99
96 private: 100 private:
97 // fState == 0 --> we have not created our ptr yet 101 // fState == 0 --> we have not created our ptr yet
98 // fState == 1 --> someone is in the middle of creating our ptr 102 // fState == 1 --> someone is in the middle of creating our ptr
99 // else --> (T*)fState is our ptr 103 // else --> (T*)fState is our ptr
100 mutable SkAtomic<uintptr_t> fState; 104 mutable SkAtomic<uintptr_t> fState;
101 }; 105 };
102 106
103 #endif//SkOncePtr_DEFINED 107 #endif//SkOncePtr_DEFINED
OLDNEW
« no previous file with comments | « include/core/SkColorTable.h ('k') | src/core/SkColorTable.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698