mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-30 16:19:03 +01:00
Allows calling of functions in the main thread
By: Raphfrk <raphfrk@gmail.com>
This commit is contained in:
parent
7b32aee768
commit
3274723ced
1 changed files with 15 additions and 0 deletions
|
@ -1,6 +1,8 @@
|
|||
package org.bukkit.scheduler;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
public interface BukkitScheduler {
|
||||
|
||||
|
@ -70,6 +72,19 @@ public interface BukkitScheduler {
|
|||
*/
|
||||
public int scheduleAsyncRepeatingTask(Plugin plugin, Runnable task, long delay, long period);
|
||||
|
||||
/**
|
||||
* Calls a method on the main thread and returns a Future object
|
||||
* This task will be executed by the main server thread
|
||||
*
|
||||
* Note: The Future.get() methods must NOT be called from the main thread
|
||||
* Note2: There is at least an average of 10ms latency until the isDone() method returns true
|
||||
*
|
||||
* @param Plugin Plugin that owns the task
|
||||
* @param Callable Task to be executed
|
||||
* @return Future Future object related to the task
|
||||
*/
|
||||
public <T> Future<T> callSyncMethod(Plugin plugin, Callable<T> task);
|
||||
|
||||
/**
|
||||
* Removes task from scheduler
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue