Index: webrtc/base/asyncinvoker.cc |
diff --git a/webrtc/base/asyncinvoker.cc b/webrtc/base/asyncinvoker.cc |
index 56f1a19d543bfeecc54b4ef7ffb7abbcb4400847..5e300bd1a4898826215ecc076ebb1f36e034df16 100644 |
--- a/webrtc/base/asyncinvoker.cc |
+++ b/webrtc/base/asyncinvoker.cc |
@@ -10,6 +10,7 @@ |
#include "webrtc/base/asyncinvoker.h" |
+#include "webrtc/base/checks.h" |
#include "webrtc/base/logging.h" |
namespace rtc { |
@@ -76,6 +77,25 @@ void AsyncInvoker::DoInvokeDelayed(Thread* thread, |
new ScopedRefMessageData<AsyncClosure>(closure)); |
} |
+GuardedAsyncInvoker::GuardedAsyncInvoker() : thread_(Thread::Current()) { |
+ thread_->SignalQueueDestroyed.connect(this, |
+ &GuardedAsyncInvoker::ThreadDestroyed); |
+} |
+ |
+GuardedAsyncInvoker::~GuardedAsyncInvoker() { |
+} |
+ |
+void GuardedAsyncInvoker::Flush(uint32 id) { |
+ rtc::CritScope cs(&crit_); |
+ if (thread_ != nullptr) |
+ invoker_.Flush(thread_, id); |
+} |
+ |
+void GuardedAsyncInvoker::ThreadDestroyed() { |
+ rtc::CritScope cs(&crit_); |
+ thread_ = nullptr; |
tommi (sloooow) - chröme
2015/08/19 20:01:54
should we DCHECK that thread_ is not nullptr first
magjed_webrtc
2015/08/20 10:28:33
Done.
|
+} |
+ |
NotifyingAsyncClosureBase::NotifyingAsyncClosureBase(AsyncInvoker* invoker, |
Thread* calling_thread) |
: invoker_(invoker), calling_thread_(calling_thread) { |