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

Unified Diff: webrtc/base/messagequeue.cc

Issue 1895933003: Adding the ability to use a simulated clock for unit tests. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fixing compile warning. Created 4 years, 7 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 | « webrtc/base/messagequeue.h ('k') | webrtc/base/timedelta.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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)
« no previous file with comments | « webrtc/base/messagequeue.h ('k') | webrtc/base/timedelta.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698