TimeController: Rename Sleep to AdvanceTime.
This change renames TimeController's Sleep method to AdvanceTime, unifying
the same name with the same semantic as for downstream projects.
Bug: webrtc:11154
Change-Id: Id79bcf0eafcd0b47a76407ba220479d84df5a736
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/161092
Commit-Queue: Markus Handell <handellm@webrtc.org>
Reviewed-by: Per Kjellander <perkj@webrtc.org>
Reviewed-by: Erik Språng <sprang@webrtc.org>
Reviewed-by: Sebastian Jansson <srte@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#29989}
diff --git a/api/test/time_controller.h b/api/test/time_controller.h
index 4723716..616622b 100644
--- a/api/test/time_controller.h
+++ b/api/test/time_controller.h
@@ -39,7 +39,7 @@
const char* thread_name) = 0;
// Allow task queues and process threads created by this instance to execute
// for the given |duration|.
- virtual void Sleep(TimeDelta duration) = 0;
+ virtual void AdvanceTime(TimeDelta duration) = 0;
// Execute closure in an implementation defined scope where rtc::Event::Wait
// might yield to execute other tasks. This allows doing blocking waits on
// tasks on other task queues froma a task queue without deadlocking.
diff --git a/call/rtp_video_sender_unittest.cc b/call/rtp_video_sender_unittest.cc
index 8ea4124..8190eea 100644
--- a/call/rtp_video_sender_unittest.cc
+++ b/call/rtp_video_sender_unittest.cc
@@ -160,7 +160,7 @@
RtpVideoSender* router() { return router_.get(); }
MockTransport& transport() { return transport_; }
- void AdvanceTime(TimeDelta delta) { time_controller_.Sleep(delta); }
+ void AdvanceTime(TimeDelta delta) { time_controller_.AdvanceTime(delta); }
private:
NiceMock<MockTransport> transport_;
diff --git a/modules/pacing/task_queue_paced_sender_unittest.cc b/modules/pacing/task_queue_paced_sender_unittest.cc
index 390523f..0c3a092 100644
--- a/modules/pacing/task_queue_paced_sender_unittest.cc
+++ b/modules/pacing/task_queue_paced_sender_unittest.cc
@@ -123,7 +123,7 @@
// Packets should be sent over a period of close to 1s. Expect a little lower
// than this since initial probing is a bit quicker.
- time_controller_.Sleep(TimeDelta::seconds(1));
+ time_controller_.AdvanceTime(TimeDelta::seconds(1));
EXPECT_EQ(packets_sent, kPacketsToSend);
ASSERT_TRUE(end_time.IsFinite());
EXPECT_NEAR((end_time - start_time).ms<double>(), 1000.0, 50.0);
@@ -140,7 +140,7 @@
EXPECT_CALL(packet_router_, SendPacket).Times(kPacketsPerSecond);
pacer_.EnqueuePackets(
GeneratePackets(RtpPacketToSend::Type::kVideo, kPacketsPerSecond));
- time_controller_.Sleep(TimeDelta::seconds(1));
+ time_controller_.AdvanceTime(TimeDelta::seconds(1));
// Insert three packets, and record send time of each of them.
// After the second packet is sent, double the send rate so we can
@@ -164,7 +164,7 @@
});
pacer_.EnqueuePackets(GeneratePackets(RtpPacketToSend::Type::kVideo, 3));
- time_controller_.Sleep(TimeDelta::ms(500));
+ time_controller_.AdvanceTime(TimeDelta::ms(500));
ASSERT_TRUE(third_packet_time.IsFinite());
EXPECT_NEAR((second_packet_time - first_packet_time).ms<double>(), 200.0,
1.0);
diff --git a/test/frame_generator_capturer_unittest.cc b/test/frame_generator_capturer_unittest.cc
index 9886b2a..7f91011 100644
--- a/test/frame_generator_capturer_unittest.cc
+++ b/test/frame_generator_capturer_unittest.cc
@@ -39,7 +39,7 @@
capturer->Start();
EXPECT_CALL(mock_sink, OnFrame(Property(&VideoFrame::width, Eq(300))))
.Times(20);
- time.Sleep(TimeDelta::seconds(1));
+ time.AdvanceTime(TimeDelta::seconds(1));
}
} // namespace test
} // namespace webrtc
diff --git a/test/network/cross_traffic_unittest.cc b/test/network/cross_traffic_unittest.cc
index 94a2dff..148ad09 100644
--- a/test/network/cross_traffic_unittest.cc
+++ b/test/network/cross_traffic_unittest.cc
@@ -141,10 +141,10 @@
// If there was no loss, we would have delivered the message in ca 1 second,
// with 50% it should take much longer.
- time.Sleep(TimeDelta::seconds(5));
+ time.AdvanceTime(TimeDelta::seconds(5));
ASSERT_EQ(deliver_count, 0);
// But given enough time the messsage will be delivered, but only once.
- time.Sleep(TimeDelta::seconds(60));
+ time.AdvanceTime(TimeDelta::seconds(60));
EXPECT_EQ(deliver_count, 1);
}
diff --git a/test/network/feedback_generator.cc b/test/network/feedback_generator.cc
index d9386c8..3ae6fb2 100644
--- a/test/network/feedback_generator.cc
+++ b/test/network/feedback_generator.cc
@@ -32,7 +32,7 @@
}
void FeedbackGeneratorImpl::Sleep(TimeDelta duration) {
- time_controller_.Sleep(duration);
+ time_controller_.AdvanceTime(duration);
}
void FeedbackGeneratorImpl::SendPacket(size_t size) {
diff --git a/test/scenario/scenario.cc b/test/scenario/scenario.cc
index 605d0e2..29a9cea 100644
--- a/test/scenario/scenario.cc
+++ b/test/scenario/scenario.cc
@@ -272,7 +272,7 @@
void Scenario::RunFor(TimeDelta duration) {
if (start_time_.IsInfinite())
Start();
- time_controller_->Sleep(duration);
+ time_controller_->AdvanceTime(duration);
}
void Scenario::RunUntil(TimeDelta target_time_since_start) {
@@ -285,11 +285,11 @@
if (start_time_.IsInfinite())
Start();
while (check_interval >= TimeUntilTarget(target_time_since_start)) {
- time_controller_->Sleep(check_interval);
+ time_controller_->AdvanceTime(check_interval);
if (exit_function())
return;
}
- time_controller_->Sleep(TimeUntilTarget(target_time_since_start));
+ time_controller_->AdvanceTime(TimeUntilTarget(target_time_since_start));
}
void Scenario::Start() {
diff --git a/test/time_controller/external_time_controller.cc b/test/time_controller/external_time_controller.cc
index 543b4e0..51e5641 100644
--- a/test/time_controller/external_time_controller.cc
+++ b/test/time_controller/external_time_controller.cc
@@ -178,7 +178,7 @@
this, impl_.CreateProcessThread(thread_name));
}
-void ExternalTimeController::Sleep(TimeDelta duration) {
+void ExternalTimeController::AdvanceTime(TimeDelta duration) {
alarm_->Sleep(duration);
}
diff --git a/test/time_controller/external_time_controller.h b/test/time_controller/external_time_controller.h
index c9b1287..3ae302e 100644
--- a/test/time_controller/external_time_controller.h
+++ b/test/time_controller/external_time_controller.h
@@ -37,7 +37,7 @@
TaskQueueFactory* GetTaskQueueFactory() override;
std::unique_ptr<ProcessThread> CreateProcessThread(
const char* thread_name) override;
- void Sleep(TimeDelta duration) override;
+ void AdvanceTime(TimeDelta duration) override;
void InvokeWithControlledYield(std::function<void()> closure) override;
rtc::YieldInterface* YieldInterface() override;
diff --git a/test/time_controller/external_time_controller_unittest.cc b/test/time_controller/external_time_controller_unittest.cc
index 95a07d9..b0b09cb 100644
--- a/test/time_controller/external_time_controller_unittest.cc
+++ b/test/time_controller/external_time_controller_unittest.cc
@@ -98,7 +98,7 @@
return kShortInterval;
});
// Sleep long enough to go through the initial phase.
- time_simulation.Sleep(kShortInterval * (kShortIntervalCount + kMargin));
+ time_simulation.AdvanceTime(kShortInterval * (kShortIntervalCount + kMargin));
EXPECT_EQ(counter.load(), kShortIntervalCount);
task_queue.PostTask(
@@ -106,7 +106,7 @@
// Sleep long enough that the task would run at least once more if not
// stopped.
- time_simulation.Sleep(kLongInterval * 2);
+ time_simulation.AdvanceTime(kLongInterval * 2);
EXPECT_EQ(counter.load(), kShortIntervalCount);
}
@@ -126,7 +126,7 @@
return TimeDelta::ms(2);
});
});
- time_simulation.Sleep(TimeDelta::ms(10));
+ time_simulation.AdvanceTime(TimeDelta::ms(10));
EXPECT_EQ(counter.load(), 1);
}
@@ -162,7 +162,7 @@
EXPECT_TRUE(event.Wait(200));
});
- time_simulation.Sleep(TimeDelta::ms(300));
+ time_simulation.AdvanceTime(TimeDelta::ms(300));
}
TEST(ExternalTimeControllerTest, CurrentTaskQueue) {
@@ -175,7 +175,7 @@
task_queue.PostTask([&] { EXPECT_TRUE(task_queue.IsCurrent()); });
- time_simulation.Sleep(TimeDelta::ms(10));
+ time_simulation.AdvanceTime(TimeDelta::ms(10));
}
} // namespace webrtc
diff --git a/test/time_controller/real_time_controller.cc b/test/time_controller/real_time_controller.cc
index f9948eb..0494bc0 100644
--- a/test/time_controller/real_time_controller.cc
+++ b/test/time_controller/real_time_controller.cc
@@ -30,7 +30,7 @@
return ProcessThread::Create(thread_name);
}
-void RealTimeController::Sleep(TimeDelta duration) {
+void RealTimeController::AdvanceTime(TimeDelta duration) {
SleepMs(duration.ms());
}
diff --git a/test/time_controller/real_time_controller.h b/test/time_controller/real_time_controller.h
index 20e6ff3..58d7682 100644
--- a/test/time_controller/real_time_controller.h
+++ b/test/time_controller/real_time_controller.h
@@ -28,7 +28,7 @@
TaskQueueFactory* GetTaskQueueFactory() override;
std::unique_ptr<ProcessThread> CreateProcessThread(
const char* thread_name) override;
- void Sleep(TimeDelta duration) override;
+ void AdvanceTime(TimeDelta duration) override;
void InvokeWithControlledYield(std::function<void()> closure) override;
rtc::YieldInterface* YieldInterface() override;
diff --git a/test/time_controller/simulated_time_controller.cc b/test/time_controller/simulated_time_controller.cc
index 5064501..c2c135a 100644
--- a/test/time_controller/simulated_time_controller.cc
+++ b/test/time_controller/simulated_time_controller.cc
@@ -418,7 +418,7 @@
return impl_.CreateProcessThread(thread_name);
}
-void GlobalSimulatedTimeController::Sleep(TimeDelta duration) {
+void GlobalSimulatedTimeController::AdvanceTime(TimeDelta duration) {
rtc::ScopedYieldPolicy yield_policy(&impl_);
Timestamp current_time = impl_.CurrentTime();
Timestamp target_time = current_time + duration;
diff --git a/test/time_controller/simulated_time_controller.h b/test/time_controller/simulated_time_controller.h
index a580202..919b858 100644
--- a/test/time_controller/simulated_time_controller.h
+++ b/test/time_controller/simulated_time_controller.h
@@ -78,9 +78,9 @@
// TimeController implementation using completely simulated time. Task queues
// and process threads created by this controller will run delayed activities
-// when Sleep() is called. Overrides the global clock backing rtc::TimeMillis()
-// and rtc::TimeMicros(). Note that this is not thread safe since it modifies
-// global state.
+// when AdvanceTime() is called. Overrides the global clock backing
+// rtc::TimeMillis() and rtc::TimeMicros(). Note that this is not thread safe
+// since it modifies global state.
class GlobalSimulatedTimeController : public TimeController {
public:
explicit GlobalSimulatedTimeController(Timestamp start_time);
@@ -90,7 +90,7 @@
TaskQueueFactory* GetTaskQueueFactory() override;
std::unique_ptr<ProcessThread> CreateProcessThread(
const char* thread_name) override;
- void Sleep(TimeDelta duration) override;
+ void AdvanceTime(TimeDelta duration) override;
void InvokeWithControlledYield(std::function<void()> closure) override;
rtc::YieldInterface* YieldInterface() override;
diff --git a/test/time_controller/simulated_time_controller_unittest.cc b/test/time_controller/simulated_time_controller_unittest.cc
index 5fc9443..be640dd 100644
--- a/test/time_controller/simulated_time_controller_unittest.cc
+++ b/test/time_controller/simulated_time_controller_unittest.cc
@@ -46,7 +46,7 @@
return kShortInterval;
});
// Sleep long enough to go through the initial phase.
- time_simulation.Sleep(kShortInterval * (kShortIntervalCount + kMargin));
+ time_simulation.AdvanceTime(kShortInterval * (kShortIntervalCount + kMargin));
EXPECT_EQ(counter.load(), kShortIntervalCount);
task_queue.PostTask(
@@ -54,7 +54,7 @@
// Sleep long enough that the task would run at least once more if not
// stopped.
- time_simulation.Sleep(kLongInterval * 2);
+ time_simulation.AdvanceTime(kLongInterval * 2);
EXPECT_EQ(counter.load(), kShortIntervalCount);
}
@@ -73,7 +73,7 @@
return TimeDelta::ms(2);
});
});
- time_simulation.Sleep(TimeDelta::ms(10));
+ time_simulation.AdvanceTime(TimeDelta::ms(10));
EXPECT_EQ(counter.load(), 1);
}
TEST(SimulatedTimeControllerTest, Example) {
diff --git a/video/BUILD.gn b/video/BUILD.gn
index 68cee87..6c8565b 100644
--- a/video/BUILD.gn
+++ b/video/BUILD.gn
@@ -647,7 +647,7 @@
"../test:test_common",
"../test:test_support",
"../test:video_test_common",
- "../test/time_controller:time_controller",
+ "../test/time_controller",
"//testing/gtest",
"//third_party/abseil-cpp/absl/algorithm:container",
"//third_party/abseil-cpp/absl/memory",
diff --git a/video/video_receive_stream_unittest.cc b/video/video_receive_stream_unittest.cc
index 2da7f12..b6c4200 100644
--- a/video/video_receive_stream_unittest.cc
+++ b/video/video_receive_stream_unittest.cc
@@ -536,13 +536,13 @@
EXPECT_CALL(mock_transport_, SendRtcp).Times(1);
video_receive_stream_.GenerateKeyFrame();
PassEncodedFrameAndWait(MakeFrame(VideoFrameType::kVideoFrameDelta, 0));
- time_controller_.Sleep(tick);
+ time_controller_.AdvanceTime(tick);
PassEncodedFrameAndWait(MakeFrame(VideoFrameType::kVideoFrameDelta, 1));
testing::Mock::VerifyAndClearExpectations(&mock_transport_);
// T+200ms: still no key frame received, expect key frame request sent again.
EXPECT_CALL(mock_transport_, SendRtcp).Times(1);
- time_controller_.Sleep(tick);
+ time_controller_.AdvanceTime(tick);
PassEncodedFrameAndWait(MakeFrame(VideoFrameType::kVideoFrameDelta, 2));
testing::Mock::VerifyAndClearExpectations(&mock_transport_);
@@ -550,7 +550,7 @@
// requests after this.
EXPECT_CALL(mock_transport_, SendRtcp).Times(0);
PassEncodedFrameAndWait(MakeFrame(VideoFrameType::kVideoFrameKey, 3));
- time_controller_.Sleep(2 * tick);
+ time_controller_.AdvanceTime(2 * tick);
PassEncodedFrameAndWait(MakeFrame(VideoFrameType::kVideoFrameDelta, 4));
}