From 19ba552e88350ef43c9cc78335b47d117d665771 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Bostr=C3=B6m?= Date: Mon, 14 Mar 2022 15:19:43 +0100 Subject: [PATCH] Add TaskQueue::PostDelayedTaskWithPrecision helper method. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Just like the other PostTask methods, this is just short-hand for invoking the TaskQueueBase's version of the method. Drive-by fix: remove unnecessary return statement of void methods. Bug: webrtc:13604 Change-Id: I3d5cae66bfa06334058386909f041916dbfa5ab8 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/255342 Reviewed-by: Mirko Bonadei Commit-Queue: Henrik Boström Auto-Submit: Henrik Boström Reviewed-by: Mirko Bonadei Commit-Queue: Mirko Bonadei Cr-Commit-Position: refs/heads/main@{#36194} --- rtc_base/task_queue.cc | 13 ++++++++++--- rtc_base/task_queue.h | 16 ++++++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/rtc_base/task_queue.cc b/rtc_base/task_queue.cc index f0dbdb3ae0..0b54178405 100644 --- a/rtc_base/task_queue.cc +++ b/rtc_base/task_queue.cc @@ -30,18 +30,25 @@ bool TaskQueue::IsCurrent() const { } void TaskQueue::PostTask(std::unique_ptr task) { - return impl_->PostTask(std::move(task)); + impl_->PostTask(std::move(task)); } void TaskQueue::PostDelayedTask(std::unique_ptr task, uint32_t milliseconds) { - return impl_->PostDelayedTask(std::move(task), milliseconds); + impl_->PostDelayedTask(std::move(task), milliseconds); } void TaskQueue::PostDelayedHighPrecisionTask( std::unique_ptr task, uint32_t milliseconds) { - return impl_->PostDelayedHighPrecisionTask(std::move(task), milliseconds); + impl_->PostDelayedHighPrecisionTask(std::move(task), milliseconds); +} + +void TaskQueue::PostDelayedTaskWithPrecision( + webrtc::TaskQueueBase::DelayPrecision precision, + std::unique_ptr task, + uint32_t milliseconds) { + impl_->PostDelayedTaskWithPrecision(precision, std::move(task), milliseconds); } } // namespace rtc diff --git a/rtc_base/task_queue.h b/rtc_base/task_queue.h index 4ad3fedd95..ef97646988 100644 --- a/rtc_base/task_queue.h +++ b/rtc_base/task_queue.h @@ -100,6 +100,10 @@ class RTC_LOCKABLE RTC_EXPORT TaskQueue { uint32_t milliseconds); void PostDelayedHighPrecisionTask(std::unique_ptr task, uint32_t milliseconds); + void PostDelayedTaskWithPrecision( + webrtc::TaskQueueBase::DelayPrecision precision, + std::unique_ptr task, + uint32_t milliseconds); // std::enable_if is used here to make sure that calls to PostTask() with // std::unique_ptr would not end up being @@ -127,6 +131,18 @@ class RTC_LOCKABLE RTC_EXPORT TaskQueue { PostDelayedHighPrecisionTask( webrtc::ToQueuedTask(std::forward(closure)), milliseconds); } + template >::value>::type* = nullptr> + void PostDelayedTaskWithPrecision( + webrtc::TaskQueueBase::DelayPrecision precision, + Closure&& closure, + uint32_t milliseconds) { + PostDelayedTaskWithPrecision( + precision, webrtc::ToQueuedTask(std::forward(closure)), + milliseconds); + } private: webrtc::TaskQueueBase* const impl_;