зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1846407 - Use enum class for Task::Run return value. r=bas,win-reviewers,rkraesig
Differential Revision: https://phabricator.services.mozilla.com/D185043
This commit is contained in:
Родитель
e63c54d99e
Коммит
0054ab3127
|
@ -1606,14 +1606,14 @@ class OffThreadCompilationCompleteTask : public Task {
|
|||
}
|
||||
#endif
|
||||
|
||||
bool Run() override {
|
||||
TaskResult Run() override {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
RefPtr<ScriptLoadContext> context = mRequest->GetScriptLoadContext();
|
||||
|
||||
if (!context->mCompileOrDecodeTask) {
|
||||
// Request has been cancelled by MaybeCancelOffThreadScript.
|
||||
return true;
|
||||
return TaskResult::Complete;
|
||||
}
|
||||
|
||||
RecordStopTime();
|
||||
|
@ -1638,7 +1638,7 @@ class OffThreadCompilationCompleteTask : public Task {
|
|||
|
||||
mRequest = nullptr;
|
||||
mLoader = nullptr;
|
||||
return true;
|
||||
return TaskResult::Complete;
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -1857,17 +1857,17 @@ class ScriptOrModuleCompileTask final : public CompileOrDecodeTask {
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
bool Run() override {
|
||||
TaskResult Run() override {
|
||||
MutexAutoLock lock(mMutex);
|
||||
|
||||
if (IsCancelled(lock)) {
|
||||
return true;
|
||||
return TaskResult::Complete;
|
||||
}
|
||||
|
||||
RefPtr<JS::Stencil> stencil = Compile();
|
||||
|
||||
DidRunTask(lock, std::move(stencil));
|
||||
return true;
|
||||
return TaskResult::Complete;
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -1932,11 +1932,11 @@ class ScriptDecodeTask final : public CompileOrDecodeTask {
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
bool Run() override {
|
||||
TaskResult Run() override {
|
||||
MutexAutoLock lock(mMutex);
|
||||
|
||||
if (IsCancelled(lock)) {
|
||||
return true;
|
||||
return TaskResult::Complete;
|
||||
}
|
||||
|
||||
RefPtr<JS::Stencil> stencil = Decode();
|
||||
|
@ -1946,7 +1946,7 @@ class ScriptDecodeTask final : public CompileOrDecodeTask {
|
|||
mOptions.steal(std::move(mDecodeOptions));
|
||||
|
||||
DidRunTask(lock, std::move(stencil));
|
||||
return true;
|
||||
return TaskResult::Complete;
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
@ -1885,9 +1885,9 @@ class ScriptCompileTask final : public Task {
|
|||
}
|
||||
|
||||
public:
|
||||
bool Run() override {
|
||||
TaskResult Run() override {
|
||||
Compile();
|
||||
return true;
|
||||
return TaskResult::Complete;
|
||||
}
|
||||
|
||||
already_AddRefed<JS::Stencil> StealStencil() { return mStencil.forget(); }
|
||||
|
@ -1923,11 +1923,11 @@ class NotifyOffThreadScriptCompletedTask : public Task {
|
|||
mReceiver(aReceiver),
|
||||
mCompileTask(aCompileTask) {}
|
||||
|
||||
bool Run() override {
|
||||
TaskResult Run() override {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
if (PastShutdownPhase(ShutdownPhase::XPCOMShutdownFinal)) {
|
||||
return true;
|
||||
return TaskResult::Complete;
|
||||
}
|
||||
|
||||
RefPtr<JS::Stencil> stencil = mCompileTask->StealStencil();
|
||||
|
@ -1936,7 +1936,7 @@ class NotifyOffThreadScriptCompletedTask : public Task {
|
|||
(void)mReceiver->OnScriptCompileComplete(
|
||||
stencil, stencil ? NS_OK : NS_ERROR_FAILURE);
|
||||
|
||||
return true;
|
||||
return TaskResult::Complete;
|
||||
}
|
||||
|
||||
#ifdef MOZ_COLLECTING_RUNNABLE_TELEMETRY
|
||||
|
|
|
@ -142,9 +142,9 @@ class DecodingTask final : public Task {
|
|||
: EventQueuePriority::RenderBlocking),
|
||||
mTask(aTask) {}
|
||||
|
||||
bool Run() override {
|
||||
TaskResult Run() override {
|
||||
mTask->Run();
|
||||
return true;
|
||||
return TaskResult::Complete;
|
||||
}
|
||||
|
||||
#ifdef MOZ_COLLECTING_RUNNABLE_TELEMETRY
|
||||
|
|
|
@ -143,15 +143,15 @@ class AsyncScriptCompileTask final : public Task {
|
|||
}
|
||||
|
||||
public:
|
||||
bool Run() override {
|
||||
TaskResult Run() override {
|
||||
MutexAutoLock lock(mMutex);
|
||||
|
||||
if (mIsCancelled) {
|
||||
return true;
|
||||
return TaskResult::Complete;
|
||||
}
|
||||
|
||||
Compile();
|
||||
return true;
|
||||
return TaskResult::Complete;
|
||||
}
|
||||
|
||||
already_AddRefed<JS::Stencil> StealStencil(JSContext* aCx) {
|
||||
|
@ -227,7 +227,7 @@ class AsyncScriptCompilationCompleteTask : public Task {
|
|||
}
|
||||
#endif
|
||||
|
||||
bool Run() override;
|
||||
TaskResult Run() override;
|
||||
|
||||
private:
|
||||
// NOTE:
|
||||
|
@ -379,11 +379,11 @@ bool AsyncScriptCompiler::StartOffThreadCompile(
|
|||
return true;
|
||||
}
|
||||
|
||||
bool AsyncScriptCompilationCompleteTask::Run() {
|
||||
Task::TaskResult AsyncScriptCompilationCompleteTask::Run() {
|
||||
mCompiler->OnCompilationComplete(mCompileTask.get());
|
||||
mCompiler = nullptr;
|
||||
mCompileTask = nullptr;
|
||||
return true;
|
||||
return TaskResult::Complete;
|
||||
}
|
||||
|
||||
void AsyncScriptCompiler::OnCompilationComplete(
|
||||
|
|
|
@ -1165,9 +1165,9 @@ CycleCollectedJSRuntime* XPCJSContext::CreateRuntime(JSContext* aCx) {
|
|||
|
||||
class HelperThreadTaskHandler : public Task {
|
||||
public:
|
||||
bool Run() override {
|
||||
TaskResult Run() override {
|
||||
JS::RunHelperThreadTask();
|
||||
return true;
|
||||
return TaskResult::Complete;
|
||||
}
|
||||
explicit HelperThreadTaskHandler()
|
||||
: Task(Kind::OffMainThreadOnly, EventQueuePriority::Normal) {
|
||||
|
|
|
@ -608,17 +608,17 @@ class InitializeVirtualDesktopManagerTask : public Task {
|
|||
}
|
||||
#endif
|
||||
|
||||
virtual bool Run() override {
|
||||
virtual TaskResult Run() override {
|
||||
RefPtr<IVirtualDesktopManager> desktopManager;
|
||||
HRESULT hr = ::CoCreateInstance(
|
||||
CLSID_VirtualDesktopManager, NULL, CLSCTX_INPROC_SERVER,
|
||||
__uuidof(IVirtualDesktopManager), getter_AddRefs(desktopManager));
|
||||
if (FAILED(hr)) {
|
||||
return true;
|
||||
return TaskResult::Complete;
|
||||
}
|
||||
|
||||
gVirtualDesktopManager = desktopManager;
|
||||
return true;
|
||||
return TaskResult::Complete;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ class IdleTaskRunnerTask : public Task {
|
|||
SetManager(TaskController::Get()->GetIdleTaskManager());
|
||||
}
|
||||
|
||||
bool Run() override {
|
||||
TaskResult Run() override {
|
||||
if (mRunner) {
|
||||
// IdleTaskRunner::Run can actually trigger the destruction of the
|
||||
// IdleTaskRunner. Make sure it doesn't get destroyed before the method
|
||||
|
@ -44,7 +44,7 @@ class IdleTaskRunnerTask : public Task {
|
|||
RefPtr<IdleTaskRunner> runner(mRunner);
|
||||
runner->Run();
|
||||
}
|
||||
return true;
|
||||
return TaskResult::Complete;
|
||||
}
|
||||
|
||||
void SetIdleDeadline(TimeStamp aDeadline) override {
|
||||
|
|
|
@ -344,7 +344,7 @@ void TaskController::RunPoolThread() {
|
|||
MutexAutoUnlock unlock(mGraphMutex);
|
||||
lastTask = nullptr;
|
||||
AUTO_PROFILE_FOLLOWING_TASK(task);
|
||||
taskCompleted = task->Run();
|
||||
taskCompleted = task->Run() == Task::TaskResult::Complete;
|
||||
ranTask = true;
|
||||
}
|
||||
|
||||
|
@ -545,10 +545,10 @@ class RunnableTask : public Task {
|
|||
Kind aKind)
|
||||
: Task(aKind, aPriority), mRunnable(aRunnable) {}
|
||||
|
||||
virtual bool Run() override {
|
||||
virtual TaskResult Run() override {
|
||||
mRunnable->Run();
|
||||
mRunnable = nullptr;
|
||||
return true;
|
||||
return TaskResult::Complete;
|
||||
}
|
||||
|
||||
void SetIdleDeadline(TimeStamp aDeadline) override {
|
||||
|
@ -873,7 +873,7 @@ bool TaskController::DoExecuteNextTaskOnlyMainThreadInternal(
|
|||
AutoSetMainThreadRunnableName nameGuard(name);
|
||||
#endif
|
||||
AUTO_PROFILE_FOLLOWING_TASK(task);
|
||||
result = task->Run();
|
||||
result = task->Run() == Task::TaskResult::Complete;
|
||||
}
|
||||
|
||||
// Task itself should keep manager alive.
|
||||
|
|
|
@ -203,9 +203,14 @@ class Task {
|
|||
|
||||
friend class TaskController;
|
||||
|
||||
// When this returns false, the task is considered incomplete and will be
|
||||
// rescheduled at the current 'mPriority' level.
|
||||
virtual bool Run() = 0;
|
||||
enum class TaskResult {
|
||||
Complete,
|
||||
Incomplete,
|
||||
};
|
||||
|
||||
// When this returns TaskResult::Incomplete, it will be rescheduled at the
|
||||
// current 'mPriority' level.
|
||||
virtual TaskResult Run() = 0;
|
||||
|
||||
private:
|
||||
Task* GetHighestPriorityDependency();
|
||||
|
|
Загрузка…
Ссылка в новой задаче