mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 15:52:07 +00:00
Bug 1661881 - Part 2: Make InputTaskManager a global singleton. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D89535
This commit is contained in:
parent
2594ec625f
commit
1dcbec6a4f
@ -8,6 +8,8 @@
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
StaticRefPtr<InputTaskManager> InputTaskManager::gInputTaskManager;
|
||||
|
||||
void InputTaskManager::EnableInputEventPrioritization() {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(mInputQueueState == STATE_DISABLED);
|
||||
@ -69,4 +71,15 @@ void InputTaskManager::DidRunTask() {
|
||||
InputEventStatistics::Get().UpdateInputDuration(TimeStamp::Now() - start);
|
||||
}
|
||||
|
||||
// static
|
||||
InputTaskManager* InputTaskManager::Get() {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
if (gInputTaskManager) {
|
||||
return gInputTaskManager.get();
|
||||
}
|
||||
|
||||
gInputTaskManager = new InputTaskManager();
|
||||
return gInputTaskManager.get();
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
|
@ -13,7 +13,6 @@ namespace mozilla {
|
||||
|
||||
class InputTaskManager : public TaskManager {
|
||||
public:
|
||||
InputTaskManager() : mInputQueueState(STATE_DISABLED) {}
|
||||
int32_t GetPriorityModifierForEventLoopTurn(
|
||||
const MutexAutoLock& aProofOfLock) final;
|
||||
void WillRunTask() final;
|
||||
@ -41,10 +40,17 @@ class InputTaskManager : public TaskManager {
|
||||
mInputHandlingStartTime = aStartTime;
|
||||
}
|
||||
|
||||
static InputTaskManager* Get();
|
||||
static void Cleanup() { gInputTaskManager = nullptr; }
|
||||
|
||||
private:
|
||||
InputTaskManager() : mInputQueueState(STATE_DISABLED) {}
|
||||
|
||||
TimeStamp mInputHandlingStartTime;
|
||||
Atomic<InputEventQueueState> mInputQueueState;
|
||||
AutoTArray<TimeStamp, 4> mStartTimes;
|
||||
|
||||
static StaticRefPtr<InputTaskManager> gInputTaskManager;
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
@ -26,7 +26,7 @@ PrioritizedEventQueue::PrioritizedEventQueue(
|
||||
mDeferredTimersQueue(
|
||||
MakeUnique<EventQueue>(EventQueuePriority::DeferredTimers)),
|
||||
mIdleQueue(MakeUnique<EventQueue>(EventQueuePriority::Idle)) {
|
||||
mInputTaskManager = new InputTaskManager();
|
||||
mInputTaskManager = InputTaskManager::Get();
|
||||
mIdleTaskManager = new IdleTaskManager(std::move(aIdlePeriod));
|
||||
TaskController::Get()->SetIdleTaskManager(mIdleTaskManager);
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include <initializer_list>
|
||||
#include "mozilla/AbstractEventQueue.h"
|
||||
#include "mozilla/BackgroundHangMonitor.h"
|
||||
#include "mozilla/InputTaskManager.h"
|
||||
#include "mozilla/StaticMutex.h"
|
||||
#include "mozilla/SchedulerGroup.h"
|
||||
#include "mozilla/ScopeExit.h"
|
||||
@ -95,6 +96,7 @@ void TaskController::SetPerformanceCounterState(
|
||||
|
||||
/* static */
|
||||
void TaskController::Shutdown() {
|
||||
InputTaskManager::Cleanup();
|
||||
if (sSingleton) {
|
||||
sSingleton->ShutdownInternal();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user