OLD | NEW |
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 Loading... |
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 |
OLD | NEW |