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

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

Issue 1867863002: Convert SkRefCnt to std::atomic. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Restore to 1. Created 4 years, 8 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/private/SkAtomics.h ('k') | include/private/SkWeakRefCnt.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
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 f(arg); 76 f(arg);
77 // Also known as a store-store/load-store barrier, this makes sure that the writes 77 // Also known as a store-store/load-store barrier, this makes sure that the writes
78 // done before here---in particular, those done by calling f(arg)---are observable 78 // done before here---in particular, those done by calling f(arg)---are observable
79 // before the writes after the line, *done = true. 79 // before the writes after the line, *done = true.
80 // 80 //
81 // In version control terms this is like saying, "check in the work up 81 // In version control terms this is like saying, "check in the work up
82 // to and including f(arg), then check in *done=true as a subsequent cha nge". 82 // to and including f(arg), then check in *done=true as a subsequent cha nge".
83 // 83 //
84 // We'll use this in the fast path to make sure f(arg)'s effects are 84 // We'll use this in the fast path to make sure f(arg)'s effects are
85 // observable whenever we observe *done == true. 85 // observable whenever we observe *done == true.
86 sk_release_store(done, true); 86 sk_atomic_store(done, true, sk_memory_order_release);
87 } 87 }
88 lock->release(); 88 lock->release();
89 } 89 }
90 90
91 // This is our fast path, called all the time. We do really want it to be inlin ed. 91 // This is our fast path, called all the time. We do really want it to be inlin ed.
92 template <typename Lock, typename Arg> 92 template <typename Lock, typename Arg>
93 inline void SkOnce(bool* done, Lock* lock, void (*f)(Arg), Arg arg) { 93 inline void SkOnce(bool* done, Lock* lock, void (*f)(Arg), Arg arg) {
94 // When *done == true: 94 // When *done == true:
95 // Also known as a load-load/load-store barrier, this acquire barrier make s 95 // Also known as a load-load/load-store barrier, this acquire barrier make s
96 // sure that anything we read from memory---in particular, memory written by 96 // sure that anything we read from memory---in particular, memory written by
(...skipping 33 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/private/SkAtomics.h ('k') | include/private/SkWeakRefCnt.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698