Let a RepeatingTask stop itself by returning a delay of PlusInfinity.
Bug: none Change-Id: I5bf87e236019d156ffe85c5b91ce09f5f4042937 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/247160 Reviewed-by: Evan Shrubsole <eshr@webrtc.org> Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org> Commit-Queue: Niels Moller <nisse@webrtc.org> Cr-Commit-Position: refs/heads/main@{#35710}
This commit is contained in:
committed by
WebRTC LUCI CQ
parent
46cc32d89f
commit
902b55457a
@ -38,13 +38,14 @@ bool RepeatingTaskBase::Run() {
|
||||
return true;
|
||||
|
||||
TimeDelta delay = RunClosure();
|
||||
RTC_DCHECK_GE(delay, TimeDelta::Zero());
|
||||
|
||||
// The closure might have stopped this task, in which case we return true to
|
||||
// destruct this object.
|
||||
if (!alive_flag_->alive())
|
||||
// A delay of +infinity means that the task should not be run again.
|
||||
// Alternatively, the closure might have stopped this task. In either which
|
||||
// case we return true to destruct this object.
|
||||
if (delay.IsPlusInfinity() || !alive_flag_->alive())
|
||||
return true;
|
||||
|
||||
RTC_DCHECK(delay.IsFinite());
|
||||
TimeDelta lost_time = clock_->CurrentTime() - next_run_time_;
|
||||
next_run_time_ += delay;
|
||||
delay -= lost_time;
|
||||
|
||||
Reference in New Issue
Block a user