Index: webrtc/base/messagequeue.cc |
diff --git a/webrtc/base/messagequeue.cc b/webrtc/base/messagequeue.cc |
index 84fdaf1a95ae3858dfaa1ab2873d0b552685da02..da50e2304f7a686af4245df733566528d279d185 100644 |
--- a/webrtc/base/messagequeue.cc |
+++ b/webrtc/base/messagequeue.cc |
@@ -15,6 +15,11 @@ |
#include "webrtc/base/messagequeue.h" |
#include "webrtc/base/trace_event.h" |
+namespace { |
+ |
+enum { MSG_WAKE_MESSAGE_QUEUE = 1 }; |
+} |
+ |
namespace rtc { |
const int kMaxMsgLatency = 150; // 150 ms |
@@ -103,6 +108,28 @@ void MessageQueueManager::ClearInternal(MessageHandler *handler) { |
(*iter)->Clear(handler); |
} |
+void MessageQueueManager::WakeAllMessageQueues() { |
+ if (!instance_) { |
+ return; |
+ } |
+ return Instance()->WakeAllMessageQueuesInternal(); |
+} |
+ |
+void MessageQueueManager::WakeAllMessageQueuesInternal() { |
+#if CS_DEBUG_CHECKS // CurrentThreadIsOwner returns true by default. |
+ ASSERT(!crit_.CurrentThreadIsOwner()); // See note above. |
+#endif |
+ CritScope cs(&crit_); |
+ for (MessageQueue* queue : message_queues_) { |
+ // Posting an arbitrary message will force the message queue to wake up. |
+ queue->Post(this, MSG_WAKE_MESSAGE_QUEUE); |
+ } |
+} |
+ |
+void MessageQueueManager::OnMessage(Message* pmsg) { |
+ RTC_DCHECK(pmsg->message_id == MSG_WAKE_MESSAGE_QUEUE); |
+} |
+ |
//------------------------------------------------------------------ |
// MessageQueue |
MessageQueue::MessageQueue(SocketServer* ss, bool init_queue) |