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> |