-
Type:
Bug
-
Resolution: Fixed
-
Priority:
Minor
-
None
-
Affects Version/s: None
-
None
While reading through the CraftScheduler source code I noticed 2 things which seem odd to me related to the CraftScheduler#isCurrentlyRunning(taskId) method:
Bukkit Javadoc for this method: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/scheduler/BukkitScheduler.html#isCurrentlyRunning-int-
isCurrentlyRunning() makes use of the 'runners' map: https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java#271
'runners' seems to contain the just-about-to-be-running and the currently running tasks, as tasks are added to 'runners' as part of parsePending(): https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java#418
Odd about the isCurrentlyRunning() method:
- It does seem to always return false for sync tasks (https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java#273). So checking from inside an async tasks if a sync task is currently running seems not possible with this.
- And for async tasks, it check if its 'workers' is empty (https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java#277). Shouldn't it check if its workers are not empty instead? Workers are added whenever the async task gets run, and removed afterwards again (https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/src/main/java/org/bukkit/craftbukkit/scheduler/CraftAsyncTask.java#35).