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

Unified Diff: webrtc/base/messagequeue.cc

Issue 2038213002: Revert of Improving the fake clock and using it to fix a flaky STUN timeout test. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 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
« no previous file with comments | « webrtc/base/messagequeue.h ('k') | webrtc/base/signalthread_unittest.cc » ('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 4c2331bfe603c17cfd5c5376e85ef591bbcacb4d..da50e2304f7a686af4245df733566528d279d185 100644
--- a/webrtc/base/messagequeue.cc
+++ b/webrtc/base/messagequeue.cc
@@ -9,13 +9,16 @@
*/
#include <algorithm>
-#include "webrtc/base/atomicops.h"
#include "webrtc/base/checks.h"
#include "webrtc/base/common.h"
#include "webrtc/base/logging.h"
#include "webrtc/base/messagequeue.h"
-#include "webrtc/base/thread.h"
#include "webrtc/base/trace_event.h"
+
+namespace {
+
+enum { MSG_WAKE_MESSAGE_QUEUE = 1 };
+}
namespace rtc {
@@ -38,7 +41,8 @@
return instance_ != NULL;
}
-MessageQueueManager::MessageQueueManager() {}
+MessageQueueManager::MessageQueueManager() {
+}
MessageQueueManager::~MessageQueueManager() {
}
@@ -104,36 +108,26 @@
(*iter)->Clear(handler);
}
-void MessageQueueManager::ProcessAllMessageQueues() {
+void MessageQueueManager::WakeAllMessageQueues() {
if (!instance_) {
return;
}
- return Instance()->ProcessAllMessageQueuesInternal();
-}
-
-void MessageQueueManager::ProcessAllMessageQueuesInternal() {
+ return Instance()->WakeAllMessageQueuesInternal();
+}
+
+void MessageQueueManager::WakeAllMessageQueuesInternal() {
#if CS_DEBUG_CHECKS // CurrentThreadIsOwner returns true by default.
ASSERT(!crit_.CurrentThreadIsOwner()); // See note above.
#endif
- // Post a delayed message at the current time and wait for it to be dispatched
- // on all queues, which will ensure that all messages that came before it were
- // also dispatched.
- volatile int queues_not_done;
- auto functor = [&queues_not_done] { AtomicOps::Decrement(&queues_not_done); };
- FunctorMessageHandler<void, decltype(functor)> handler(functor);
- {
- CritScope cs(&crit_);
- queues_not_done = static_cast<int>(message_queues_.size());
- for (MessageQueue* queue : message_queues_) {
- queue->PostDelayed(0, &handler);
- }
- }
- // Note: One of the message queues may have been on this thread, which is why
- // we can't synchronously wait for queues_not_done to go to 0; we need to
- // process messages as well.
- while (AtomicOps::AcquireLoad(&queues_not_done) > 0) {
- rtc::Thread::Current()->ProcessMessages(0);
- }
+ 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);
}
//------------------------------------------------------------------
« no previous file with comments | « webrtc/base/messagequeue.h ('k') | webrtc/base/signalthread_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698