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

Side by Side Diff: include/ports/SkAtomics_std.h

Issue 1327703003: Revert of Parallel cache - preliminary (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/ports/SkAtomics_atomic.h ('k') | include/ports/SkAtomics_sync.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 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 SkAtomics_std_DEFINED 8 #ifndef SkAtomics_std_DEFINED
9 #define SkAtomics_std_DEFINED 9 #define SkAtomics_std_DEFINED
10 10
(...skipping 21 matching lines...) Expand all
32 } 32 }
33 33
34 template <typename T> 34 template <typename T>
35 T sk_atomic_fetch_add(T* ptr, T val, sk_memory_order mo) { 35 T sk_atomic_fetch_add(T* ptr, T val, sk_memory_order mo) {
36 // All values of mo are valid. 36 // All values of mo are valid.
37 std::atomic<T>* ap = reinterpret_cast<std::atomic<T>*>(ptr); 37 std::atomic<T>* ap = reinterpret_cast<std::atomic<T>*>(ptr);
38 return std::atomic_fetch_add_explicit(ap, val, (std::memory_order)mo); 38 return std::atomic_fetch_add_explicit(ap, val, (std::memory_order)mo);
39 } 39 }
40 40
41 template <typename T> 41 template <typename T>
42 T sk_atomic_fetch_sub(T* ptr, T val, sk_memory_order mo) {
43 // All values of mo are valid.
44 std::atomic<T>* ap = reinterpret_cast<std::atomic<T>*>(ptr);
45 return std::atomic_fetch_sub_explicit(ap, val, (std::memory_order)mo);
46 }
47
48 template <typename T>
49 bool sk_atomic_compare_exchange(T* ptr, T* expected, T desired, 42 bool sk_atomic_compare_exchange(T* ptr, T* expected, T desired,
50 sk_memory_order success, 43 sk_memory_order success,
51 sk_memory_order failure) { 44 sk_memory_order failure) {
52 // All values of success are valid. 45 // All values of success are valid.
53 SkASSERT(failure == sk_memory_order_relaxed || 46 SkASSERT(failure == sk_memory_order_relaxed ||
54 failure == sk_memory_order_seq_cst || 47 failure == sk_memory_order_seq_cst ||
55 failure == sk_memory_order_acquire || 48 failure == sk_memory_order_acquire ||
56 failure == sk_memory_order_consume); 49 failure == sk_memory_order_consume);
57 SkASSERT(failure <= success); 50 SkASSERT(failure <= success);
58 std::atomic<T>* ap = reinterpret_cast<std::atomic<T>*>(ptr); 51 std::atomic<T>* ap = reinterpret_cast<std::atomic<T>*>(ptr);
59 return std::atomic_compare_exchange_strong_explicit(ap, expected, desired, 52 return std::atomic_compare_exchange_strong_explicit(ap, expected, desired,
60 (std::memory_order)succe ss, 53 (std::memory_order)succe ss,
61 (std::memory_order)failu re); 54 (std::memory_order)failu re);
62 } 55 }
63 56
64 template <typename T> 57 template <typename T>
65 T sk_atomic_exchange(T* ptr, T val, sk_memory_order mo) { 58 T sk_atomic_exchange(T* ptr, T val, sk_memory_order mo) {
66 // All values of mo are valid. 59 // All values of mo are valid.
67 std::atomic<T>* ap = reinterpret_cast<std::atomic<T>*>(ptr); 60 std::atomic<T>* ap = reinterpret_cast<std::atomic<T>*>(ptr);
68 return std::atomic_exchange_explicit(ap, val, (std::memory_order)mo); 61 return std::atomic_exchange_explicit(ap, val, (std::memory_order)mo);
69 } 62 }
70 63
71 #endif//SkAtomics_std_DEFINED 64 #endif//SkAtomics_std_DEFINED
OLDNEW
« no previous file with comments | « include/ports/SkAtomics_atomic.h ('k') | include/ports/SkAtomics_sync.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698