зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset b99cc4960043 (bug 1839102) for causing build bustages in idget/windows/nsWindow.cpp CLOSED TREE
This commit is contained in:
Родитель
b47c5a6453
Коммит
e25db9b336
|
@ -137,9 +137,9 @@ bool DecodePool::IsShuttingDown() const { return mShuttingDown; }
|
|||
class DecodingTask final : public Task {
|
||||
public:
|
||||
explicit DecodingTask(RefPtr<IDecodingTask>&& aTask)
|
||||
: Task(Kind::OffMainThreadOnly, aTask->Priority() == TaskPriority::eLow
|
||||
? EventQueuePriority::Normal
|
||||
: EventQueuePriority::RenderBlocking),
|
||||
: Task(false, aTask->Priority() == TaskPriority::eLow
|
||||
? EventQueuePriority::Normal
|
||||
: EventQueuePriority::RenderBlocking),
|
||||
mTask(aTask) {}
|
||||
|
||||
bool Run() override {
|
||||
|
|
|
@ -1184,8 +1184,7 @@ class HelperThreadTaskHandler : public Task {
|
|||
JS::RunHelperThreadTask();
|
||||
return true;
|
||||
}
|
||||
explicit HelperThreadTaskHandler()
|
||||
: Task(Kind::OffMainThreadOnly, EventQueuePriority::Normal) {
|
||||
explicit HelperThreadTaskHandler() : Task(false, EventQueuePriority::Normal) {
|
||||
// Bug 1703185: Currently all tasks are run at the same priority.
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ already_AddRefed<IdleTaskRunner> IdleTaskRunner::Create(
|
|||
class IdleTaskRunnerTask : public Task {
|
||||
public:
|
||||
explicit IdleTaskRunnerTask(IdleTaskRunner* aRunner)
|
||||
: Task(Kind::MainThreadOnly, EventQueuePriority::Idle),
|
||||
: Task(true, EventQueuePriority::Idle),
|
||||
mRunner(aRunner),
|
||||
mRequestInterrupt(aRunner->mRequestInterrupt) {
|
||||
SetManager(TaskController::Get()->GetIdleTaskManager());
|
||||
|
|
|
@ -331,8 +331,7 @@ void TaskController::RunPoolThread() {
|
|||
task = nextTask;
|
||||
}
|
||||
|
||||
if (task->GetKind() == Task::Kind::MainThreadOnly ||
|
||||
task->mInProgress) {
|
||||
if (task->IsMainThreadOnly() || task->mInProgress) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -417,7 +416,7 @@ void TaskController::RunPoolThread() {
|
|||
void TaskController::AddTask(already_AddRefed<Task>&& aTask) {
|
||||
RefPtr<Task> task(aTask);
|
||||
|
||||
if (task->GetKind() == Task::Kind::OffMainThreadOnly) {
|
||||
if (!task->IsMainThreadOnly()) {
|
||||
MutexAutoLock lock(mPoolInitializationMutex);
|
||||
if (!mThreadPoolInitialized) {
|
||||
InitializeThreadPool();
|
||||
|
@ -454,13 +453,10 @@ void TaskController::AddTask(already_AddRefed<Task>&& aTask) {
|
|||
|
||||
std::pair<std::set<RefPtr<Task>, Task::PriorityCompare>::iterator, bool>
|
||||
insertion;
|
||||
switch (task->GetKind()) {
|
||||
case Task::Kind::MainThreadOnly:
|
||||
insertion = mMainThreadTasks.insert(std::move(task));
|
||||
break;
|
||||
case Task::Kind::OffMainThreadOnly:
|
||||
insertion = mThreadableTasks.insert(std::move(task));
|
||||
break;
|
||||
if (task->IsMainThreadOnly()) {
|
||||
insertion = mMainThreadTasks.insert(std::move(task));
|
||||
} else {
|
||||
insertion = mThreadableTasks.insert(std::move(task));
|
||||
}
|
||||
(*insertion.first)->mIterator = insertion.first;
|
||||
MOZ_ASSERT(insertion.second);
|
||||
|
@ -531,7 +527,7 @@ void TaskController::ProcessPendingMTTask(bool aMayWait) {
|
|||
void TaskController::ReprioritizeTask(Task* aTask, uint32_t aPriority) {
|
||||
MutexAutoLock lock(mGraphMutex);
|
||||
std::set<RefPtr<Task>, Task::PriorityCompare>* queue = &mMainThreadTasks;
|
||||
if (aTask->GetKind() == Task::Kind::OffMainThreadOnly) {
|
||||
if (!aTask->IsMainThreadOnly()) {
|
||||
queue = &mThreadableTasks;
|
||||
}
|
||||
|
||||
|
@ -552,8 +548,8 @@ void TaskController::ReprioritizeTask(Task* aTask, uint32_t aPriority) {
|
|||
class RunnableTask : public Task {
|
||||
public:
|
||||
RunnableTask(already_AddRefed<nsIRunnable>&& aRunnable, int32_t aPriority,
|
||||
Kind aKind)
|
||||
: Task(aKind, aPriority), mRunnable(aRunnable) {}
|
||||
bool aMainThread = true)
|
||||
: Task(aMainThread, aPriority), mRunnable(aRunnable) {}
|
||||
|
||||
virtual bool Run() override {
|
||||
mRunnable->Run();
|
||||
|
@ -591,8 +587,7 @@ class RunnableTask : public Task {
|
|||
void TaskController::DispatchRunnable(already_AddRefed<nsIRunnable>&& aRunnable,
|
||||
uint32_t aPriority,
|
||||
TaskManager* aManager) {
|
||||
RefPtr<RunnableTask> task = new RunnableTask(std::move(aRunnable), aPriority,
|
||||
Task::Kind::MainThreadOnly);
|
||||
RefPtr<RunnableTask> task = new RunnableTask(std::move(aRunnable), aPriority);
|
||||
|
||||
task->SetManager(aManager);
|
||||
TaskController::Get()->AddTask(task.forget());
|
||||
|
@ -817,8 +812,7 @@ bool TaskController::DoExecuteNextTaskOnlyMainThreadInternal(
|
|||
|
||||
task = GetFinalDependency(task);
|
||||
|
||||
if (task->GetKind() == Task::Kind::OffMainThreadOnly ||
|
||||
task->mInProgress ||
|
||||
if (!task->IsMainThreadOnly() || task->mInProgress ||
|
||||
(task->mTaskManager && task->mTaskManager->mCurrentSuspended)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -964,7 +958,7 @@ void TaskController::MaybeInterruptTask(Task* aTask) {
|
|||
Task* firstDependency = aTask->mDependencies.begin()->get();
|
||||
if (aTask->GetPriority() <= firstDependency->GetPriority() &&
|
||||
!firstDependency->mCompleted &&
|
||||
aTask->GetKind() == firstDependency->GetKind()) {
|
||||
aTask->IsMainThreadOnly() == firstDependency->IsMainThreadOnly()) {
|
||||
// This task has the same or a higher priority as one of its dependencies,
|
||||
// never any need to interrupt.
|
||||
return;
|
||||
|
@ -978,7 +972,7 @@ void TaskController::MaybeInterruptTask(Task* aTask) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (aTask->GetKind() == Task::Kind::MainThreadOnly) {
|
||||
if (aTask->IsMainThreadOnly()) {
|
||||
mMayHaveMainThreadTask = true;
|
||||
|
||||
EnsureMainThreadTasksScheduled();
|
||||
|
@ -989,7 +983,7 @@ void TaskController::MaybeInterruptTask(Task* aTask) {
|
|||
|
||||
// We could go through the steps above here and interrupt an off main
|
||||
// thread task in case it has a lower priority.
|
||||
if (finalDependency->GetKind() == Task::Kind::OffMainThreadOnly) {
|
||||
if (!finalDependency->IsMainThreadOnly()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -111,31 +111,16 @@ class TaskManager {
|
|||
};
|
||||
|
||||
// A Task is the the base class for any unit of work that may be scheduled.
|
||||
//
|
||||
// Subclasses may specify their priority and whether they should be bound to
|
||||
// either the Gecko Main thread or off main thread. When not bound to the main
|
||||
// thread tasks may be executed on any available thread excluding the main
|
||||
// thread, but they may also be executed in parallel to any other task they do
|
||||
// not have a dependency relationship with.
|
||||
//
|
||||
// Tasks will be run in order of object creation.
|
||||
// the Gecko Main thread. When not bound to the main thread tasks may be
|
||||
// executed on any available thread (including the main thread), but they may
|
||||
// also be executed in parallel to any other task they do not have a dependency
|
||||
// relationship with. Tasks will be run in order of object creation.
|
||||
class Task {
|
||||
public:
|
||||
enum class Kind : uint8_t {
|
||||
// This task should be executed on any available thread excluding the Gecko
|
||||
// Main thread.
|
||||
OffMainThreadOnly,
|
||||
|
||||
// This task should be executed on the Gecko Main thread.
|
||||
MainThreadOnly
|
||||
|
||||
// NOTE: "any available thread including the main thread" option is not
|
||||
// supported (See bug 1839102).
|
||||
};
|
||||
|
||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(Task)
|
||||
|
||||
Kind GetKind() { return mKind; }
|
||||
bool IsMainThreadOnly() { return mMainThreadOnly; }
|
||||
|
||||
// This returns the current task priority with its modifier applied.
|
||||
uint32_t GetPriority() { return mPriority + mPriorityModifier; }
|
||||
|
@ -163,7 +148,7 @@ class Task {
|
|||
// This sets the TaskManager for the current task. Calling this after the
|
||||
// task has been added to the TaskController results in undefined behavior.
|
||||
void SetManager(TaskManager* aManager) {
|
||||
MOZ_ASSERT(mKind == Kind::MainThreadOnly);
|
||||
MOZ_ASSERT(mMainThreadOnly);
|
||||
MOZ_ASSERT(!mIsInGraph);
|
||||
mTaskManager = aManager;
|
||||
}
|
||||
|
@ -193,12 +178,15 @@ class Task {
|
|||
#endif
|
||||
|
||||
protected:
|
||||
Task(Kind aKind,
|
||||
Task(bool aMainThreadOnly,
|
||||
uint32_t aPriority = static_cast<uint32_t>(kDefaultPriorityValue))
|
||||
: mKind(aKind), mSeqNo(sCurrentTaskSeqNo++), mPriority(aPriority) {}
|
||||
: mMainThreadOnly(aMainThreadOnly),
|
||||
mSeqNo(sCurrentTaskSeqNo++),
|
||||
mPriority(aPriority) {}
|
||||
|
||||
Task(Kind aKind, EventQueuePriority aPriority = kDefaultPriorityValue)
|
||||
: mKind(aKind),
|
||||
Task(bool aMainThreadOnly,
|
||||
EventQueuePriority aPriority = kDefaultPriorityValue)
|
||||
: mMainThreadOnly(aMainThreadOnly),
|
||||
mSeqNo(sCurrentTaskSeqNo++),
|
||||
mPriority(static_cast<uint32_t>(aPriority)) {}
|
||||
|
||||
|
@ -232,7 +220,7 @@ class Task {
|
|||
RefPtr<TaskManager> mTaskManager;
|
||||
|
||||
// Access to these variables is protected by the GraphMutex.
|
||||
Kind mKind;
|
||||
bool mMainThreadOnly;
|
||||
bool mCompleted = false;
|
||||
bool mInProgress = false;
|
||||
#ifdef DEBUG
|
||||
|
|
Загрузка…
Ссылка в новой задаче