| Index: src/core/SkMessageBus.h
|
| diff --git a/src/core/SkMessageBus.h b/src/core/SkMessageBus.h
|
| index 0a408319c15ef197c4cfbf02398d7168e1cae813..ddeac57ac12d2ac5ff6b9e871eb555167cfbb601 100644
|
| --- a/src/core/SkMessageBus.h
|
| +++ b/src/core/SkMessageBus.h
|
| @@ -44,6 +44,18 @@ private:
|
| SkMutex fInboxesMutex;
|
| };
|
|
|
| +// 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; \
|
| + }
|
| +
|
| // ----------------------- Implementation of SkMessageBus::Inbox -----------------------
|
|
|
| template<typename Message>
|
| @@ -93,17 +105,6 @@ template <typename Message>
|
| }
|
|
|
| template <typename Message>
|
| -/*static*/ SkMessageBus<Message>* SkMessageBus<Message>::Get() {
|
| - // The first time this method is called, create the singleton bus for this message type.
|
| - static SkMessageBus<Message>* bus = NULL;
|
| - SK_DECLARE_STATIC_ONCE(once);
|
| - SkOnce(&once, &New, &bus);
|
| -
|
| - SkASSERT(bus != NULL);
|
| - return bus;
|
| -}
|
| -
|
| -template <typename Message>
|
| /*static*/ void SkMessageBus<Message>::Post(const Message& m) {
|
| SkMessageBus<Message>* bus = SkMessageBus<Message>::Get();
|
| SkAutoMutexAcquire lock(bus->fInboxesMutex);
|
|
|