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

Unified Diff: webrtc/base/messagequeue.cc

Issue 2915253002: Delete SignalThread class. (Closed)
Patch Set: Implement Destroy logic, using new method MessageQueue::PostFunctor. Created 3 years, 6 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
Index: webrtc/base/messagequeue.cc
diff --git a/webrtc/base/messagequeue.cc b/webrtc/base/messagequeue.cc
index cafb70bd002faaf3241db5f9f4633b70767cb887..95d2045a4a00c8247c55a05355e57d93da37a3f7 100644
--- a/webrtc/base/messagequeue.cc
+++ b/webrtc/base/messagequeue.cc
@@ -44,6 +44,18 @@ class SCOPED_LOCKABLE DebugNonReentrantCritScope {
RTC_DISALLOW_COPY_AND_ASSIGN(DebugNonReentrantCritScope);
};
+
+class FunctorPostMessageHandler : public MessageHandler {
+ public:
+ void OnMessage(Message* msg) override;
+};
+
+void FunctorPostMessageHandler::OnMessage(Message* msg) {
+ CallableData* data = static_cast<CallableData*>(msg->pdata);
+ data->call();
+ delete data;
+}
kwiberg-webrtc 2017/06/26 13:07:48 Define this function inline? There's no downside t
nisse-webrtc 2017/06/27 08:27:17 Done.
+
} // namespace
//------------------------------------------------------------------
@@ -529,4 +541,12 @@ void MessageQueue::Dispatch(Message *pmsg) {
}
}
+void MessageQueue::PostFunctorInternal(const Location& posted_from,
+ CallableData* message_data)
+{
tommi 2017/06/27 12:01:14 can you run git cl format?
nisse-webrtc 2017/06/28 11:47:54 Already done, in ps#14.
+ // FunctorPostMessageHandler keeps no state, create a static object.
+ RTC_DEFINE_STATIC_LOCAL(FunctorPostMessageHandler, handler, ());
kwiberg-webrtc 2017/06/26 13:07:48 Why not just FunctorPostMessageHandler handler;
nisse-webrtc 2017/06/27 08:27:17 It has to outlive this scope, since it's accessed
kwiberg-webrtc 2017/06/27 09:16:28 Ah, right, it has a vtable. But yes, as of C++11,
nisse-webrtc 2017/06/28 11:47:54 Good. But it still has to be in a local scope? (If
+ Post(posted_from, &handler, 0, message_data);
+}
+
} // namespace rtc

Powered by Google App Engine
This is Rietveld 408576698