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

Unified Diff: webrtc/test/fake_network_pipe.cc

Issue 2718343002: Make FakeNetworkPipe not busy loop any more. (Closed)
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/test/fake_network_pipe.cc
diff --git a/webrtc/test/fake_network_pipe.cc b/webrtc/test/fake_network_pipe.cc
index d594ab8104e3b6d7b0499b85415732544ae3b40d..8f2fee6c2c154eb63e192f8536d54f7717ff404f 100644
--- a/webrtc/test/fake_network_pipe.cc
+++ b/webrtc/test/fake_network_pipe.cc
@@ -23,6 +23,10 @@
namespace webrtc {
+namespace {
+constexpr int64_t kDefaultProcessIntervalMs = 5;
+}
+
FakeNetworkPipe::FakeNetworkPipe(Clock* clock,
const FakeNetworkPipe::Config& config)
: FakeNetworkPipe(clock, config, 1) {}
@@ -175,8 +179,6 @@ void FakeNetworkPipe::Process() {
(*delay_link_.rbegin())->arrival_time() - packet->arrival_time();
}
packet->IncrementArrivalTime(arrival_time_jitter);
- if (packet->arrival_time() < next_process_time_)
- next_process_time_ = packet->arrival_time();
delay_link_.insert(packet);
}
@@ -201,13 +203,14 @@ void FakeNetworkPipe::Process() {
packet->data_length(), PacketTime());
delete packet;
}
+
+ next_process_time_ = !delay_link_.empty()
+ ? (*delay_link_.begin())->arrival_time()
+ : time_now + kDefaultProcessIntervalMs;
}
int64_t FakeNetworkPipe::TimeUntilNextProcess() const {
rtc::CritScope crit(&lock_);
- const int64_t kDefaultProcessIntervalMs = 5;
- if (capacity_link_.empty() || delay_link_.empty())
- return kDefaultProcessIntervalMs;
return std::max<int64_t>(next_process_time_ - clock_->TimeInMilliseconds(),
0);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698