Add ability to specify delayed task precision in RepeatingTaskHandle.

See go/postdelayedtask-precision-in-webrtc for context of which use
cases are considered "high" or "low". Most use cases are "low" which
is the default, but this CL allows opting in to "high".

Will be used by FrameBuffer2.

Bug: webrtc:13604
Change-Id: Iebf6eea44779873e78746da749a39e1101b92819
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/248861
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Commit-Queue: Henrik Boström <hbos@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35776}
This commit is contained in:
Henrik Boström
2022-01-24 17:12:35 +01:00
committed by WebRTC LUCI CQ
parent 6f542d5e92
commit 27e8a095bf
4 changed files with 125 additions and 10 deletions

View File

@ -21,10 +21,12 @@ namespace webrtc_repeating_task_impl {
RepeatingTaskBase::RepeatingTaskBase(
TaskQueueBase* task_queue,
TaskQueueBase::DelayPrecision precision,
TimeDelta first_delay,
Clock* clock,
rtc::scoped_refptr<PendingTaskSafetyFlag> alive_flag)
: task_queue_(task_queue),
precision_(precision),
clock_(clock),
next_run_time_(clock_->CurrentTime() + first_delay),
alive_flag_(std::move(alive_flag)) {}
@ -51,7 +53,8 @@ bool RepeatingTaskBase::Run() {
delay -= lost_time;
delay = std::max(delay, TimeDelta::Zero());
task_queue_->PostDelayedTask(absl::WrapUnique(this), delay.ms());
task_queue_->PostDelayedTaskWithPrecision(precision_, absl::WrapUnique(this),
delay.ms());
// Return false to tell the TaskQueue to not destruct this object since we
// have taken ownership with absl::WrapUnique.