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

Unified Diff: webrtc/base/asyncinvoker-inl.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 | « webrtc/base/asyncinvoker.cc ('k') | webrtc/base/event.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/base/asyncinvoker-inl.h
diff --git a/webrtc/base/asyncinvoker-inl.h b/webrtc/base/asyncinvoker-inl.h
index c3691b5659b78935fe6381fd744622cbc11030ef..d172eee0a6bc32cdde3d9d51b1dae0ed9e1471f9 100644
--- a/webrtc/base/asyncinvoker-inl.h
+++ b/webrtc/base/asyncinvoker-inl.h
@@ -11,6 +11,7 @@
#ifndef WEBRTC_BASE_ASYNCINVOKER_INL_H_
#define WEBRTC_BASE_ASYNCINVOKER_INL_H_
+#include "webrtc/base/atomicops.h"
#include "webrtc/base/bind.h"
#include "webrtc/base/callback.h"
#include "webrtc/base/criticalsection.h"
@@ -26,18 +27,23 @@ class AsyncInvoker;
// on the calling thread if necessary.
class AsyncClosure {
public:
- virtual ~AsyncClosure() {}
+ explicit AsyncClosure(AsyncInvoker* invoker) : invoker_(invoker) {}
+ virtual ~AsyncClosure();
// Runs the asynchronous task, and triggers a callback to the calling
// thread if needed. Should be called from the target thread.
virtual void Execute() = 0;
+
+ protected:
+ AsyncInvoker* invoker_;
};
// Simple closure that doesn't trigger a callback for the calling thread.
template <class FunctorT>
class FireAndForgetAsyncClosure : public AsyncClosure {
public:
- explicit FireAndForgetAsyncClosure(const FunctorT& functor)
- : functor_(functor) {}
+ explicit FireAndForgetAsyncClosure(AsyncInvoker* invoker,
+ const FunctorT& functor)
+ : AsyncClosure(invoker), functor_(functor) {}
virtual void Execute() {
functor_();
}
@@ -65,7 +71,6 @@ class NotifyingAsyncClosureBase : public AsyncClosure,
bool CallbackCanceled() const { return calling_thread_ == NULL; }
private:
- AsyncInvoker* invoker_;
Location callback_posted_from_;
Callback0<void> callback_;
CriticalSection crit_;
« no previous file with comments | « webrtc/base/asyncinvoker.cc ('k') | webrtc/base/event.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698