Index: webrtc/base/asyncinvoker.cc |
diff --git a/webrtc/base/asyncinvoker.cc b/webrtc/base/asyncinvoker.cc |
index d2583091ccdcfca9d8140b9db0f3b7c4c411ece3..bfd13172f70329598dc9393d41eb660f8877e8f7 100644 |
--- a/webrtc/base/asyncinvoker.cc |
+++ b/webrtc/base/asyncinvoker.cc |
@@ -19,7 +19,7 @@ |
AsyncInvoker::AsyncInvoker() : invocation_complete_(false, false) {} |
AsyncInvoker::~AsyncInvoker() { |
- AtomicOps::Increment(&destroying_); |
+ destroying_ = true; |
// Messages for this need to be cleared *before* our destructor is complete. |
MessageQueueManager::Clear(this); |
// And we need to wait for any invocations that are still in progress on |
@@ -44,8 +44,7 @@ |
} |
void AsyncInvoker::Flush(Thread* thread, uint32_t id /*= MQID_ANY*/) { |
- if (AtomicOps::AcquireLoad(&destroying_)) |
- return; |
+ if (destroying_) return; |
// Run this on |thread| to reduce the number of context switches. |
if (Thread::Current() != thread) { |
@@ -66,10 +65,11 @@ |
Thread* thread, |
std::unique_ptr<AsyncClosure> closure, |
uint32_t id) { |
- if (AtomicOps::AcquireLoad(&destroying_)) { |
+ if (destroying_) { |
LOG(LS_WARNING) << "Tried to invoke while destroying the invoker."; |
return; |
} |
+ AtomicOps::Increment(&pending_invocations_); |
thread->Post(posted_from, this, id, |
new ScopedMessageData<AsyncClosure>(std::move(closure))); |
} |
@@ -79,10 +79,11 @@ |
std::unique_ptr<AsyncClosure> closure, |
uint32_t delay_ms, |
uint32_t id) { |
- if (AtomicOps::AcquireLoad(&destroying_)) { |
+ if (destroying_) { |
LOG(LS_WARNING) << "Tried to invoke while destroying the invoker."; |
return; |
} |
+ AtomicOps::Increment(&pending_invocations_); |
thread->PostDelayed(posted_from, delay_ms, this, id, |
new ScopedMessageData<AsyncClosure>(std::move(closure))); |
} |
@@ -110,10 +111,6 @@ |
thread_ = nullptr; |
} |
-AsyncClosure::AsyncClosure(AsyncInvoker* invoker) : invoker_(invoker) { |
- AtomicOps::Increment(&invoker_->pending_invocations_); |
-} |
- |
AsyncClosure::~AsyncClosure() { |
AtomicOps::Decrement(&invoker_->pending_invocations_); |
invoker_->invocation_complete_.Set(); |