From 743be194eda4c1f37c4a5f62f38ef88f09f30649 Mon Sep 17 00:00:00 2001 From: mtklein Date: Wed, 22 Apr 2015 20:30:12 -0700 Subject: [PATCH] use acquire/release in SkEventTracer.cpp BUG=chromium:437044 Review URL: https://codereview.chromium.org/1091283006 --- src/utils/SkEventTracer.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/utils/SkEventTracer.cpp b/src/utils/SkEventTracer.cpp index 1a669a3f8e..b114c21c8f 100644 --- a/src/utils/SkEventTracer.cpp +++ b/src/utils/SkEventTracer.cpp @@ -41,18 +41,15 @@ class SkDefaultEventTracer : public SkEventTracer { static SkEventTracer* gUserTracer = nullptr; SK_DECLARE_STATIC_LAZY_PTR(SkDefaultEventTracer, gDefaultTracer); -// We can use relaxed memory order for gUserTracer loads and stores. -// It's not guarding anything but itself. - void SkEventTracer::SetInstance(SkEventTracer* tracer) { - SkASSERT(nullptr == sk_atomic_load(&gUserTracer, sk_memory_order_relaxed)); - sk_atomic_store(&gUserTracer, tracer, sk_memory_order_relaxed); + SkASSERT(nullptr == sk_atomic_load(&gUserTracer, sk_memory_order_acquire)); + sk_atomic_store(&gUserTracer, tracer, sk_memory_order_release); // An atomic load during process shutdown is probably overkill, but safe overkill. - atexit([](){ SkDELETE(sk_atomic_load(&gUserTracer, sk_memory_order_relaxed)); }); + atexit([](){ SkDELETE(sk_atomic_load(&gUserTracer, sk_memory_order_acquire)); }); } SkEventTracer* SkEventTracer::GetInstance() { - if (SkEventTracer* tracer = sk_atomic_load(&gUserTracer, sk_memory_order_relaxed)) { + if (SkEventTracer* tracer = sk_atomic_load(&gUserTracer, sk_memory_order_acquire)) { return tracer; } return gDefaultTracer.get();