Reland "Revert back to using the task_queue_ for guarding access."
This reverts commit af1b9ceb62dce3462083f9a44e26ee6d79639cef.
Reason for revert: Speculative reland after looking into downstream
failures. It's possible that carryover state from unrelated tests
running in parallel was causing failures.
Original change's description:
> Revert "Revert back to using the task_queue_ for guarding access."
>
> This reverts commit 475006d4a30f8bc47f82eb540a6a066da2829095.
>
> Reason for revert: Speculative revert. Breaks downstream project
>
> Original change's description:
> > Revert back to using the task_queue_ for guarding access.
> >
> > This removes the SequenceChecker that was temporarily used while
> > the rtc::Thread TQ implementation was being fixed.
> >
> > Bug: none
> > Change-Id: Iaa46e47371211ac0a97b2dcaf23cef12b43ee8ea
> > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/175081
> > Commit-Queue: Tommi <tommi@webrtc.org>
> > Reviewed-by: Sebastian Jansson <srte@webrtc.org>
> > Cr-Commit-Position: refs/heads/master@{#31256}
>
> TBR=tommi@webrtc.org,srte@webrtc.org
>
> Change-Id: I17a12bdca888a63f2fd161da30c0def5b9c3d04e
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: none
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/175103
> Reviewed-by: Artem Titov <titovartem@webrtc.org>
> Commit-Queue: Artem Titov <titovartem@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#31258}
TBR=tommi@webrtc.org,srte@webrtc.org,titovartem@webrtc.org
# Not skipping CQ checks because this is a reland.
Bug: none
Change-Id: I23992643126d7d6dae63da1bb14420b2b8794fd9
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/175135
Reviewed-by: Tommi <tommi@webrtc.org>
Reviewed-by: Sebastian Jansson <srte@webrtc.org>
Reviewed-by: Artem Titov <titovartem@webrtc.org>
Commit-Queue: Tommi <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31283}
diff --git a/rtc_base/task_utils/repeating_task.cc b/rtc_base/task_utils/repeating_task.cc
index 71911e6..3b84701 100644
--- a/rtc_base/task_utils/repeating_task.cc
+++ b/rtc_base/task_utils/repeating_task.cc
@@ -21,13 +21,12 @@
TimeDelta first_delay)
: task_queue_(task_queue),
next_run_time_(Timestamp::Micros(rtc::TimeMicros()) + first_delay) {
- sequence_checker_.Detach();
}
RepeatingTaskBase::~RepeatingTaskBase() = default;
bool RepeatingTaskBase::Run() {
- RTC_DCHECK_RUN_ON(&sequence_checker_);
+ RTC_DCHECK_RUN_ON(task_queue_);
// Return true to tell the TaskQueue to destruct this object.
if (next_run_time_.IsPlusInfinity())
return true;
@@ -53,7 +52,7 @@
}
void RepeatingTaskBase::Stop() {
- RTC_DCHECK_RUN_ON(&sequence_checker_);
+ RTC_DCHECK_RUN_ON(task_queue_);
RTC_DCHECK(next_run_time_.IsFinite());
next_run_time_ = Timestamp::PlusInfinity();
}
diff --git a/rtc_base/task_utils/repeating_task.h b/rtc_base/task_utils/repeating_task.h
index 75d03bf..f7ae55e 100644
--- a/rtc_base/task_utils/repeating_task.h
+++ b/rtc_base/task_utils/repeating_task.h
@@ -19,7 +19,6 @@
#include "api/task_queue/task_queue_base.h"
#include "api/units/time_delta.h"
#include "api/units/timestamp.h"
-#include "rtc_base/synchronization/sequence_checker.h"
namespace webrtc {
@@ -41,14 +40,7 @@
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(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_;
+ Timestamp next_run_time_ RTC_GUARDED_BY(task_queue_);
};
// The template closure pattern is based on rtc::ClosureTask.