Bug 1760647 - nsStreamTransportService thread-safety annotations r=necko-reviewers,dragana

Differential Revision: https://phabricator.services.mozilla.com/D141656
This commit is contained in:
Randell Jesup 2022-03-21 21:35:53 +00:00
parent d956dfa608
commit 0ba3cb38b1
2 changed files with 5 additions and 4 deletions

View File

@ -252,6 +252,7 @@ nsStreamTransportService::~nsStreamTransportService() {
nsresult nsStreamTransportService::Init() {
// Can't be used multithreaded before this
PUSH_IGNORE_THREAD_SAFETY
MOZ_ASSERT(!mPool);
mPool = new nsThreadPool();
@ -261,6 +262,7 @@ nsresult nsStreamTransportService::Init() {
mPool->SetIdleThreadLimit(5);
mPool->SetIdleThreadTimeoutRegressive(true);
mPool->SetIdleThreadTimeout(PR_SecondsToInterval(30));
POP_THREAD_SAFETY
nsCOMPtr<nsIObserverService> obsSvc = mozilla::services::GetObserverService();
if (obsSvc) obsSvc->AddObserver(this, "xpcom-shutdown-threads", false);

View File

@ -45,13 +45,12 @@ class nsStreamTransportService final : public nsIStreamTransportService,
private:
~nsStreamTransportService();
nsCOMPtr<nsIThreadPool> mPool;
nsCOMPtr<nsIThreadPool> mPool GUARDED_BY(mShutdownLock);
DataMutex<nsTArray<RefPtr<DelayedRunnable>>> mScheduledDelayedRunnables;
mozilla::Mutex mShutdownLock MOZ_UNANNOTATED{
"nsStreamTransportService.mShutdownLock"};
bool mIsShutdown{false};
mozilla::Mutex mShutdownLock{"nsStreamTransportService.mShutdownLock"};
bool mIsShutdown GUARDED_BY(mShutdownLock) {false};
};
} // namespace net