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

Side by Side Diff: src/utils/SkEventTracer.cpp

Issue 1091283006: use acquire/release in SkEventTracer.cpp (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Created 5 years, 8 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 | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkAtomics.h" 8 #include "SkAtomics.h"
9 #include "SkEventTracer.h" 9 #include "SkEventTracer.h"
10 #include "SkLazyPtr.h" 10 #include "SkLazyPtr.h"
(...skipping 23 matching lines...) Expand all
34 const uint8_t* categoryEnabledFlag) override { 34 const uint8_t* categoryEnabledFlag) override {
35 static const char* dummy = "dummy"; 35 static const char* dummy = "dummy";
36 return dummy; 36 return dummy;
37 }; 37 };
38 }; 38 };
39 39
40 // We prefer gUserTracer if it's been set, otherwise we fall back on gDefaultTra cer. 40 // We prefer gUserTracer if it's been set, otherwise we fall back on gDefaultTra cer.
41 static SkEventTracer* gUserTracer = nullptr; 41 static SkEventTracer* gUserTracer = nullptr;
42 SK_DECLARE_STATIC_LAZY_PTR(SkDefaultEventTracer, gDefaultTracer); 42 SK_DECLARE_STATIC_LAZY_PTR(SkDefaultEventTracer, gDefaultTracer);
43 43
44 // We can use relaxed memory order for gUserTracer loads and stores.
45 // It's not guarding anything but itself.
46
47 void SkEventTracer::SetInstance(SkEventTracer* tracer) { 44 void SkEventTracer::SetInstance(SkEventTracer* tracer) {
48 SkASSERT(nullptr == sk_atomic_load(&gUserTracer, sk_memory_order_relaxed)); 45 SkASSERT(nullptr == sk_atomic_load(&gUserTracer, sk_memory_order_acquire));
Alexander Potapenko 2015/04/22 17:47:50 I may be mistaking, but this one can be demoted to
mtklein 2015/04/22 18:56:24 Yeah, seemed simpler to keep it all as _acquire so
49 sk_atomic_store(&gUserTracer, tracer, sk_memory_order_relaxed); 46 sk_atomic_store(&gUserTracer, tracer, sk_memory_order_release);
50 // An atomic load during process shutdown is probably overkill, but safe ove rkill. 47 // An atomic load during process shutdown is probably overkill, but safe ove rkill.
51 atexit([](){ SkDELETE(sk_atomic_load(&gUserTracer, sk_memory_order_relaxed)) ; }); 48 atexit([](){ SkDELETE(sk_atomic_load(&gUserTracer, sk_memory_order_acquire)) ; });
52 } 49 }
53 50
54 SkEventTracer* SkEventTracer::GetInstance() { 51 SkEventTracer* SkEventTracer::GetInstance() {
55 if (SkEventTracer* tracer = sk_atomic_load(&gUserTracer, sk_memory_order_rel axed)) { 52 if (SkEventTracer* tracer = sk_atomic_load(&gUserTracer, sk_memory_order_acq uire)) {
56 return tracer; 53 return tracer;
57 } 54 }
58 return gDefaultTracer.get(); 55 return gDefaultTracer.get();
59 } 56 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698