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:
@ -20,7 +20,6 @@
|
||||
#include "api/units/time_delta.h"
|
||||
#include "api/units/timestamp.h"
|
||||
#include "rtc_base/synchronization/sequence_checker.h"
|
||||
#include "rtc_base/thread_checker.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
@ -31,18 +30,25 @@ class RepeatingTaskBase : public QueuedTask {
|
||||
public:
|
||||
RepeatingTaskBase(TaskQueueBase* task_queue, TimeDelta first_delay);
|
||||
~RepeatingTaskBase() override;
|
||||
virtual TimeDelta RunClosure() = 0;
|
||||
|
||||
void Stop();
|
||||
|
||||
private:
|
||||
friend class ::webrtc::RepeatingTaskHandle;
|
||||
virtual TimeDelta RunClosure() = 0;
|
||||
|
||||
bool Run() final;
|
||||
void Stop() RTC_RUN_ON(task_queue_);
|
||||
|
||||
TaskQueueBase* const task_queue_;
|
||||
// This is always finite, except for the special case where it's PlusInfinity
|
||||
// to signal that the task should stop.
|
||||
Timestamp next_run_time_ RTC_GUARDED_BY(task_queue_);
|
||||
Timestamp next_run_time_ RTC_GUARDED_BY(sequence_checker_);
|
||||
// We use a SequenceChecker to check for correct usage instead of using
|
||||
// RTC_DCHECK_RUN_ON(task_queue_). This is to work around a compatibility
|
||||
// issue with some TQ implementations such as rtc::Thread that don't
|
||||
// consistently set themselves as the 'current' TQ when running tasks.
|
||||
// The SequenceChecker detects those implementations differently but gives
|
||||
// the same effect as far as thread safety goes.
|
||||
SequenceChecker sequence_checker_;
|
||||
};
|
||||
|
||||
// The template closure pattern is based on rtc::ClosureTask.
|
||||
@ -61,9 +67,9 @@ class RepeatingTaskImpl final : public RepeatingTaskBase {
|
||||
"");
|
||||
}
|
||||
|
||||
private:
|
||||
TimeDelta RunClosure() override { return closure_(); }
|
||||
|
||||
private:
|
||||
typename std::remove_const<
|
||||
typename std::remove_reference<Closure>::type>::type closure_;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user