From 9ebe6d7c889716a1ff68e4075ad4384a34ef027b Mon Sep 17 00:00:00 2001 From: Tommi Date: Tue, 16 Nov 2021 16:07:34 +0100 Subject: [PATCH] Remove the AsyncInvoker alias. This emphasizes the "hint" to potential external users that the class has been deprecated. Bug: webrtc:12339 Change-Id: Iab83481af69a505059297cce959f02b5ab649f2f Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/237805 Reviewed-by: Mirko Bonadei Commit-Queue: Tommi Cr-Commit-Position: refs/heads/main@{#35368} --- media/sctp/usrsctp_transport.cc | 4 ++-- rtc_base/async_invoker.h | 12 +++++------- rtc_base/async_invoker_inl.h | 2 +- rtc_base/thread_unittest.cc | 22 +++++++++++----------- 4 files changed, 19 insertions(+), 21 deletions(-) diff --git a/media/sctp/usrsctp_transport.cc b/media/sctp/usrsctp_transport.cc index 40ce840738..4babf110a2 100644 --- a/media/sctp/usrsctp_transport.cc +++ b/media/sctp/usrsctp_transport.cc @@ -1172,8 +1172,8 @@ void UsrsctpTransport::OnPacketRead(rtc::PacketTransportInternal* transport, // packet will have called connect, and a connection will be established. if (sock_) { // Pass received packet to SCTP stack. Once processed by usrsctp, the data - // will be will be given to the global OnSctpInboundData, and then, - // marshalled by the AsyncInvoker. + // will be will be given to the global OnSctpInboundPacket callback and + // posted to the transport thread. VerboseLogPacket(data, len, SCTP_DUMP_INBOUND); usrsctp_conninput(reinterpret_cast(id_), data, len, 0); } else { diff --git a/rtc_base/async_invoker.h b/rtc_base/async_invoker.h index 20b24f3314..8a54159a57 100644 --- a/rtc_base/async_invoker.h +++ b/rtc_base/async_invoker.h @@ -26,6 +26,8 @@ namespace rtc { +// DEPRECATED - do not use. +// // Invokes function objects (aka functors) asynchronously on a Thread, and // owns the lifetime of calls (ie, when this object is destroyed, calls in // flight are cancelled). AsyncInvoker can optionally execute a user-specified @@ -153,10 +155,9 @@ class DEPRECATED_AsyncInvoker : public MessageHandlerAutoCleanup { // future. std::atomic pending_invocations_; - // Reference counted so that if the AsyncInvoker destructor finishes before - // an AsyncClosure's destructor that's about to call - // "invocation_complete_->Set()", it's not dereferenced after being - // destroyed. + // Reference counted so that if the destructor finishes before an + // AsyncClosure's destructor that's about to call + // "invocation_complete_->Set()", it's not dereferenced after being destroyed. rtc::Ref::Ptr invocation_complete_; // This flag is used to ensure that if an application AsyncInvokes tasks that @@ -169,9 +170,6 @@ class DEPRECATED_AsyncInvoker : public MessageHandlerAutoCleanup { RTC_DISALLOW_COPY_AND_ASSIGN(DEPRECATED_AsyncInvoker); }; -using AsyncInvoker ABSL_DEPRECATED("bugs.webrtc.org/12339") = - DEPRECATED_AsyncInvoker; - } // namespace rtc #endif // RTC_BASE_ASYNC_INVOKER_H_ diff --git a/rtc_base/async_invoker_inl.h b/rtc_base/async_invoker_inl.h index 9fb328782c..c2b6413519 100644 --- a/rtc_base/async_invoker_inl.h +++ b/rtc_base/async_invoker_inl.h @@ -23,7 +23,7 @@ namespace rtc { class DEPRECATED_AsyncInvoker; -// Helper class for AsyncInvoker. Runs a task and triggers a callback +// Helper class for DEPRECATED_AsyncInvoker. Runs a task and triggers a callback // on the calling thread if necessary. class AsyncClosure { public: diff --git a/rtc_base/thread_unittest.cc b/rtc_base/thread_unittest.cc index 430db3d606..87c87e6a02 100644 --- a/rtc_base/thread_unittest.cc +++ b/rtc_base/thread_unittest.cc @@ -742,7 +742,7 @@ TEST(ThreadManager, ClearReentrant) { new ScopedRefMessageData(inner_handler)); } -class AsyncInvokeTest : public ::testing::Test { +class DEPRECATED_AsyncInvokeTest : public ::testing::Test { public: void IntCallback(int value) { EXPECT_EQ(expected_thread_, Thread::Current()); @@ -754,13 +754,13 @@ class AsyncInvokeTest : public ::testing::Test { protected: enum { kWaitTimeout = 1000 }; - AsyncInvokeTest() : int_value_(0), expected_thread_(nullptr) {} + DEPRECATED_AsyncInvokeTest() : int_value_(0), expected_thread_(nullptr) {} int int_value_; Thread* expected_thread_; }; -TEST_F(AsyncInvokeTest, FireAndForget) { +TEST_F(DEPRECATED_AsyncInvokeTest, FireAndForget) { DEPRECATED_AsyncInvoker invoker; // Create and start the thread. auto thread = Thread::CreateWithSocketServer(); @@ -772,7 +772,7 @@ TEST_F(AsyncInvokeTest, FireAndForget) { thread->Stop(); } -TEST_F(AsyncInvokeTest, NonCopyableFunctor) { +TEST_F(DEPRECATED_AsyncInvokeTest, NonCopyableFunctor) { DEPRECATED_AsyncInvoker invoker; // Create and start the thread. auto thread = Thread::CreateWithSocketServer(); @@ -784,7 +784,7 @@ TEST_F(AsyncInvokeTest, NonCopyableFunctor) { thread->Stop(); } -TEST_F(AsyncInvokeTest, KillInvokerDuringExecute) { +TEST_F(DEPRECATED_AsyncInvokeTest, KillInvokerDuringExecute) { // Use these events to get in a state where the functor is in the middle of // executing, and then to wait for it to finish, ensuring the "EXPECT_FALSE" // is run. @@ -821,10 +821,10 @@ TEST_F(AsyncInvokeTest, KillInvokerDuringExecute) { } // Variant of the above test where the async-invoked task calls AsyncInvoke -// *again*, for the thread on which the AsyncInvoker is currently being -// destroyed. This shouldn't deadlock or crash; this second invocation should -// just be ignored. -TEST_F(AsyncInvokeTest, KillInvokerDuringExecuteWithReentrantInvoke) { +// *again*, for the thread on which the invoker is currently being destroyed. +// This shouldn't deadlock or crash. The second invocation should be ignored. +TEST_F(DEPRECATED_AsyncInvokeTest, + KillInvokerDuringExecuteWithReentrantInvoke) { Event functor_started; // Flag used to verify that the recursively invoked task never actually runs. bool reentrant_functor_run = false; @@ -851,7 +851,7 @@ TEST_F(AsyncInvokeTest, KillInvokerDuringExecuteWithReentrantInvoke) { EXPECT_FALSE(reentrant_functor_run); } -TEST_F(AsyncInvokeTest, Flush) { +TEST_F(DEPRECATED_AsyncInvokeTest, Flush) { DEPRECATED_AsyncInvoker invoker; AtomicBool flag1; AtomicBool flag2; @@ -867,7 +867,7 @@ TEST_F(AsyncInvokeTest, Flush) { EXPECT_TRUE(flag2.get()); } -TEST_F(AsyncInvokeTest, FlushWithIds) { +TEST_F(DEPRECATED_AsyncInvokeTest, FlushWithIds) { DEPRECATED_AsyncInvoker invoker; AtomicBool flag1; AtomicBool flag2;