From 69cbe1e40589bb76b725facdfb324076f8f40e33 Mon Sep 17 00:00:00 2001 From: retrooper Date: Tue, 8 Jul 2025 19:39:19 +0200 Subject: [PATCH] Revert "Refactor TaskWrapper into interface and implementation classes" --- .../util/folia/AsyncScheduler.java | 19 ++--- .../util/folia/EntityScheduler.java | 15 ++-- .../util/folia/GlobalRegionScheduler.java | 15 ++-- .../util/folia/RegionScheduler.java | 27 +++--- .../packetevents/util/folia/TaskWrapper.java | 82 +++++++++++++++++++ .../util/folia/task/BukkitTaskWrapper.java | 48 ----------- .../util/folia/task/FoliaTaskWrapper.java | 48 ----------- .../util/folia/task/TaskWrapper.java | 47 ----------- 8 files changed, 114 insertions(+), 187 deletions(-) create mode 100644 spigot/src/main/java/io/github/retrooper/packetevents/util/folia/TaskWrapper.java delete mode 100644 spigot/src/main/java/io/github/retrooper/packetevents/util/folia/task/BukkitTaskWrapper.java delete mode 100644 spigot/src/main/java/io/github/retrooper/packetevents/util/folia/task/FoliaTaskWrapper.java delete mode 100644 spigot/src/main/java/io/github/retrooper/packetevents/util/folia/task/TaskWrapper.java diff --git a/spigot/src/main/java/io/github/retrooper/packetevents/util/folia/AsyncScheduler.java b/spigot/src/main/java/io/github/retrooper/packetevents/util/folia/AsyncScheduler.java index 8f858d614..a6f8bf293 100644 --- a/spigot/src/main/java/io/github/retrooper/packetevents/util/folia/AsyncScheduler.java +++ b/spigot/src/main/java/io/github/retrooper/packetevents/util/folia/AsyncScheduler.java @@ -18,9 +18,6 @@ package io.github.retrooper.packetevents.util.folia; -import io.github.retrooper.packetevents.util.folia.task.BukkitTaskWrapper; -import io.github.retrooper.packetevents.util.folia.task.FoliaTaskWrapper; -import io.github.retrooper.packetevents.util.folia.task.TaskWrapper; import org.bukkit.Bukkit; import org.bukkit.plugin.Plugin; import org.bukkit.scheduler.BukkitScheduler; @@ -54,10 +51,10 @@ public class AsyncScheduler { */ public TaskWrapper runNow(@NotNull Plugin plugin, @NotNull Consumer task) { if (!FoliaScheduler.isFolia) { - return new BukkitTaskWrapper(bukkitScheduler.runTaskAsynchronously(plugin, () -> task.accept(null))); + return new TaskWrapper(bukkitScheduler.runTaskAsynchronously(plugin, () -> task.accept(null))); } - return new FoliaTaskWrapper(asyncScheduler.runNow(plugin, (o) -> task.accept(null))); + return new TaskWrapper(asyncScheduler.runNow(plugin, (o) -> task.accept(null))); } /** @@ -71,10 +68,10 @@ public class AsyncScheduler { */ public TaskWrapper runDelayed(@NotNull Plugin plugin, @NotNull Consumer task, long delay, @NotNull TimeUnit timeUnit) { if (!FoliaScheduler.isFolia) { - return new BukkitTaskWrapper(bukkitScheduler.runTaskLaterAsynchronously(plugin, () -> task.accept(null), convertTimeToTicks(delay, timeUnit))); + return new TaskWrapper(bukkitScheduler.runTaskLaterAsynchronously(plugin, () -> task.accept(null), convertTimeToTicks(delay, timeUnit))); } - return new FoliaTaskWrapper(asyncScheduler.runDelayed(plugin, (o) -> task.accept(null), delay, timeUnit)); + return new TaskWrapper(asyncScheduler.runDelayed(plugin, (o) -> task.accept(null), delay, timeUnit)); } /** @@ -91,10 +88,10 @@ public class AsyncScheduler { if (period < 1) period = 1; if (!FoliaScheduler.isFolia) { - return new BukkitTaskWrapper(bukkitScheduler.runTaskTimerAsynchronously(plugin, () -> task.accept(null), convertTimeToTicks(delay, timeUnit), convertTimeToTicks(period, timeUnit))); + return new TaskWrapper(bukkitScheduler.runTaskTimerAsynchronously(plugin, () -> task.accept(null), convertTimeToTicks(delay, timeUnit), convertTimeToTicks(period, timeUnit))); } - return new FoliaTaskWrapper(asyncScheduler.runAtFixedRate(plugin, (o) -> task.accept(null), delay, period, timeUnit)); + return new TaskWrapper(asyncScheduler.runAtFixedRate(plugin, (o) -> task.accept(null), delay, period, timeUnit)); } /** @@ -110,10 +107,10 @@ public class AsyncScheduler { if (periodTicks < 1) periodTicks = 1; if (!FoliaScheduler.isFolia) { - return new BukkitTaskWrapper(bukkitScheduler.runTaskTimerAsynchronously(plugin, () -> task.accept(null), initialDelayTicks, periodTicks)); + return new TaskWrapper(bukkitScheduler.runTaskTimerAsynchronously(plugin, () -> task.accept(null), initialDelayTicks, periodTicks)); } - return new FoliaTaskWrapper(asyncScheduler.runAtFixedRate(plugin, (o) -> task.accept(null), initialDelayTicks * 50, periodTicks * 50, TimeUnit.MILLISECONDS)); + return new TaskWrapper(asyncScheduler.runAtFixedRate(plugin, (o) -> task.accept(null), initialDelayTicks * 50, periodTicks * 50, TimeUnit.MILLISECONDS)); } /** diff --git a/spigot/src/main/java/io/github/retrooper/packetevents/util/folia/EntityScheduler.java b/spigot/src/main/java/io/github/retrooper/packetevents/util/folia/EntityScheduler.java index 0e83864ae..ee427ceef 100644 --- a/spigot/src/main/java/io/github/retrooper/packetevents/util/folia/EntityScheduler.java +++ b/spigot/src/main/java/io/github/retrooper/packetevents/util/folia/EntityScheduler.java @@ -18,9 +18,6 @@ package io.github.retrooper.packetevents.util.folia; -import io.github.retrooper.packetevents.util.folia.task.BukkitTaskWrapper; -import io.github.retrooper.packetevents.util.folia.task.FoliaTaskWrapper; -import io.github.retrooper.packetevents.util.folia.task.TaskWrapper; import org.bukkit.Bukkit; import org.bukkit.entity.Entity; import org.bukkit.plugin.Plugin; @@ -80,10 +77,10 @@ public class EntityScheduler { */ public TaskWrapper run(@NotNull Entity entity, @NotNull Plugin plugin, @NotNull Consumer task, @Nullable Runnable retired) { if (!FoliaScheduler.isFolia) { - return new BukkitTaskWrapper(bukkitScheduler.runTask(plugin, () -> task.accept(null))); + return new TaskWrapper(bukkitScheduler.runTask(plugin, () -> task.accept(null))); } - return new FoliaTaskWrapper(entity.getScheduler().run(plugin, (o) -> task.accept(null), retired)); + return new TaskWrapper(entity.getScheduler().run(plugin, (o) -> task.accept(null), retired)); } /** @@ -104,10 +101,10 @@ public class EntityScheduler { if (delayTicks < 1) delayTicks = 1; if (!FoliaScheduler.isFolia) { - return new BukkitTaskWrapper(bukkitScheduler.runTaskLater(plugin, () -> task.accept(null), delayTicks)); + return new TaskWrapper(bukkitScheduler.runTaskLater(plugin, () -> task.accept(null), delayTicks)); } - return new FoliaTaskWrapper(entity.getScheduler().runDelayed(plugin, (o) -> task.accept(null), retired, delayTicks)); + return new TaskWrapper(entity.getScheduler().runDelayed(plugin, (o) -> task.accept(null), retired, delayTicks)); } /** @@ -130,9 +127,9 @@ public class EntityScheduler { if (periodTicks < 1) periodTicks = 1; if (!FoliaScheduler.isFolia) { - return new BukkitTaskWrapper(bukkitScheduler.runTaskTimer(plugin, () -> task.accept(null), initialDelayTicks, periodTicks)); + return new TaskWrapper(bukkitScheduler.runTaskTimer(plugin, () -> task.accept(null), initialDelayTicks, periodTicks)); } - return new FoliaTaskWrapper(entity.getScheduler().runAtFixedRate(plugin, (o) -> task.accept(null), retired, initialDelayTicks, periodTicks)); + return new TaskWrapper(entity.getScheduler().runAtFixedRate(plugin, (o) -> task.accept(null), retired, initialDelayTicks, periodTicks)); } } \ No newline at end of file diff --git a/spigot/src/main/java/io/github/retrooper/packetevents/util/folia/GlobalRegionScheduler.java b/spigot/src/main/java/io/github/retrooper/packetevents/util/folia/GlobalRegionScheduler.java index a33d36432..cae50ab10 100644 --- a/spigot/src/main/java/io/github/retrooper/packetevents/util/folia/GlobalRegionScheduler.java +++ b/spigot/src/main/java/io/github/retrooper/packetevents/util/folia/GlobalRegionScheduler.java @@ -18,9 +18,6 @@ package io.github.retrooper.packetevents.util.folia; -import io.github.retrooper.packetevents.util.folia.task.BukkitTaskWrapper; -import io.github.retrooper.packetevents.util.folia.task.FoliaTaskWrapper; -import io.github.retrooper.packetevents.util.folia.task.TaskWrapper; import org.bukkit.Bukkit; import org.bukkit.plugin.Plugin; import org.bukkit.scheduler.BukkitScheduler; @@ -68,10 +65,10 @@ public class GlobalRegionScheduler { */ public TaskWrapper run(@NotNull Plugin plugin, @NotNull Consumer task) { if (!FoliaScheduler.isFolia) { - return new BukkitTaskWrapper(bukkitScheduler.runTask(plugin, () -> task.accept(null))); + return new TaskWrapper(bukkitScheduler.runTask(plugin, () -> task.accept(null))); } - return new FoliaTaskWrapper(globalRegionScheduler.run(plugin, (o) -> task.accept(null))); + return new TaskWrapper(globalRegionScheduler.run(plugin, (o) -> task.accept(null))); } /** @@ -86,10 +83,10 @@ public class GlobalRegionScheduler { if (delay < 1) delay = 1; if (!FoliaScheduler.isFolia) { - return new BukkitTaskWrapper(bukkitScheduler.runTaskLater(plugin, () -> task.accept(null), delay)); + return new TaskWrapper(bukkitScheduler.runTaskLater(plugin, () -> task.accept(null), delay)); } - return new FoliaTaskWrapper(globalRegionScheduler.runDelayed(plugin, (o) -> task.accept(null), delay)); + return new TaskWrapper(globalRegionScheduler.runDelayed(plugin, (o) -> task.accept(null), delay)); } /** @@ -106,10 +103,10 @@ public class GlobalRegionScheduler { if (periodTicks < 1) periodTicks = 1; if (!FoliaScheduler.isFolia) { - return new BukkitTaskWrapper(bukkitScheduler.runTaskTimer(plugin, () -> task.accept(null), initialDelayTicks, periodTicks)); + return new TaskWrapper(bukkitScheduler.runTaskTimer(plugin, () -> task.accept(null), initialDelayTicks, periodTicks)); } - return new FoliaTaskWrapper(globalRegionScheduler.runAtFixedRate(plugin, (o) -> task.accept(null), initialDelayTicks, periodTicks)); + return new TaskWrapper(globalRegionScheduler.runAtFixedRate(plugin, (o) -> task.accept(null), initialDelayTicks, periodTicks)); } /** diff --git a/spigot/src/main/java/io/github/retrooper/packetevents/util/folia/RegionScheduler.java b/spigot/src/main/java/io/github/retrooper/packetevents/util/folia/RegionScheduler.java index d2e6d11b4..521c2d992 100644 --- a/spigot/src/main/java/io/github/retrooper/packetevents/util/folia/RegionScheduler.java +++ b/spigot/src/main/java/io/github/retrooper/packetevents/util/folia/RegionScheduler.java @@ -18,9 +18,6 @@ package io.github.retrooper.packetevents.util.folia; -import io.github.retrooper.packetevents.util.folia.task.BukkitTaskWrapper; -import io.github.retrooper.packetevents.util.folia.task.FoliaTaskWrapper; -import io.github.retrooper.packetevents.util.folia.task.TaskWrapper; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.World; @@ -92,10 +89,10 @@ public class RegionScheduler { */ public TaskWrapper run(@NotNull Plugin plugin, @NotNull World world, int chunkX, int chunkZ, @NotNull Consumer task) { if (!FoliaScheduler.isFolia) { - return new BukkitTaskWrapper(Bukkit.getScheduler().runTask(plugin, () -> task.accept(null))); + return new TaskWrapper(Bukkit.getScheduler().runTask(plugin, () -> task.accept(null))); } - return new FoliaTaskWrapper(regionScheduler.run(plugin, world, chunkX, chunkZ, (o) -> task.accept(null))); + return new TaskWrapper(regionScheduler.run(plugin, world, chunkX, chunkZ, (o) -> task.accept(null))); } /** @@ -108,10 +105,10 @@ public class RegionScheduler { */ public TaskWrapper run(@NotNull Plugin plugin, @NotNull Location location, @NotNull Consumer task) { if (!FoliaScheduler.isFolia) { - return new BukkitTaskWrapper(Bukkit.getScheduler().runTask(plugin, () -> task.accept(null))); + return new TaskWrapper(Bukkit.getScheduler().runTask(plugin, () -> task.accept(null))); } - return new FoliaTaskWrapper(regionScheduler.run(plugin, location, (o) -> task.accept(null))); + return new TaskWrapper(regionScheduler.run(plugin, location, (o) -> task.accept(null))); } /** @@ -129,10 +126,10 @@ public class RegionScheduler { if (delayTicks < 1) delayTicks = 1; if (!FoliaScheduler.isFolia) { - return new BukkitTaskWrapper(Bukkit.getScheduler().runTaskLater(plugin, () -> task.accept(null), delayTicks)); + return new TaskWrapper(Bukkit.getScheduler().runTaskLater(plugin, () -> task.accept(null), delayTicks)); } - return new FoliaTaskWrapper(regionScheduler.runDelayed(plugin, world, chunkX, chunkZ, (o) -> task.accept(null), delayTicks)); + return new TaskWrapper(regionScheduler.runDelayed(plugin, world, chunkX, chunkZ, (o) -> task.accept(null), delayTicks)); } /** @@ -148,10 +145,10 @@ public class RegionScheduler { if (delayTicks < 1) delayTicks = 1; if (!FoliaScheduler.isFolia) { - return new BukkitTaskWrapper(Bukkit.getScheduler().runTaskLater(plugin, () -> task.accept(null), delayTicks)); + return new TaskWrapper(Bukkit.getScheduler().runTaskLater(plugin, () -> task.accept(null), delayTicks)); } - return new FoliaTaskWrapper(regionScheduler.runDelayed(plugin, location, (o) -> task.accept(null), delayTicks)); + return new TaskWrapper(regionScheduler.runDelayed(plugin, location, (o) -> task.accept(null), delayTicks)); } /** @@ -171,10 +168,10 @@ public class RegionScheduler { if (periodTicks < 1) periodTicks = 1; if (!FoliaScheduler.isFolia) { - return new BukkitTaskWrapper(Bukkit.getScheduler().runTaskTimer(plugin, () -> task.accept(null), initialDelayTicks, periodTicks)); + return new TaskWrapper(Bukkit.getScheduler().runTaskTimer(plugin, () -> task.accept(null), initialDelayTicks, periodTicks)); } - return new FoliaTaskWrapper(regionScheduler.runAtFixedRate(plugin, world, chunkX, chunkZ, (o) -> task.accept(null), initialDelayTicks, periodTicks)); + return new TaskWrapper(regionScheduler.runAtFixedRate(plugin, world, chunkX, chunkZ, (o) -> task.accept(null), initialDelayTicks, periodTicks)); } /** @@ -192,9 +189,9 @@ public class RegionScheduler { if (periodTicks < 1) periodTicks = 1; if (!FoliaScheduler.isFolia) { - return new BukkitTaskWrapper(Bukkit.getScheduler().runTaskTimer(plugin, () -> task.accept(null), initialDelayTicks, periodTicks)); + return new TaskWrapper(Bukkit.getScheduler().runTaskTimer(plugin, () -> task.accept(null), initialDelayTicks, periodTicks)); } - return new FoliaTaskWrapper(regionScheduler.runAtFixedRate(plugin, location, (o) -> task.accept(null), initialDelayTicks, periodTicks)); + return new TaskWrapper(regionScheduler.runAtFixedRate(plugin, location, (o) -> task.accept(null), initialDelayTicks, periodTicks)); } } \ No newline at end of file diff --git a/spigot/src/main/java/io/github/retrooper/packetevents/util/folia/TaskWrapper.java b/spigot/src/main/java/io/github/retrooper/packetevents/util/folia/TaskWrapper.java new file mode 100644 index 000000000..0827c812b --- /dev/null +++ b/spigot/src/main/java/io/github/retrooper/packetevents/util/folia/TaskWrapper.java @@ -0,0 +1,82 @@ +/* + * This file is part of packetevents - https://github.com/retrooper/packetevents + * Copyright (C) 2024 retrooper and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package io.github.retrooper.packetevents.util.folia; + +import io.papermc.paper.threadedregions.scheduler.ScheduledTask; +import org.bukkit.plugin.Plugin; +import org.bukkit.scheduler.BukkitTask; +import org.jetbrains.annotations.NotNull; + +/** + * Represents a wrapper around {@code BukkitTask} and Paper's {@code ScheduledTask}. + * This class provides a unified interface for interacting with both Bukkit's task scheduler + * and Paper's task scheduler. + */ +public class TaskWrapper { + + private BukkitTask bukkitTask; + private ScheduledTask scheduledTask; + + /** + * Constructs a new TaskWrapper around a BukkitTask. + * + * @param bukkitTask the BukkitTask to wrap + */ + public TaskWrapper(@NotNull BukkitTask bukkitTask) { + this.bukkitTask = bukkitTask; + } + + /** + * Constructs a new TaskWrapper around Paper's ScheduledTask. + * + * @param scheduledTask the ScheduledTask to wrap + */ + public TaskWrapper(@NotNull ScheduledTask scheduledTask) { + this.scheduledTask = scheduledTask; + } + + /** + * Retrieves the Plugin that owns this task. + * + * @return the owning {@link Plugin} + */ + public Plugin getOwner() { + return bukkitTask != null ? bukkitTask.getOwner() : scheduledTask.getOwningPlugin(); + } + + /** + * Checks if the task is canceled. + * + * @return true if the task is canceled, false otherwise + */ + public boolean isCancelled() { + return bukkitTask != null ? bukkitTask.isCancelled() : scheduledTask.isCancelled(); + } + + /** + * Cancels the task. If the task is running, it will be canceled. + */ + public void cancel() { + if (bukkitTask != null) { + bukkitTask.cancel(); + } else { + scheduledTask.cancel(); + } + } +} \ No newline at end of file diff --git a/spigot/src/main/java/io/github/retrooper/packetevents/util/folia/task/BukkitTaskWrapper.java b/spigot/src/main/java/io/github/retrooper/packetevents/util/folia/task/BukkitTaskWrapper.java deleted file mode 100644 index b28142746..000000000 --- a/spigot/src/main/java/io/github/retrooper/packetevents/util/folia/task/BukkitTaskWrapper.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * This file is part of packetevents - https://github.com/retrooper/packetevents - * Copyright (C) 2025 retrooper and contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package io.github.retrooper.packetevents.util.folia.task; - -import org.bukkit.plugin.Plugin; -import org.bukkit.scheduler.BukkitTask; - -/** - * An implementation of {@code TaskWrapper} for interacting with {@code BukkitTask}. - */ -public class BukkitTaskWrapper implements TaskWrapper { - - private final BukkitTask task; - - public BukkitTaskWrapper(BukkitTask task) { - this.task = task; - } - - @Override - public Plugin getOwner() { - return task.getOwner(); - } - - @Override - public boolean isCancelled() { - return task.isCancelled(); - } - - @Override - public void cancel() { - task.cancel(); - } -} diff --git a/spigot/src/main/java/io/github/retrooper/packetevents/util/folia/task/FoliaTaskWrapper.java b/spigot/src/main/java/io/github/retrooper/packetevents/util/folia/task/FoliaTaskWrapper.java deleted file mode 100644 index 62c661432..000000000 --- a/spigot/src/main/java/io/github/retrooper/packetevents/util/folia/task/FoliaTaskWrapper.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * This file is part of packetevents - https://github.com/retrooper/packetevents - * Copyright (C) 2025 retrooper and contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package io.github.retrooper.packetevents.util.folia.task; - -import io.papermc.paper.threadedregions.scheduler.ScheduledTask; -import org.bukkit.plugin.Plugin; - -/** - * An implementation of {@code TaskWrapper} for interacting with Paper's {@code ScheduledTask}. - */ -public class FoliaTaskWrapper implements TaskWrapper { - - private final ScheduledTask scheduledTask; - - public FoliaTaskWrapper(ScheduledTask scheduledTask) { - this.scheduledTask = scheduledTask; - } - - @Override - public Plugin getOwner() { - return scheduledTask.getOwningPlugin(); - } - - @Override - public boolean isCancelled() { - return scheduledTask.isCancelled(); - } - - @Override - public void cancel() { - scheduledTask.cancel(); - } -} diff --git a/spigot/src/main/java/io/github/retrooper/packetevents/util/folia/task/TaskWrapper.java b/spigot/src/main/java/io/github/retrooper/packetevents/util/folia/task/TaskWrapper.java deleted file mode 100644 index 0e9b909b3..000000000 --- a/spigot/src/main/java/io/github/retrooper/packetevents/util/folia/task/TaskWrapper.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * This file is part of packetevents - https://github.com/retrooper/packetevents - * Copyright (C) 2024 retrooper and contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package io.github.retrooper.packetevents.util.folia.task; - -import org.bukkit.plugin.Plugin; - -/** - * A unified interface for interacting with tasks. - * This wrapper provides consistent methods to interact with tasks across multiple platforms, such as {@code BukkitTask} and Paper's {@code ScheduledTask}. - */ -public interface TaskWrapper { - - /** - * Retrieves the plugin that owns this task. - * - * @return The {@code Plugin} instance owning this task. - */ - Plugin getOwner(); - - /** - * Checks if the task has been cancelled. - * - * @return {@code true} if the task is cancelled, {@code false} otherwise. - */ - boolean isCancelled(); - - /** - * Cancels the task. - */ - void cancel(); -} \ No newline at end of file