mirror of
https://github.com/songoda/SongodaCore.git
synced 2024-11-27 12:35:12 +01:00
Added asyncFuture
Added a method to run a task async but return a CompletableFuture. Useful if you want the task to be asynchronous but also wait for it to finish and concatenate another task or more functionalities with the CompletableFuture API
This commit is contained in:
parent
799bf30651
commit
c0a2bc8cc5
@ -12,6 +12,7 @@ import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class DataManagerAbstract {
|
||||
|
||||
@ -68,6 +69,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.
|
||||
|
Loading…
Reference in New Issue
Block a user