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

Unified Diff: include/core/SkAtomics.h

Issue 1193493003: Modernize atomics in SkTaskGroup's threadpool. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/core/SkTaskGroup.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkAtomics.h
diff --git a/include/core/SkAtomics.h b/include/core/SkAtomics.h
index 9866db4860cea31df1289391748e23bb7288cc58..be94164227b789c43899cabd38c94d6fe8e3e050 100644
--- a/include/core/SkAtomics.h
+++ b/include/core/SkAtomics.h
@@ -43,6 +43,7 @@ template <typename T>
class SkAtomic : SkNoncopyable {
public:
SkAtomic() {}
+ explicit SkAtomic(const T& val) : fVal(val) {}
// It is essential we return by value rather than by const&. fVal may change at any time.
T load(sk_memory_order mo = sk_memory_order_seq_cst) const {
@@ -53,6 +54,10 @@ public:
sk_atomic_store(&fVal, val, mo);
}
+ T fetch_add(const T& val, sk_memory_order mo = sk_memory_order_seq_cst) {
+ return sk_atomic_fetch_add(&fVal, val, mo);
+ }
+
bool compare_exchange(T* expected, const T& desired,
sk_memory_order success = sk_memory_order_seq_cst,
sk_memory_order failure = sk_memory_order_seq_cst) {
« no previous file with comments | « no previous file | src/core/SkTaskGroup.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698