Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(249)

Unified Diff: webrtc/base/asyncinvoker.h

Issue 2694723004: Making AsyncInvoker destructor thread-safe. (Closed)
Patch Set: Switch to MessageQueueManager::Clear, for when multiple threads are blocked. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/base/asyncinvoker.h
diff --git a/webrtc/base/asyncinvoker.h b/webrtc/base/asyncinvoker.h
index d91e30601eff620aaec65537ee47632187a705c5..5a14049494f1c7b06c9ff754b4f61caaccb1a708 100644
--- a/webrtc/base/asyncinvoker.h
+++ b/webrtc/base/asyncinvoker.h
@@ -14,8 +14,8 @@
#include "webrtc/base/asyncinvoker-inl.h"
#include "webrtc/base/bind.h"
#include "webrtc/base/constructormagic.h"
+#include "webrtc/base/event.h"
#include "webrtc/base/sigslot.h"
-#include "webrtc/base/scopedptrcollection.h"
#include "webrtc/base/thread.h"
namespace rtc {
@@ -80,7 +80,8 @@ class AsyncInvoker : public MessageHandler {
const FunctorT& functor,
uint32_t id = 0) {
scoped_refptr<AsyncClosure> closure(
- new RefCountedObject<FireAndForgetAsyncClosure<FunctorT> >(functor));
+ new RefCountedObject<FireAndForgetAsyncClosure<FunctorT> >(this,
+ functor));
DoInvoke(posted_from, thread, closure, id);
}
@@ -93,7 +94,8 @@ class AsyncInvoker : public MessageHandler {
uint32_t delay_ms,
uint32_t id = 0) {
scoped_refptr<AsyncClosure> closure(
- new RefCountedObject<FireAndForgetAsyncClosure<FunctorT> >(functor));
+ new RefCountedObject<FireAndForgetAsyncClosure<FunctorT> >(this,
+ functor));
DoInvokeDelayed(posted_from, thread, closure, delay_ms, id);
}
@@ -155,7 +157,10 @@ class AsyncInvoker : public MessageHandler {
const scoped_refptr<AsyncClosure>& closure,
uint32_t delay_ms,
uint32_t id);
- bool destroying_;
+ volatile int pending_invocations_ = 0;
+ Event invocation_complete_;
+ bool destroying_ = false;
+ friend class AsyncClosure;
RTC_DISALLOW_COPY_AND_ASSIGN(AsyncInvoker);
};

Powered by Google App Engine
This is Rietveld 408576698