Index: webrtc/rtc_base/messagequeue.cc |
diff --git a/webrtc/rtc_base/messagequeue.cc b/webrtc/rtc_base/messagequeue.cc |
index cafb70bd002faaf3241db5f9f4633b70767cb887..fce1906a41e0d5c5db6c07e0c5c4bd07ccf30cf8 100644 |
--- a/webrtc/rtc_base/messagequeue.cc |
+++ b/webrtc/rtc_base/messagequeue.cc |
@@ -44,6 +44,16 @@ class SCOPED_LOCKABLE DebugNonReentrantCritScope { |
RTC_DISALLOW_COPY_AND_ASSIGN(DebugNonReentrantCritScope); |
}; |
+ |
+class FunctorPostMessageHandler : public MessageHandler { |
+ public: |
+ void OnMessage(Message* msg) override { |
+ RunnableData* data = static_cast<RunnableData*>(msg->pdata); |
+ data->Run(); |
+ delete data; |
+ } |
+}; |
+ |
} // namespace |
//------------------------------------------------------------------ |
@@ -529,4 +539,12 @@ void MessageQueue::Dispatch(Message *pmsg) { |
} |
} |
+void MessageQueue::PostFunctorInternal(const Location& posted_from, |
+ RunnableData* message_data) { |
+ // Use static to ensure it outlives this scope. Safe since |
+ // FunctorPostMessageHandler keeps no state. |
+ static FunctorPostMessageHandler handler; |
+ Post(posted_from, &handler, 0, message_data); |
+} |
+ |
} // namespace rtc |