зеркало из 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:
Родитель
27e306d932
Коммит
091001f4a1
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
|
|
Загрузка…
Ссылка в новой задаче