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

Unified Diff: include/ports/SkAtomics_std.h

Issue 1039323002: Extract the spinlock from SkOnce as SkSpinlock. (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: quotes Created 5 years, 9 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
Index: include/ports/SkAtomics_std.h
diff --git a/include/ports/SkAtomics_std.h b/include/ports/SkAtomics_std.h
index e89d74981c449c228899419591c717fb3077155f..4c26858dfda4b0b22be881b3be7b37b05a9e2d26 100644
--- a/include/ports/SkAtomics_std.h
+++ b/include/ports/SkAtomics_std.h
@@ -1,3 +1,10 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
#ifndef SkAtomics_std_DEFINED
#define SkAtomics_std_DEFINED
@@ -47,4 +54,11 @@ bool sk_atomic_compare_exchange(T* ptr, T* expected, T desired,
(std::memory_order)failure);
}
+template <typename T>
+T sk_atomic_exchange(T* ptr, T val, sk_memory_order mo) {
+ // All values of mo are valid.
+ std::atomic<T>* ap = reinterpret_cast<std::atomic<T>*>(ptr);
+ return std::atomic_exchange_explicit(ap, val, (std::memory_order)mo);
+}
+
#endif//SkAtomics_std_DEFINED

Powered by Google App Engine
This is Rietveld 408576698