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

Unified Diff: src/core/SkMessageBus.h

Issue 304383005: Port most uses of SkOnce to SkLazyPtr. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add mutex Created 6 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/core/SkMatrix.cpp ('k') | src/core/SkPathRef.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkMessageBus.h
diff --git a/src/core/SkMessageBus.h b/src/core/SkMessageBus.h
index ddeac57ac12d2ac5ff6b9e871eb555167cfbb601..f36c42b4c7bc93f230e2a38bee33b13ab040151e 100644
--- a/src/core/SkMessageBus.h
+++ b/src/core/SkMessageBus.h
@@ -8,7 +8,7 @@
#ifndef SkMessageBus_DEFINED
#define SkMessageBus_DEFINED
-#include "SkOnce.h"
+#include "SkLazyPtr.h"
#include "SkTDArray.h"
#include "SkThread.h"
#include "SkTypes.h"
@@ -38,7 +38,7 @@ public:
private:
SkMessageBus();
static SkMessageBus* Get();
- static void New(SkMessageBus**);
+ static SkMessageBus* New();
SkTDArray<Inbox*> fInboxes;
SkMutex fInboxesMutex;
@@ -46,14 +46,11 @@ private:
// This must go in a single .cpp file, not some .h, or we risk creating more than one global
// SkMessageBus per type when using shared libraries.
-#define DECLARE_SKMESSAGEBUS_MESSAGE(Message) \
- template <> \
- SkMessageBus<Message>* SkMessageBus<Message>::Get() { \
- static SkMessageBus<Message>* bus = NULL; \
- SK_DECLARE_STATIC_ONCE(once); \
- SkOnce(&once, &New, &bus); \
- SkASSERT(bus != NULL); \
- return bus; \
+#define DECLARE_SKMESSAGEBUS_MESSAGE(Message) \
+ template <> \
+ SkMessageBus<Message>* SkMessageBus<Message>::Get() { \
+ SK_DECLARE_STATIC_LAZY_PTR(SkMessageBus<Message>, bus, New); \
+ return bus.get(); \
}
// ----------------------- Implementation of SkMessageBus::Inbox -----------------------
@@ -100,8 +97,8 @@ template <typename Message>
SkMessageBus<Message>::SkMessageBus() {}
template <typename Message>
-/*static*/ void SkMessageBus<Message>::New(SkMessageBus<Message>** bus) {
- *bus = new SkMessageBus<Message>();
+/*static*/ SkMessageBus<Message>* SkMessageBus<Message>::New() {
+ return SkNEW(SkMessageBus<Message>);
}
template <typename Message>
« no previous file with comments | « src/core/SkMatrix.cpp ('k') | src/core/SkPathRef.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698