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

Unified Diff: src/core/SkMessageBus.h

Issue 140053002: move SkMessageBus::Get out of header (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: obsolete Created 6 years, 11 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 | « no previous file | src/gpu/GrResourceCache.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 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);
« no previous file with comments | « no previous file | src/gpu/GrResourceCache.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698