diff --git a/rtc_base/async_invoker.cc b/rtc_base/async_invoker.cc index 4cf0aca78d..61c153499f 100644 --- a/rtc_base/async_invoker.cc +++ b/rtc_base/async_invoker.cc @@ -46,28 +46,6 @@ void DEPRECATED_AsyncInvoker::OnMessage(Message* msg) { delete data; } -void DEPRECATED_AsyncInvoker::Flush(Thread* thread, - uint32_t id /*= MQID_ANY*/) { - // If the destructor is waiting for invocations to finish, don't start - // running even more tasks. - if (destroying_.load(std::memory_order_relaxed)) - return; - - // Run this on `thread` to reduce the number of context switches. - if (Thread::Current() != thread) { - thread->Invoke(RTC_FROM_HERE, - [this, thread, id] { Flush(thread, id); }); - return; - } - - MessageList removed; - thread->Clear(this, id, &removed); - for (MessageList::iterator it = removed.begin(); it != removed.end(); ++it) { - // This message was pending on this thread, so run it now. - thread->Send(it->posted_from, it->phandler, it->message_id, it->pdata); - } -} - void DEPRECATED_AsyncInvoker::Clear() { ThreadManager::Clear(this); } diff --git a/rtc_base/async_invoker.h b/rtc_base/async_invoker.h index 8a54159a57..e5a3c15cac 100644 --- a/rtc_base/async_invoker.h +++ b/rtc_base/async_invoker.h @@ -121,13 +121,6 @@ class DEPRECATED_AsyncInvoker : public MessageHandlerAutoCleanup { DoInvokeDelayed(posted_from, thread, std::move(closure), delay_ms, id); } - // Synchronously execute on `thread` all outstanding calls we own - // that are pending on `thread`, and wait for calls to complete - // before returning. Optionally filter by message id. - // The destructor will not wait for outstanding calls, so if that - // behavior is desired, call Flush() before destroying this object. - void Flush(Thread* thread, uint32_t id = MQID_ANY); - // Cancels any outstanding calls we own that are pending on any thread, and // which have not yet started to execute. This does not wait for any calls // that have already started executing to complete. diff --git a/rtc_base/thread_unittest.cc b/rtc_base/thread_unittest.cc index 87c87e6a02..62f00ec772 100644 --- a/rtc_base/thread_unittest.cc +++ b/rtc_base/thread_unittest.cc @@ -851,44 +851,6 @@ TEST_F(DEPRECATED_AsyncInvokeTest, EXPECT_FALSE(reentrant_functor_run); } -TEST_F(DEPRECATED_AsyncInvokeTest, Flush) { - DEPRECATED_AsyncInvoker invoker; - AtomicBool flag1; - AtomicBool flag2; - // Queue two async calls to the current thread. - invoker.AsyncInvoke(RTC_FROM_HERE, Thread::Current(), FunctorB(&flag1)); - invoker.AsyncInvoke(RTC_FROM_HERE, Thread::Current(), FunctorB(&flag2)); - // Because we haven't pumped messages, these should not have run yet. - EXPECT_FALSE(flag1.get()); - EXPECT_FALSE(flag2.get()); - // Force them to run now. - invoker.Flush(Thread::Current()); - EXPECT_TRUE(flag1.get()); - EXPECT_TRUE(flag2.get()); -} - -TEST_F(DEPRECATED_AsyncInvokeTest, FlushWithIds) { - DEPRECATED_AsyncInvoker invoker; - AtomicBool flag1; - AtomicBool flag2; - // Queue two async calls to the current thread, one with a message id. - invoker.AsyncInvoke(RTC_FROM_HERE, Thread::Current(), FunctorB(&flag1), - 5); - invoker.AsyncInvoke(RTC_FROM_HERE, Thread::Current(), FunctorB(&flag2)); - // Because we haven't pumped messages, these should not have run yet. - EXPECT_FALSE(flag1.get()); - EXPECT_FALSE(flag2.get()); - // Execute pending calls with id == 5. - invoker.Flush(Thread::Current(), 5); - EXPECT_TRUE(flag1.get()); - EXPECT_FALSE(flag2.get()); - flag1 = false; - // Execute all pending calls. The id == 5 call should not execute again. - invoker.Flush(Thread::Current()); - EXPECT_FALSE(flag1.get()); - EXPECT_TRUE(flag2.get()); -} - void WaitAndSetEvent(Event* wait_event, Event* set_event) { wait_event->Wait(Event::kForever); set_event->Set();