13
0
geforkt von Mirrors/Paper

Improved the Scheduler.

Adds nag message when async tasks are not properly shut down and adds a limiter for sync tasks. Once they use 35ms in a single tick, any remaining tasks are not executed until later ticks. Adds a method to report the pending tasks and one to report active worker threads

By: Raphfrk <raphfrk@gmail.com>
Dieser Commit ist enthalten in:
Bukkit/Spigot 2011-04-28 20:05:48 +01:00
Ursprung 894465d3b7
Commit 788c41c330
3 geänderte Dateien mit 93 neuen und 9 gelöschten Zeilen

Datei anzeigen

@ -3,6 +3,7 @@ package org.bukkit.scheduler;
import org.bukkit.plugin.Plugin;
import java.util.concurrent.Callable;
import java.util.concurrent.Future;
import java.util.List;
public interface BukkitScheduler {
@ -129,4 +130,21 @@ public interface BukkitScheduler {
* @return If the task is queued to be run.
*/
public boolean isQueued(int taskId);
/**
* Returns a list of all active workers.
*
* This list contains asynch tasks that are being executed by separate threads.
*
* @return Active workers
*/
public List<BukkitWorker> getActiveWorkers();
/**
* Returns a list of all pending tasks. The ordering of the tasks is not related to their order of execution.
*
* @return Active workers
*/
public List<BukkitTask> getPendingTasks();
}

Datei anzeigen

@ -0,0 +1,31 @@
package org.bukkit.scheduler;
import org.bukkit.plugin.Plugin;
/**
* Represents a task being executed by the scheduler
*/
public interface BukkitTask {
/**
* Returns the taskId for the task
*
* @return Task id number
*/
public int getTaskId();
/**
* Returns the Plugin that owns this task
*
* @return The Plugin that owns the task
*/
public Plugin getOwner();
/**
* Returns true if the Task is a sync task
*
* @return true if the task is run by main thread
*/
public boolean isSync();
}

Datei anzeigen

@ -0,0 +1,35 @@
package org.bukkit.scheduler;
import org.bukkit.plugin.Plugin;
/**
* Represents a worker thread for the scheduler. This gives information about
* the Thread object for the task, owner of the task and the taskId.
*
* Workers are used to execute async tasks.
*/
public interface BukkitWorker {
/**
* Returns the taskId for the task being executed by this worker
*
* @return Task id number
*/
public int getTaskId();
/**
* Returns the Plugin that owns this task
*
* @return The Plugin that owns the task
*/
public Plugin getOwner();
/**
* Returns the thread for the worker
*
* @return The Thread object for the worker
*/
public Thread getThread();
}