Add thread annotations and docs in ProcessThreadImpl.

Bug: webrtc:11567
Change-Id: Ib6b635f658aeecd43cf4ea66e517b7f2caa14022
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/206465
Commit-Queue: Niels Moller <nisse@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Tommi <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33312}
This commit is contained in:
Niels Möller
2021-02-22 10:36:29 +01:00
committed by Commit Bot
parent bc9dc5a0b0
commit 2bfddf78d2
2 changed files with 26 additions and 12 deletions

View File

@ -69,7 +69,8 @@ void ProcessThreadImpl::Delete() {
delete this;
}
void ProcessThreadImpl::Start() {
// Doesn't need locking, because the contending thread isn't running.
void ProcessThreadImpl::Start() RTC_NO_THREAD_SAFETY_ANALYSIS {
RTC_DCHECK(thread_checker_.IsCurrent());
RTC_DCHECK(!thread_.get());
if (thread_.get())
@ -91,6 +92,7 @@ void ProcessThreadImpl::Stop() {
return;
{
// Need to take lock, for synchronization with `thread_`.
rtc::CritScope lock(&lock_);
stop_ = true;
}
@ -98,9 +100,17 @@ void ProcessThreadImpl::Stop() {
wake_up_.Set();
thread_->Stop();
thread_.reset();
StopNoLocks();
}
// No locking needed, since this is called after the contending thread is
// stopped.
void ProcessThreadImpl::StopNoLocks() RTC_NO_THREAD_SAFETY_ANALYSIS {
RTC_DCHECK(!thread_);
stop_ = false;
thread_.reset();
for (ModuleCallback& m : modules_)
m.module->ProcessThreadAttached(nullptr);
}