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

Unified Diff: webrtc/base/asyncinvoker.h

Issue 2694723004: Making AsyncInvoker destructor thread-safe. (Closed)
Patch Set: Merge with master 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
« no previous file with comments | « tools-webrtc/sanitizers/tsan_suppressions_webrtc.cc ('k') | webrtc/base/asyncinvoker.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/base/asyncinvoker.h
diff --git a/webrtc/base/asyncinvoker.h b/webrtc/base/asyncinvoker.h
index 43fffeac10568526755d097ec9b167f83811a001..ed6124397460e35113e9093cc6fa76580ee33a7d 100644
--- a/webrtc/base/asyncinvoker.h
+++ b/webrtc/base/asyncinvoker.h
@@ -17,6 +17,7 @@
#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/thread.h"
@@ -82,7 +83,7 @@ class AsyncInvoker : public MessageHandler {
const FunctorT& functor,
uint32_t id = 0) {
std::unique_ptr<AsyncClosure> closure(
- new FireAndForgetAsyncClosure<FunctorT>(functor));
+ new FireAndForgetAsyncClosure<FunctorT>(this, functor));
DoInvoke(posted_from, thread, std::move(closure), id);
}
@@ -95,7 +96,7 @@ class AsyncInvoker : public MessageHandler {
uint32_t delay_ms,
uint32_t id = 0) {
std::unique_ptr<AsyncClosure> closure(
- new FireAndForgetAsyncClosure<FunctorT>(functor));
+ new FireAndForgetAsyncClosure<FunctorT>(this, functor));
DoInvokeDelayed(posted_from, thread, std::move(closure), delay_ms, id);
}
@@ -157,7 +158,10 @@ class AsyncInvoker : public MessageHandler {
std::unique_ptr<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);
};
« no previous file with comments | « tools-webrtc/sanitizers/tsan_suppressions_webrtc.cc ('k') | webrtc/base/asyncinvoker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698