Chromium Code Reviews| Index: webrtc/base/asyncinvoker.cc |
| diff --git a/webrtc/base/asyncinvoker.cc b/webrtc/base/asyncinvoker.cc |
| index bfd13172f70329598dc9393d41eb660f8877e8f7..e3f33b5123ebc2dbabe849b044b258d579e0f715 100644 |
| --- a/webrtc/base/asyncinvoker.cc |
| +++ b/webrtc/base/asyncinvoker.cc |
| @@ -29,8 +29,8 @@ AsyncInvoker::~AsyncInvoker() { |
| // another thread, WITHIN an AsyncInvoked functor, it may do another |
| // Thread::Post even after we called MessageQueueManager::Clear(this). So |
| // we need to keep calling Clear to discard these posts. |
| - MessageQueueManager::Clear(this); |
| invocation_complete_.Wait(Event::kForever); |
| + MessageQueueManager::Clear(this); |
|
nisse-webrtc
2017/05/18 08:04:55
This is subtle (maybe too subtle...).
So at the e
Taylor Brandstetter
2017/05/18 20:54:52
I must have had a brain lapse and forgot that if "
|
| } |
| } |
| @@ -69,7 +69,6 @@ void AsyncInvoker::DoInvoke(const Location& posted_from, |
| 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))); |
| } |
| @@ -83,7 +82,6 @@ void AsyncInvoker::DoInvokeDelayed(const Location& posted_from, |
| 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))); |
| } |
| @@ -111,6 +109,10 @@ void GuardedAsyncInvoker::ThreadDestroyed() { |
| thread_ = nullptr; |
| } |
| +AsyncClosure::AsyncClosure(AsyncInvoker* invoker) : invoker_(invoker) { |
| + AtomicOps::Increment(&invoker_->pending_invocations_); |
|
nisse-webrtc
2017/05/18 08:04:55
I take it moving the increment here from DoInvoke*
Taylor Brandstetter
2017/05/18 20:54:52
It's still done before anything gets added to the
nisse-webrtc
2017/05/19 06:43:21
I see, I was under the impression that the closure
|
| +} |
| + |
| AsyncClosure::~AsyncClosure() { |
| AtomicOps::Decrement(&invoker_->pending_invocations_); |
|
nisse-webrtc
2017/05/18 11:12:39
Thinking a bit more, I'm afraids this approach is
Taylor Brandstetter
2017/05/18 20:54:52
That's exactly the issue I was trying to fix in th
nisse-webrtc
2017/05/19 06:43:21
Makes sense. lgtm, then.
nisse-webrtc
2017/05/19 06:48:16
But please update cl title accordingly...
|
| invoker_->invocation_complete_.Set(); |