Mark rtc::Thread's versions of PostTask/PostDelayedTask deprecated.

Because rtc::Thread inherits from TaskQueueBase, it already implements
a pair of PostTask/PostDelayedTask methods that we want to keep. But in
addition to those, rtc::Thread defines its own PostTask/PostDelayedTask
using templates. These are the versions that we want to deprecate.

They were originally implemented prior to rtc::Thread inheriting from
TaskQueueBase. We want to deprecate them because...
- We don't want to have multiple code paths that do the same thing.
- We want to move away from rtc::Thread to TaskQueueBase long-term.
- These versions are not overridable in Chromium.
- These versions don't have high/low precision versions of PDT.

Helper methods are added to rtc::Thread so that callers don't have to
wrap every lambda in webrtc::ToQueuedTask() and update dependencies.

Bug: webrtc:13582
Change-Id: I58702c53f4cb3705681bd9f1ea16b7aaa5052c18
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/247660
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Reviewed-by: Markus Handell <handellm@google.com>
Commit-Queue: Henrik Boström <hbos@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35750}
This commit is contained in:
Henrik Boström
2022-01-20 11:58:05 +01:00
committed by WebRTC LUCI CQ
parent c065e739e2
commit 2deee4bbb2
21 changed files with 170 additions and 146 deletions

View File

@ -88,8 +88,8 @@ TEST_P(SimulatedRealTimeControllerConformanceTest, ThreadPostOrderTest) {
// Tasks on thread have to be executed in order in which they were
// posted.
ExecutionOrderKeeper execution_order;
thread->PostTask(RTC_FROM_HERE, [&]() { execution_order.Executed(1); });
thread->PostTask(RTC_FROM_HERE, [&]() { execution_order.Executed(2); });
thread->PostTask([&]() { execution_order.Executed(1); });
thread->PostTask([&]() { execution_order.Executed(2); });
time_controller->AdvanceTime(TimeDelta::Millis(100));
EXPECT_THAT(execution_order.order(), ElementsAreArray({1, 2}));
// Destroy `thread` before `execution_order` to be sure `execution_order`
@ -121,7 +121,7 @@ TEST_P(SimulatedRealTimeControllerConformanceTest, ThreadPostInvokeOrderTest) {
// Tasks on thread have to be executed in order in which they were
// posted/invoked.
ExecutionOrderKeeper execution_order;
thread->PostTask(RTC_FROM_HERE, [&]() { execution_order.Executed(1); });
thread->PostTask([&]() { execution_order.Executed(1); });
thread->Invoke<void>(RTC_FROM_HERE, [&]() { execution_order.Executed(2); });
time_controller->AdvanceTime(TimeDelta::Millis(100));
EXPECT_THAT(execution_order.order(), ElementsAreArray({1, 2}));
@ -139,8 +139,8 @@ TEST_P(SimulatedRealTimeControllerConformanceTest,
// If task is invoked from thread X on thread X it has to be executed
// immediately.
ExecutionOrderKeeper execution_order;
thread->PostTask(RTC_FROM_HERE, [&]() {
thread->PostTask(RTC_FROM_HERE, [&]() { execution_order.Executed(2); });
thread->PostTask([&]() {
thread->PostTask([&]() { execution_order.Executed(2); });
thread->Invoke<void>(RTC_FROM_HERE, [&]() { execution_order.Executed(1); });
});
time_controller->AdvanceTime(TimeDelta::Millis(100));