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

Unified Diff: src/core/SkMessageBus.h

Issue 651723003: Require SK_DECLARE_STATIC_LAZY_PTR is used in global scope. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: safe unref Created 6 years, 2 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/SkLazyPtr.h ('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 1290ea965f9c133faaf25037a85cf2061742a293..a005c3b9dfadd1c121397f979c9eec9aacdfb6e1 100644
--- a/src/core/SkMessageBus.h
+++ b/src/core/SkMessageBus.h
@@ -38,19 +38,21 @@ public:
private:
SkMessageBus();
static SkMessageBus* Get();
- static SkMessageBus* New();
+
+ // Allow SkLazyPtr to call SkMessageBus::SkMessageBus().
+ template <typename T> friend T* Private::sk_new();
SkTDArray<Inbox*> fInboxes;
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() { \
- SK_DECLARE_STATIC_LAZY_PTR(SkMessageBus<Message>, bus, New); \
- return bus.get(); \
+// SkMessageBus per type when using shared libraries. NOTE: at most one per file will compile.
+#define DECLARE_SKMESSAGEBUS_MESSAGE(Message) \
+ SK_DECLARE_STATIC_LAZY_PTR(SkMessageBus<Message>, bus); \
+ template <> \
+ SkMessageBus<Message>* SkMessageBus<Message>::Get() { \
+ return bus.get(); \
}
// ----------------------- Implementation of SkMessageBus::Inbox -----------------------
@@ -97,11 +99,6 @@ template <typename Message>
SkMessageBus<Message>::SkMessageBus() {}
template <typename Message>
-/*static*/ SkMessageBus<Message>* SkMessageBus<Message>::New() {
- return SkNEW(SkMessageBus<Message>);
-}
-
-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 | « src/core/SkLazyPtr.h ('k') | src/core/SkPathRef.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698