diff --git a/image/DecodePool.cpp b/image/DecodePool.cpp index 2781bcc5a314..b63322691452 100644 --- a/image/DecodePool.cpp +++ b/image/DecodePool.cpp @@ -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 diff --git a/js/xpconnect/src/XPCJSContext.cpp b/js/xpconnect/src/XPCJSContext.cpp index 9b5fcd84127c..e1e5a7ecef54 100644 --- a/js/xpconnect/src/XPCJSContext.cpp +++ b/js/xpconnect/src/XPCJSContext.cpp @@ -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) { diff --git a/widget/windows/nsWindow.cpp b/widget/windows/nsWindow.cpp index a1722c08e96e..e2e512b04393 100644 --- a/widget/windows/nsWindow.cpp +++ b/widget/windows/nsWindow.cpp @@ -608,17 +608,17 @@ class InitializeVirtualDesktopManagerTask : public Task { } #endif - virtual bool Run() override { + virtual TaskResult Run() override { RefPtr 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; } }; diff --git a/xpcom/threads/IdleTaskRunner.cpp b/xpcom/threads/IdleTaskRunner.cpp index 2a61877fa050..d1a571d089a7 100644 --- a/xpcom/threads/IdleTaskRunner.cpp +++ b/xpcom/threads/IdleTaskRunner.cpp @@ -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 runner(mRunner); runner->Run(); } - return true; + return TaskResult::Complete; } void SetIdleDeadline(TimeStamp aDeadline) override { diff --git a/xpcom/threads/TaskController.cpp b/xpcom/threads/TaskController.cpp index c617f43217ed..0bf7d3160a4a 100644 --- a/xpcom/threads/TaskController.cpp +++ b/xpcom/threads/TaskController.cpp @@ -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. diff --git a/xpcom/threads/TaskController.h b/xpcom/threads/TaskController.h index 5293604898bb..f51e61f4cd65 100644 --- a/xpcom/threads/TaskController.h +++ b/xpcom/threads/TaskController.h @@ -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();