Index: include/private/SkOncePtr.h |
diff --git a/include/private/SkOncePtr.h b/include/private/SkOncePtr.h |
index 3c1ab634ee4397d747cebf7fcfbfb616b189f1fb..b60d968b4a4ef7825d16c558cbaf822206f94abe 100644 |
--- a/include/private/SkOncePtr.h |
+++ b/include/private/SkOncePtr.h |
@@ -66,8 +66,9 @@ public: |
if (state == 0) { |
// It looks like no one has tried to create our pointer yet. |
// We try to claim that task by atomically swapping our state from '0' to '1'. |
+ // See SkOnce.h for why we use an acquire memory order here rather than relaxed. |
if (sk_atomic_compare_exchange( |
- &fState, &state, (uintptr_t)1, sk_memory_order_relaxed, sk_memory_order_relaxed)) { |
+ &fState, &state, (uintptr_t)1, sk_memory_order_acquire, sk_memory_order_acquire)) { |
// We've claimed it. Create our pointer and store it into fState. |
state = (uintptr_t)f(); |
SkASSERT(state > 1); |