Chromium Code Reviews| 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 |