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

Unified Diff: webrtc/modules/utility/source/process_thread_impl.cc

Issue 2755273004: Add thread check to ModuleProcessThread::DeRegisterModule (Closed)
Patch Set: Remove TODO Created 3 years, 9 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 | « no previous file | webrtc/voice_engine/channel.h » ('j') | webrtc/voice_engine/channel.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/modules/utility/source/process_thread_impl.cc
diff --git a/webrtc/modules/utility/source/process_thread_impl.cc b/webrtc/modules/utility/source/process_thread_impl.cc
index 6252931544b1b7b0ee257b2b7da8b649ed65df39..7ea232786db878d33170b9d9cfef7160f3bb47c0 100644
--- a/webrtc/modules/utility/source/process_thread_impl.cc
+++ b/webrtc/modules/utility/source/process_thread_impl.cc
@@ -67,15 +67,8 @@ void ProcessThreadImpl::Start() {
RTC_DCHECK(!stop_);
- {
- // TODO(tommi): Since DeRegisterModule is currently being called from
- // different threads in some cases (ChannelOwner), we need to lock access to
- // the modules_ collection even on the controller thread.
- // Once we've cleaned up those places, we can remove this lock.
- rtc::CritScope lock(&lock_);
- for (ModuleCallback& m : modules_)
- m.module->ProcessThreadAttached(this);
- }
+ for (ModuleCallback& m : modules_)
+ m.module->ProcessThreadAttached(this);
thread_.reset(
new rtc::PlatformThread(&ProcessThreadImpl::Run, this, thread_name_));
@@ -97,13 +90,6 @@ void ProcessThreadImpl::Stop() {
thread_->Stop();
stop_ = false;
- // TODO(tommi): Since DeRegisterModule is currently being called from
- // different threads in some cases (ChannelOwner), we need to lock access to
- // the modules_ collection even on the controller thread.
- // Since DeRegisterModule also checks thread_, we also need to hold the
- // lock for the .reset() operation.
- // Once we've cleaned up those places, we can remove this lock.
- rtc::CritScope lock(&lock_);
thread_.reset();
for (ModuleCallback& m : modules_)
m.module->ProcessThreadAttached(nullptr);
@@ -162,8 +148,7 @@ void ProcessThreadImpl::RegisterModule(Module* module,
}
void ProcessThreadImpl::DeRegisterModule(Module* module) {
- // Allowed to be called on any thread.
- // TODO(tommi): Disallow this ^^^
+ RTC_DCHECK(thread_checker_.CalledOnValidThread());
RTC_DCHECK(module);
{
@@ -171,18 +156,10 @@ void ProcessThreadImpl::DeRegisterModule(Module* module) {
modules_.remove_if([&module](const ModuleCallback& m) {
return m.module == module;
});
-
- // TODO(tommi): we currently need to hold the lock while calling out to
- // ProcessThreadAttached. This is to make sure that the thread hasn't been
- // destroyed while we attach the module. Once we can make sure
- // DeRegisterModule isn't being called on arbitrary threads, we can move the
- // |if (thread_.get())| check and ProcessThreadAttached() call outside the
- // lock scope.
-
- // Notify the module that it's been detached.
- if (thread_.get())
- module->ProcessThreadAttached(nullptr);
}
+
+ // Notify the module that it's been detached.
+ module->ProcessThreadAttached(nullptr);
}
// static
« no previous file with comments | « no previous file | webrtc/voice_engine/channel.h » ('j') | webrtc/voice_engine/channel.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698