Migrate CallStats and RtpStreamsSynchronizer timers over to RepeatingTask

Bug: none
Change-Id: Ib49a3de74c6d3a6d4ea158383a5e4b69a1e58ab9
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/175000
Reviewed-by: Sebastian Jansson <srte@webrtc.org>
Commit-Queue: Tommi <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31252}
This commit is contained in:
Tommi
2020-05-13 18:27:26 +02:00
committed by Commit Bot
parent 6ee67936bd
commit a0a4480f12
8 changed files with 55 additions and 77 deletions

View File

@ -20,12 +20,14 @@ namespace webrtc_repeating_task_impl {
RepeatingTaskBase::RepeatingTaskBase(TaskQueueBase* task_queue,
TimeDelta first_delay)
: task_queue_(task_queue),
next_run_time_(Timestamp::Micros(rtc::TimeMicros()) + first_delay) {}
next_run_time_(Timestamp::Micros(rtc::TimeMicros()) + first_delay) {
sequence_checker_.Detach();
}
RepeatingTaskBase::~RepeatingTaskBase() = default;
bool RepeatingTaskBase::Run() {
RTC_DCHECK_RUN_ON(task_queue_);
RTC_DCHECK_RUN_ON(&sequence_checker_);
// Return true to tell the TaskQueue to destruct this object.
if (next_run_time_.IsPlusInfinity())
return true;
@ -51,6 +53,7 @@ bool RepeatingTaskBase::Run() {
}
void RepeatingTaskBase::Stop() {
RTC_DCHECK_RUN_ON(&sequence_checker_);
RTC_DCHECK(next_run_time_.IsFinite());
next_run_time_ = Timestamp::PlusInfinity();
}
@ -75,7 +78,6 @@ RepeatingTaskHandle::RepeatingTaskHandle(
void RepeatingTaskHandle::Stop() {
if (repeating_task_) {
RTC_DCHECK_RUN_ON(repeating_task_->task_queue_);
repeating_task_->Stop();
repeating_task_ = nullptr;
}