Removes PostStop from RepeatingTaskHandle.
It isn't used and can easily be replaced with posting a task, as shown
in the changes to the unit test.
Also removing the sequenced task checker that no longer adds any value.
We now ensure that the task can only be stopped with a reference to the
task queue it runs on.
Bug: webrtc:10365
Change-Id: Ie8aef6f742c55db1fb686f20c2a28c606c721fa0
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/129725
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#27292}
diff --git a/rtc_base/task_utils/repeating_task.cc b/rtc_base/task_utils/repeating_task.cc
index 0cc9a62..cdabf2f 100644
--- a/rtc_base/task_utils/repeating_task.cc
+++ b/rtc_base/task_utils/repeating_task.cc
@@ -54,38 +54,16 @@
next_run_time_ = Timestamp::PlusInfinity();
}
-void RepeatingTaskBase::PostStop() {
- if (task_queue_->IsCurrent()) {
- RTC_DLOG(LS_INFO) << "Using PostStop() from the task queue running the "
- "repeated task. Consider calling Stop() instead.";
- }
- task_queue_->PostTask(ToQueuedTask([this] {
- RTC_DCHECK_RUN_ON(task_queue_);
- Stop();
- }));
-}
-
} // namespace webrtc_repeating_task_impl
-RepeatingTaskHandle::RepeatingTaskHandle() {
- sequence_checker_.Detach();
-}
-RepeatingTaskHandle::~RepeatingTaskHandle() {
- sequence_checker_.Detach();
-}
RepeatingTaskHandle::RepeatingTaskHandle(RepeatingTaskHandle&& other)
: repeating_task_(other.repeating_task_) {
- RTC_DCHECK_RUN_ON(&sequence_checker_);
other.repeating_task_ = nullptr;
}
RepeatingTaskHandle& RepeatingTaskHandle::operator=(
RepeatingTaskHandle&& other) {
- RTC_DCHECK_RUN_ON(&other.sequence_checker_);
- {
- RTC_DCHECK_RUN_ON(&sequence_checker_);
- repeating_task_ = other.repeating_task_;
- }
+ repeating_task_ = other.repeating_task_;
other.repeating_task_ = nullptr;
return *this;
}
@@ -95,7 +73,6 @@
: repeating_task_(repeating_task) {}
void RepeatingTaskHandle::Stop() {
- RTC_DCHECK_RUN_ON(&sequence_checker_);
if (repeating_task_) {
RTC_DCHECK_RUN_ON(repeating_task_->task_queue_);
repeating_task_->Stop();
@@ -103,16 +80,7 @@
}
}
-void RepeatingTaskHandle::PostStop() {
- RTC_DCHECK_RUN_ON(&sequence_checker_);
- if (repeating_task_) {
- repeating_task_->PostStop();
- repeating_task_ = nullptr;
- }
-}
-
bool RepeatingTaskHandle::Running() const {
- RTC_DCHECK_RUN_ON(&sequence_checker_);
return repeating_task_ != nullptr;
}