Mark AsyncInvoker as deprecated
Also fix similar annotation on NackModule to have effect (when defining an alias with C++ using, ABSL_DEPRECATED should appear on the left hand side). Bug: webrtc:12339 Change-Id: Id80a20bf2c56a826777b8a40e06ac5c65e4f8db7 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/217242 Reviewed-by: Harald Alvestrand <hta@webrtc.org> Commit-Queue: Niels Moller <nisse@webrtc.org> Cr-Commit-Position: refs/heads/master@{#33905}
This commit is contained in:

committed by
WebRTC LUCI CQ

parent
de88b08b94
commit
0694ce7d1b
@ -125,7 +125,7 @@ class DEPRECATED_NackModule : public Module {
|
|||||||
const absl::optional<BackoffSettings> backoff_settings_;
|
const absl::optional<BackoffSettings> backoff_settings_;
|
||||||
};
|
};
|
||||||
|
|
||||||
using NackModule = ABSL_DEPRECATED("") DEPRECATED_NackModule;
|
using NackModule ABSL_DEPRECATED("") = DEPRECATED_NackModule;
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
|
||||||
|
@ -15,12 +15,12 @@
|
|||||||
|
|
||||||
namespace rtc {
|
namespace rtc {
|
||||||
|
|
||||||
AsyncInvoker::AsyncInvoker()
|
DEPRECATED_AsyncInvoker::DEPRECATED_AsyncInvoker()
|
||||||
: pending_invocations_(0),
|
: pending_invocations_(0),
|
||||||
invocation_complete_(make_ref_counted<Event>()),
|
invocation_complete_(make_ref_counted<Event>()),
|
||||||
destroying_(false) {}
|
destroying_(false) {}
|
||||||
|
|
||||||
AsyncInvoker::~AsyncInvoker() {
|
DEPRECATED_AsyncInvoker::~DEPRECATED_AsyncInvoker() {
|
||||||
destroying_.store(true, std::memory_order_relaxed);
|
destroying_.store(true, std::memory_order_relaxed);
|
||||||
// Messages for this need to be cleared *before* our destructor is complete.
|
// Messages for this need to be cleared *before* our destructor is complete.
|
||||||
ThreadManager::Clear(this);
|
ThreadManager::Clear(this);
|
||||||
@ -37,7 +37,7 @@ AsyncInvoker::~AsyncInvoker() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AsyncInvoker::OnMessage(Message* msg) {
|
void DEPRECATED_AsyncInvoker::OnMessage(Message* msg) {
|
||||||
// Get the AsyncClosure shared ptr from this message's data.
|
// Get the AsyncClosure shared ptr from this message's data.
|
||||||
ScopedMessageData<AsyncClosure>* data =
|
ScopedMessageData<AsyncClosure>* data =
|
||||||
static_cast<ScopedMessageData<AsyncClosure>*>(msg->pdata);
|
static_cast<ScopedMessageData<AsyncClosure>*>(msg->pdata);
|
||||||
@ -46,7 +46,8 @@ void AsyncInvoker::OnMessage(Message* msg) {
|
|||||||
delete data;
|
delete data;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AsyncInvoker::Flush(Thread* thread, uint32_t id /*= MQID_ANY*/) {
|
void DEPRECATED_AsyncInvoker::Flush(Thread* thread,
|
||||||
|
uint32_t id /*= MQID_ANY*/) {
|
||||||
// If the destructor is waiting for invocations to finish, don't start
|
// If the destructor is waiting for invocations to finish, don't start
|
||||||
// running even more tasks.
|
// running even more tasks.
|
||||||
if (destroying_.load(std::memory_order_relaxed))
|
if (destroying_.load(std::memory_order_relaxed))
|
||||||
@ -67,14 +68,14 @@ void AsyncInvoker::Flush(Thread* thread, uint32_t id /*= MQID_ANY*/) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AsyncInvoker::Clear() {
|
void DEPRECATED_AsyncInvoker::Clear() {
|
||||||
ThreadManager::Clear(this);
|
ThreadManager::Clear(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AsyncInvoker::DoInvoke(const Location& posted_from,
|
void DEPRECATED_AsyncInvoker::DoInvoke(const Location& posted_from,
|
||||||
Thread* thread,
|
Thread* thread,
|
||||||
std::unique_ptr<AsyncClosure> closure,
|
std::unique_ptr<AsyncClosure> closure,
|
||||||
uint32_t id) {
|
uint32_t id) {
|
||||||
if (destroying_.load(std::memory_order_relaxed)) {
|
if (destroying_.load(std::memory_order_relaxed)) {
|
||||||
// Note that this may be expected, if the application is AsyncInvoking
|
// Note that this may be expected, if the application is AsyncInvoking
|
||||||
// tasks that AsyncInvoke other tasks. But otherwise it indicates a race
|
// tasks that AsyncInvoke other tasks. But otherwise it indicates a race
|
||||||
@ -87,11 +88,12 @@ void AsyncInvoker::DoInvoke(const Location& posted_from,
|
|||||||
new ScopedMessageData<AsyncClosure>(std::move(closure)));
|
new ScopedMessageData<AsyncClosure>(std::move(closure)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void AsyncInvoker::DoInvokeDelayed(const Location& posted_from,
|
void DEPRECATED_AsyncInvoker::DoInvokeDelayed(
|
||||||
Thread* thread,
|
const Location& posted_from,
|
||||||
std::unique_ptr<AsyncClosure> closure,
|
Thread* thread,
|
||||||
uint32_t delay_ms,
|
std::unique_ptr<AsyncClosure> closure,
|
||||||
uint32_t id) {
|
uint32_t delay_ms,
|
||||||
|
uint32_t id) {
|
||||||
if (destroying_.load(std::memory_order_relaxed)) {
|
if (destroying_.load(std::memory_order_relaxed)) {
|
||||||
// See above comment.
|
// See above comment.
|
||||||
RTC_LOG(LS_WARNING) << "Tried to invoke while destroying the invoker.";
|
RTC_LOG(LS_WARNING) << "Tried to invoke while destroying the invoker.";
|
||||||
@ -101,7 +103,7 @@ void AsyncInvoker::DoInvokeDelayed(const Location& posted_from,
|
|||||||
new ScopedMessageData<AsyncClosure>(std::move(closure)));
|
new ScopedMessageData<AsyncClosure>(std::move(closure)));
|
||||||
}
|
}
|
||||||
|
|
||||||
AsyncClosure::AsyncClosure(AsyncInvoker* invoker)
|
AsyncClosure::AsyncClosure(DEPRECATED_AsyncInvoker* invoker)
|
||||||
: invoker_(invoker), invocation_complete_(invoker_->invocation_complete_) {
|
: invoker_(invoker), invocation_complete_(invoker_->invocation_complete_) {
|
||||||
invoker_->pending_invocations_.fetch_add(1, std::memory_order_relaxed);
|
invoker_->pending_invocations_.fetch_add(1, std::memory_order_relaxed);
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
#include "absl/base/attributes.h"
|
||||||
#include "api/scoped_refptr.h"
|
#include "api/scoped_refptr.h"
|
||||||
#include "rtc_base/async_invoker_inl.h"
|
#include "rtc_base/async_invoker_inl.h"
|
||||||
#include "rtc_base/constructor_magic.h"
|
#include "rtc_base/constructor_magic.h"
|
||||||
@ -86,10 +87,10 @@ namespace rtc {
|
|||||||
// destruction. This can be done by starting each chain of invocations on the
|
// destruction. This can be done by starting each chain of invocations on the
|
||||||
// same thread on which it will be destroyed, or by using some other
|
// same thread on which it will be destroyed, or by using some other
|
||||||
// synchronization method.
|
// synchronization method.
|
||||||
class AsyncInvoker : public MessageHandlerAutoCleanup {
|
class DEPRECATED_AsyncInvoker : public MessageHandlerAutoCleanup {
|
||||||
public:
|
public:
|
||||||
AsyncInvoker();
|
DEPRECATED_AsyncInvoker();
|
||||||
~AsyncInvoker() override;
|
~DEPRECATED_AsyncInvoker() override;
|
||||||
|
|
||||||
// Call |functor| asynchronously on |thread|, with no callback upon
|
// Call |functor| asynchronously on |thread|, with no callback upon
|
||||||
// completion. Returns immediately.
|
// completion. Returns immediately.
|
||||||
@ -165,9 +166,12 @@ class AsyncInvoker : public MessageHandlerAutoCleanup {
|
|||||||
|
|
||||||
friend class AsyncClosure;
|
friend class AsyncClosure;
|
||||||
|
|
||||||
RTC_DISALLOW_COPY_AND_ASSIGN(AsyncInvoker);
|
RTC_DISALLOW_COPY_AND_ASSIGN(DEPRECATED_AsyncInvoker);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
using AsyncInvoker ABSL_DEPRECATED("bugs.webrtc.org/12339") =
|
||||||
|
DEPRECATED_AsyncInvoker;
|
||||||
|
|
||||||
} // namespace rtc
|
} // namespace rtc
|
||||||
|
|
||||||
#endif // RTC_BASE_ASYNC_INVOKER_H_
|
#endif // RTC_BASE_ASYNC_INVOKER_H_
|
||||||
|
@ -21,20 +21,20 @@
|
|||||||
|
|
||||||
namespace rtc {
|
namespace rtc {
|
||||||
|
|
||||||
class AsyncInvoker;
|
class DEPRECATED_AsyncInvoker;
|
||||||
|
|
||||||
// Helper class for AsyncInvoker. Runs a task and triggers a callback
|
// Helper class for AsyncInvoker. Runs a task and triggers a callback
|
||||||
// on the calling thread if necessary.
|
// on the calling thread if necessary.
|
||||||
class AsyncClosure {
|
class AsyncClosure {
|
||||||
public:
|
public:
|
||||||
explicit AsyncClosure(AsyncInvoker* invoker);
|
explicit AsyncClosure(DEPRECATED_AsyncInvoker* invoker);
|
||||||
virtual ~AsyncClosure();
|
virtual ~AsyncClosure();
|
||||||
// Runs the asynchronous task, and triggers a callback to the calling
|
// Runs the asynchronous task, and triggers a callback to the calling
|
||||||
// thread if needed. Should be called from the target thread.
|
// thread if needed. Should be called from the target thread.
|
||||||
virtual void Execute() = 0;
|
virtual void Execute() = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
AsyncInvoker* invoker_;
|
DEPRECATED_AsyncInvoker* invoker_;
|
||||||
// Reference counted so that if the AsyncInvoker destructor finishes before
|
// Reference counted so that if the AsyncInvoker destructor finishes before
|
||||||
// an AsyncClosure's destructor that's about to call
|
// an AsyncClosure's destructor that's about to call
|
||||||
// "invocation_complete_->Set()", it's not dereferenced after being
|
// "invocation_complete_->Set()", it's not dereferenced after being
|
||||||
@ -46,7 +46,8 @@ class AsyncClosure {
|
|||||||
template <class FunctorT>
|
template <class FunctorT>
|
||||||
class FireAndForgetAsyncClosure : public AsyncClosure {
|
class FireAndForgetAsyncClosure : public AsyncClosure {
|
||||||
public:
|
public:
|
||||||
explicit FireAndForgetAsyncClosure(AsyncInvoker* invoker, FunctorT&& functor)
|
explicit FireAndForgetAsyncClosure(DEPRECATED_AsyncInvoker* invoker,
|
||||||
|
FunctorT&& functor)
|
||||||
: AsyncClosure(invoker), functor_(std::forward<FunctorT>(functor)) {}
|
: AsyncClosure(invoker), functor_(std::forward<FunctorT>(functor)) {}
|
||||||
virtual void Execute() { functor_(); }
|
virtual void Execute() { functor_(); }
|
||||||
|
|
||||||
|
@ -521,7 +521,7 @@ TEST(ThreadTest, ThreeThreadsInvoke) {
|
|||||||
|
|
||||||
// Asynchronously invoke SetAndInvokeSet on |thread1| and wait until
|
// Asynchronously invoke SetAndInvokeSet on |thread1| and wait until
|
||||||
// |thread1| starts the call.
|
// |thread1| starts the call.
|
||||||
static void AsyncInvokeSetAndWait(AsyncInvoker* invoker,
|
static void AsyncInvokeSetAndWait(DEPRECATED_AsyncInvoker* invoker,
|
||||||
Thread* thread1,
|
Thread* thread1,
|
||||||
Thread* thread2,
|
Thread* thread2,
|
||||||
LockedBool* out) {
|
LockedBool* out) {
|
||||||
@ -536,7 +536,7 @@ TEST(ThreadTest, ThreeThreadsInvoke) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
AsyncInvoker invoker;
|
DEPRECATED_AsyncInvoker invoker;
|
||||||
LockedBool thread_a_called(false);
|
LockedBool thread_a_called(false);
|
||||||
|
|
||||||
// Start the sequence A --(invoke)--> B --(async invoke)--> C --(invoke)--> A.
|
// Start the sequence A --(invoke)--> B --(async invoke)--> C --(invoke)--> A.
|
||||||
@ -761,7 +761,7 @@ class AsyncInvokeTest : public ::testing::Test {
|
|||||||
};
|
};
|
||||||
|
|
||||||
TEST_F(AsyncInvokeTest, FireAndForget) {
|
TEST_F(AsyncInvokeTest, FireAndForget) {
|
||||||
AsyncInvoker invoker;
|
DEPRECATED_AsyncInvoker invoker;
|
||||||
// Create and start the thread.
|
// Create and start the thread.
|
||||||
auto thread = Thread::CreateWithSocketServer();
|
auto thread = Thread::CreateWithSocketServer();
|
||||||
thread->Start();
|
thread->Start();
|
||||||
@ -773,7 +773,7 @@ TEST_F(AsyncInvokeTest, FireAndForget) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(AsyncInvokeTest, NonCopyableFunctor) {
|
TEST_F(AsyncInvokeTest, NonCopyableFunctor) {
|
||||||
AsyncInvoker invoker;
|
DEPRECATED_AsyncInvoker invoker;
|
||||||
// Create and start the thread.
|
// Create and start the thread.
|
||||||
auto thread = Thread::CreateWithSocketServer();
|
auto thread = Thread::CreateWithSocketServer();
|
||||||
thread->Start();
|
thread->Start();
|
||||||
@ -804,7 +804,7 @@ TEST_F(AsyncInvokeTest, KillInvokerDuringExecute) {
|
|||||||
EXPECT_FALSE(invoker_destroyed);
|
EXPECT_FALSE(invoker_destroyed);
|
||||||
functor_finished.Set();
|
functor_finished.Set();
|
||||||
};
|
};
|
||||||
AsyncInvoker invoker;
|
DEPRECATED_AsyncInvoker invoker;
|
||||||
invoker.AsyncInvoke<void>(RTC_FROM_HERE, thread.get(), functor);
|
invoker.AsyncInvoke<void>(RTC_FROM_HERE, thread.get(), functor);
|
||||||
functor_started.Wait(Event::kForever);
|
functor_started.Wait(Event::kForever);
|
||||||
|
|
||||||
@ -833,7 +833,7 @@ TEST_F(AsyncInvokeTest, KillInvokerDuringExecuteWithReentrantInvoke) {
|
|||||||
Thread thread(std::make_unique<NullSocketServer>());
|
Thread thread(std::make_unique<NullSocketServer>());
|
||||||
thread.Start();
|
thread.Start();
|
||||||
{
|
{
|
||||||
AsyncInvoker invoker;
|
DEPRECATED_AsyncInvoker invoker;
|
||||||
auto reentrant_functor = [&reentrant_functor_run] {
|
auto reentrant_functor = [&reentrant_functor_run] {
|
||||||
reentrant_functor_run = true;
|
reentrant_functor_run = true;
|
||||||
};
|
};
|
||||||
@ -852,7 +852,7 @@ TEST_F(AsyncInvokeTest, KillInvokerDuringExecuteWithReentrantInvoke) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(AsyncInvokeTest, Flush) {
|
TEST_F(AsyncInvokeTest, Flush) {
|
||||||
AsyncInvoker invoker;
|
DEPRECATED_AsyncInvoker invoker;
|
||||||
AtomicBool flag1;
|
AtomicBool flag1;
|
||||||
AtomicBool flag2;
|
AtomicBool flag2;
|
||||||
// Queue two async calls to the current thread.
|
// Queue two async calls to the current thread.
|
||||||
@ -868,7 +868,7 @@ TEST_F(AsyncInvokeTest, Flush) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(AsyncInvokeTest, FlushWithIds) {
|
TEST_F(AsyncInvokeTest, FlushWithIds) {
|
||||||
AsyncInvoker invoker;
|
DEPRECATED_AsyncInvoker invoker;
|
||||||
AtomicBool flag1;
|
AtomicBool flag1;
|
||||||
AtomicBool flag2;
|
AtomicBool flag2;
|
||||||
// Queue two async calls to the current thread, one with a message id.
|
// Queue two async calls to the current thread, one with a message id.
|
||||||
|
Reference in New Issue
Block a user