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

Unified Diff: webrtc/base/fakeclock.cc

Issue 2024813004: 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: Fixing another TSan warning. WebRtcSession wasn't completely shut down. 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
Index: webrtc/base/fakeclock.cc
diff --git a/webrtc/base/fakeclock.cc b/webrtc/base/fakeclock.cc
index e5aa3bc0a4fc3af0aecd8e58b395c54ce48f0d41..bcd720ff742f2687f6c0bb05c5e60672edec6314 100644
--- a/webrtc/base/fakeclock.cc
+++ b/webrtc/base/fakeclock.cc
@@ -27,14 +27,24 @@ void FakeClock::SetTimeNanos(uint64_t nanos) {
time_ = nanos;
}
// If message queues are waiting in a socket select() with a timeout provided
- // by the OS, they should wake up to check if there are any messages ready to
- // be dispatched based on the fake time.
- MessageQueueManager::WakeAllMessageQueues();
+ // by the OS, they should wake up and dispatch all messages that are ready.
+ MessageQueueManager::ProcessAllMessageQueues();
}
void FakeClock::AdvanceTime(TimeDelta delta) {
- CritScope cs(&lock_);
- SetTimeNanos(time_ + delta.ToNanoseconds());
+ {
+ CritScope cs(&lock_);
+ time_ += delta.ToNanoseconds();
+ }
+ MessageQueueManager::ProcessAllMessageQueues();
+}
+
+ScopedFakeClock::ScopedFakeClock() {
+ prev_clock_ = SetClockForTesting(this);
+}
+
+ScopedFakeClock::~ScopedFakeClock() {
+ SetClockForTesting(prev_clock_);
nisse-webrtc 2016/06/08 09:47:30 I think it's simpler to only ever allow one fake c
}
} // namespace rtc
« no previous file with comments | « webrtc/base/fakeclock.h ('k') | webrtc/base/gunit.h » ('j') | webrtc/base/timeutils.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698