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

Side by Side Diff: include/core/SkAtomics.h

Issue 908943002: Port SkLazyPtr to new SkAtomics.h (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: includes Created 5 years, 10 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 | « no previous file | include/core/SkLazyPtr.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 #ifndef SkAtomics_DEFINED 1 #ifndef SkAtomics_DEFINED
2 #define SkAtomics_DEFINED 2 #define SkAtomics_DEFINED
3 3
4 // This file is not part of the public Skia API. 4 // This file is not part of the public Skia API.
5 #include "SkTypes.h" 5 #include "SkTypes.h"
6 6
7 enum sk_memory_order { 7 enum sk_memory_order {
8 sk_memory_order_relaxed, 8 sk_memory_order_relaxed,
9 sk_memory_order_consume, 9 sk_memory_order_consume,
10 sk_memory_order_acquire, 10 sk_memory_order_acquire,
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 break; 60 break;
61 } 61 }
62 } while(!sk_atomic_compare_exchange(ptr, &prev, prev+1)); 62 } while(!sk_atomic_compare_exchange(ptr, &prev, prev+1));
63 return prev; 63 return prev;
64 } 64 }
65 65
66 template <typename T> 66 template <typename T>
67 T sk_acquire_load(T* ptr) { return sk_atomic_load(ptr, sk_memory_order_acquire); } 67 T sk_acquire_load(T* ptr) { return sk_atomic_load(ptr, sk_memory_order_acquire); }
68 68
69 template <typename T> 69 template <typename T>
70 T sk_consume_load(T* ptr) {
71 // On every platform we care about, consume is the same as relaxed.
72 // If we pass consume here, some compilers turn that into acquire, which is overkill.
73 return sk_atomic_load(ptr, sk_memory_order_relaxed);
74 }
75
76 template <typename T>
77 void sk_release_store(T* ptr, T val) { sk_atomic_store(ptr, val, sk_memory_order _release); } 70 void sk_release_store(T* ptr, T val) { sk_atomic_store(ptr, val, sk_memory_order _release); }
78 71
79 inline void sk_membar_acquire__after_atomic_dec() {} 72 inline void sk_membar_acquire__after_atomic_dec() {}
80 inline void sk_membar_acquire__after_atomic_conditional_inc() {} 73 inline void sk_membar_acquire__after_atomic_conditional_inc() {}
81 74
82 #endif//SkAtomics_DEFINED 75 #endif//SkAtomics_DEFINED
OLDNEW
« no previous file with comments | « no previous file | include/core/SkLazyPtr.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698