зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1634253 - P2. Dissociate running a BackgroundHangMonitor from main thread. r=froydnj
This will allow to have other threads to use one such as the compositor thread. Differential Revision: https://phabricator.services.mozilla.com/D73820
This commit is contained in:
Родитель
151a0ccd4e
Коммит
d792bf2e0c
|
@ -588,6 +588,7 @@ nsThread::nsThread(NotNull<SynchronizedEventQueue*> aQueue,
|
|||
mShutdownRequired(false),
|
||||
mPriority(PRIORITY_NORMAL),
|
||||
mIsMainThread(aMainThread == MAIN_THREAD),
|
||||
mUseHangMonitor(aMainThread == MAIN_THREAD),
|
||||
mIsAPoolThreadFree(nullptr),
|
||||
mCanInvokeJS(false),
|
||||
#ifdef EARLY_BETA_OR_EARLIER
|
||||
|
@ -606,6 +607,7 @@ nsThread::nsThread()
|
|||
mShutdownRequired(false),
|
||||
mPriority(PRIORITY_NORMAL),
|
||||
mIsMainThread(false),
|
||||
mUseHangMonitor(false),
|
||||
mCanInvokeJS(false),
|
||||
#ifdef EARLY_BETA_OR_EARLIER
|
||||
mLastWakeupCheckTime(TimeStamp::Now()),
|
||||
|
@ -1077,8 +1079,13 @@ nsThread::ProcessNextEvent(bool aMayWait, bool* aResult) {
|
|||
}
|
||||
|
||||
Maybe<dom::AutoNoJSAPI> noJSAPI;
|
||||
|
||||
if (mUseHangMonitor && reallyWait) {
|
||||
BackgroundHangMonitor().NotifyWait();
|
||||
}
|
||||
|
||||
if (mIsMainThread) {
|
||||
DoMainThreadSpecificProcessing(reallyWait);
|
||||
DoMainThreadSpecificProcessing();
|
||||
}
|
||||
|
||||
++mNestedEventLoopDepth;
|
||||
|
@ -1155,7 +1162,7 @@ nsThread::ProcessNextEvent(bool aMayWait, bool* aResult) {
|
|||
|
||||
mozilla::TimeStamp now = mozilla::TimeStamp::Now();
|
||||
|
||||
if (mIsMainThread) {
|
||||
if (mUseHangMonitor) {
|
||||
BackgroundHangMonitor().NotifyActivity();
|
||||
}
|
||||
|
||||
|
@ -1352,15 +1359,11 @@ void nsThread::SetScriptObserver(
|
|||
mScriptObserver = aScriptObserver;
|
||||
}
|
||||
|
||||
void nsThread::DoMainThreadSpecificProcessing(bool aReallyWait) const {
|
||||
void nsThread::DoMainThreadSpecificProcessing() const {
|
||||
MOZ_ASSERT(mIsMainThread);
|
||||
|
||||
ipc::CancelCPOWs();
|
||||
|
||||
if (aReallyWait) {
|
||||
BackgroundHangMonitor().NotifyWait();
|
||||
}
|
||||
|
||||
// Fire a memory pressure notification, if one is pending.
|
||||
if (!ShuttingDown()) {
|
||||
MemoryPressureState mpPending = NS_GetPendingMemoryPressure();
|
||||
|
|
|
@ -257,8 +257,13 @@ class nsThread : public nsIThreadInternal,
|
|||
// notifications, etc.
|
||||
nsLocalExecutionRecord EnterLocalExecution();
|
||||
|
||||
void SetUseHangMonitor(bool aValue) {
|
||||
MOZ_ASSERT(IsOnCurrentThread());
|
||||
mUseHangMonitor = aValue;
|
||||
}
|
||||
|
||||
private:
|
||||
void DoMainThreadSpecificProcessing(bool aReallyWait) const;
|
||||
void DoMainThreadSpecificProcessing() const;
|
||||
|
||||
protected:
|
||||
friend class nsThreadShutdownEvent;
|
||||
|
@ -329,6 +334,7 @@ class nsThread : public nsIThreadInternal,
|
|||
int8_t mPriority;
|
||||
|
||||
const bool mIsMainThread;
|
||||
bool mUseHangMonitor;
|
||||
mozilla::Atomic<bool, mozilla::Relaxed>* mIsAPoolThreadFree;
|
||||
|
||||
// Set to true if this thread creates a JSRuntime.
|
||||
|
|
Загрузка…
Ссылка в новой задаче