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

Side by Side Diff: webrtc/base/messagequeue.cc

Issue 2680233002: Use fake clock in some more networks tests. (Closed)
Patch Set: Use a different fake clock thing. Created 3 years, 10 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 unified diff | Download patch
« no previous file with comments | « webrtc/base/messagequeue.h ('k') | webrtc/base/signalthread.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 #include <algorithm> 10 #include <algorithm>
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 } 139 }
140 ~ScopedIncrement() override { AtomicOps::Decrement(value_); } 140 ~ScopedIncrement() override { AtomicOps::Decrement(value_); }
141 141
142 private: 142 private:
143 volatile int* value_; 143 volatile int* value_;
144 }; 144 };
145 145
146 { 146 {
147 DebugNonReentrantCritScope cs(&crit_, &locked_); 147 DebugNonReentrantCritScope cs(&crit_, &locked_);
148 for (MessageQueue* queue : message_queues_) { 148 for (MessageQueue* queue : message_queues_) {
149 if (queue->IsQuitting()) { 149 if (!queue->IsProcessingMessages()) {
150 // If the queue is quitting, it's done processing messages so it can 150 // If the queue is not processing messages, it can
151 // be ignored. If we tried to post a message to it, it would be dropped. 151 // be ignored. If we tried to post a message to it, it would be dropped
152 // or ignored.
152 continue; 153 continue;
153 } 154 }
154 queue->PostDelayed(RTC_FROM_HERE, 0, nullptr, MQID_DISPOSE, 155 queue->PostDelayed(RTC_FROM_HERE, 0, nullptr, MQID_DISPOSE,
155 new ScopedIncrement(&queues_not_done)); 156 new ScopedIncrement(&queues_not_done));
156 } 157 }
157 } 158 }
158 // Note: One of the message queues may have been on this thread, which is why 159 // Note: One of the message queues may have been on this thread, which is why
159 // we can't synchronously wait for queues_not_done to go to 0; we need to 160 // we can't synchronously wait for queues_not_done to go to 0; we need to
160 // process messages as well. 161 // process messages as well.
161 while (AtomicOps::AcquireLoad(&queues_not_done) > 0) { 162 while (AtomicOps::AcquireLoad(&queues_not_done) > 0) {
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 245
245 void MessageQueue::Quit() { 246 void MessageQueue::Quit() {
246 AtomicOps::ReleaseStore(&stop_, 1); 247 AtomicOps::ReleaseStore(&stop_, 1);
247 WakeUpSocketServer(); 248 WakeUpSocketServer();
248 } 249 }
249 250
250 bool MessageQueue::IsQuitting() { 251 bool MessageQueue::IsQuitting() {
251 return AtomicOps::AcquireLoad(&stop_) != 0; 252 return AtomicOps::AcquireLoad(&stop_) != 0;
252 } 253 }
253 254
255 bool MessageQueue::IsProcessingMessages() {
256 return !IsQuitting();
257 }
258
254 void MessageQueue::Restart() { 259 void MessageQueue::Restart() {
255 AtomicOps::ReleaseStore(&stop_, 0); 260 AtomicOps::ReleaseStore(&stop_, 0);
256 } 261 }
257 262
258 bool MessageQueue::Peek(Message *pmsg, int cmsWait) { 263 bool MessageQueue::Peek(Message *pmsg, int cmsWait) {
259 if (fPeekKeep_) { 264 if (fPeekKeep_) {
260 *pmsg = msgPeek_; 265 *pmsg = msgPeek_;
261 return true; 266 return true;
262 } 267 }
263 if (!Get(pmsg, cmsWait)) 268 if (!Get(pmsg, cmsWait))
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 pmsg->phandler->OnMessage(pmsg); 538 pmsg->phandler->OnMessage(pmsg);
534 int64_t end_time = TimeMillis(); 539 int64_t end_time = TimeMillis();
535 int64_t diff = TimeDiff(end_time, start_time); 540 int64_t diff = TimeDiff(end_time, start_time);
536 if (diff >= kSlowDispatchLoggingThreshold) { 541 if (diff >= kSlowDispatchLoggingThreshold) {
537 LOG(LS_INFO) << "Message took " << diff << "ms to dispatch. Posted from: " 542 LOG(LS_INFO) << "Message took " << diff << "ms to dispatch. Posted from: "
538 << pmsg->posted_from.ToString(); 543 << pmsg->posted_from.ToString();
539 } 544 }
540 } 545 }
541 546
542 } // namespace rtc 547 } // namespace rtc
OLDNEW
« no previous file with comments | « webrtc/base/messagequeue.h ('k') | webrtc/base/signalthread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698