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();