From 1a82d12b7b7654d8ec3a0e23ba96f8541695f180 Mon Sep 17 00:00:00 2001 From: HJfod <60038575+HJfod@users.noreply.github.com> Date: Sat, 24 Aug 2024 11:31:53 +0300 Subject: [PATCH] add Task::cancelled --- loader/include/Geode/utils/Task.hpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/loader/include/Geode/utils/Task.hpp b/loader/include/Geode/utils/Task.hpp index 38868bf1..d6691257 100644 --- a/loader/include/Geode/utils/Task.hpp +++ b/loader/include/Geode/utils/Task.hpp @@ -390,6 +390,15 @@ namespace geode { return m_handle == nullptr; } + /** + * Create a new Task that is immediately cancelled + * @param name The name of the Task; used for debugging + */ + static Task cancelled(std::string_view const name = "") { + auto task = Task(Handle::create(name)); + Task::cancel(task.m_handle); + return task; + } /** * Create a new Task that immediately finishes with the given * value