Index: src/core/SkMessageBus.h |
diff --git a/src/core/SkMessageBus.h b/src/core/SkMessageBus.h |
index f36c42b4c7bc93f230e2a38bee33b13ab040151e..ddeac57ac12d2ac5ff6b9e871eb555167cfbb601 100644 |
--- a/src/core/SkMessageBus.h |
+++ b/src/core/SkMessageBus.h |
@@ -8,7 +8,7 @@ |
#ifndef SkMessageBus_DEFINED |
#define SkMessageBus_DEFINED |
-#include "SkLazyPtr.h" |
+#include "SkOnce.h" |
#include "SkTDArray.h" |
#include "SkThread.h" |
#include "SkTypes.h" |
@@ -38,7 +38,7 @@ |
private: |
SkMessageBus(); |
static SkMessageBus* Get(); |
- static SkMessageBus* New(); |
+ static void New(SkMessageBus**); |
SkTDArray<Inbox*> fInboxes; |
SkMutex fInboxesMutex; |
@@ -46,11 +46,14 @@ |
// 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() { \ |
- SK_DECLARE_STATIC_LAZY_PTR(SkMessageBus<Message>, bus, New); \ |
- return bus.get(); \ |
+#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; \ |
} |
// ----------------------- Implementation of SkMessageBus::Inbox ----------------------- |
@@ -97,8 +100,8 @@ |
SkMessageBus<Message>::SkMessageBus() {} |
template <typename Message> |
-/*static*/ SkMessageBus<Message>* SkMessageBus<Message>::New() { |
- return SkNEW(SkMessageBus<Message>); |
+/*static*/ void SkMessageBus<Message>::New(SkMessageBus<Message>** bus) { |
+ *bus = new SkMessageBus<Message>(); |
} |
template <typename Message> |