Merge pull request #22 from divios/patch-1

Added `DataManagerAbstract#asyncFuture`
This commit is contained in:
Christian Koop 2022-03-18 16:07:37 +01:00
commit 7a85bd7a2a
No known key found for this signature in database
GPG Key ID: 89A8181384E010A3
1 changed files with 11 additions and 0 deletions

View File

@ -11,6 +11,7 @@ import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;
@ -80,6 +81,16 @@ public class DataManagerAbstract {
public void async(Runnable runnable) {
Bukkit.getScheduler().runTaskAsynchronously(this.plugin, runnable);
}
/**
* Queue a task to be run asynchronously with all the
* advantages of CompletableFuture api <br>
*
* @param runnable task to run
*/
public CompletableFuture<Void> asyncFuture(Runnable runnable) {
return CompletableFuture.runAsync(runnable);
}
/**
* Queue a task to be run synchronously.