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

Unified Diff: src/utils/SkEventTracer.cpp

Issue 1953533002: SkOncePtr -> SkOnce (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: hide sk_num_cores() Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/ports/SkFontHost_mac.cpp ('k') | tests/OncePtrTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/utils/SkEventTracer.cpp
diff --git a/src/utils/SkEventTracer.cpp b/src/utils/SkEventTracer.cpp
index 32a0207c23ebaa0f3d0ac9edd7a29688a67c0e23..0a748d1464d70f9d30ac9d66f5909ad798cb2a2d 100644
--- a/src/utils/SkEventTracer.cpp
+++ b/src/utils/SkEventTracer.cpp
@@ -7,7 +7,7 @@
#include "SkAtomics.h"
#include "SkEventTracer.h"
-#include "SkOncePtr.h"
+#include "SkOnce.h"
#include <stdlib.h>
@@ -39,9 +39,8 @@ class SkDefaultEventTracer : public SkEventTracer {
}
};
-// We prefer gUserTracer if it's been set, otherwise we fall back on gDefaultTracer.
+// We prefer gUserTracer if it's been set, otherwise we fall back on a default tracer;
static SkEventTracer* gUserTracer = nullptr;
-SK_DECLARE_STATIC_ONCE_PTR(SkDefaultEventTracer, gDefaultTracer);
void SkEventTracer::SetInstance(SkEventTracer* tracer) {
SkASSERT(nullptr == sk_atomic_load(&gUserTracer, sk_memory_order_acquire));
@@ -54,5 +53,8 @@ SkEventTracer* SkEventTracer::GetInstance() {
if (SkEventTracer* tracer = sk_atomic_load(&gUserTracer, sk_memory_order_acquire)) {
return tracer;
}
- return gDefaultTracer.get([]{ return new SkDefaultEventTracer; });
+ static SkOnce once;
+ static SkDefaultEventTracer* defaultTracer;
+ once([] { defaultTracer = new SkDefaultEventTracer; });
+ return defaultTracer;
}
« no previous file with comments | « src/ports/SkFontHost_mac.cpp ('k') | tests/OncePtrTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698