public class DeferredWorkQueue
extends java.lang.Object
Use of this class after startup is not possible. At that
point, IThreadListener
should be used instead.
Exceptions from tasks will be handled gracefully, causing a mod loading error. Tasks that take egregiously long times to run will be logged.
Modifier and Type | Class and Description |
---|---|
static interface |
DeferredWorkQueue.CheckedRunnable
Runnable except it allows throwing checked exceptions. |
Constructor and Description |
---|
DeferredWorkQueue() |
Modifier and Type | Method and Description |
---|---|
static <T> java.util.concurrent.CompletableFuture<T> |
getLater(java.util.function.Supplier<T> workToEnqueue)
Run a task computing a result on the loading thread at the next available
opportunity, i.e.
|
static <T> java.util.concurrent.CompletableFuture<T> |
getLaterChecked(java.util.concurrent.Callable<T> workToEnqueue)
Run a task computing a result on the loading thread at the next available
opportunity, i.e.
|
static java.util.concurrent.CompletableFuture<java.lang.Void> |
runLater(java.lang.Runnable workToEnqueue)
Run a task on the loading thread at the next available opportunity, i.e.
|
static java.util.concurrent.CompletableFuture<java.lang.Void> |
runLaterChecked(DeferredWorkQueue.CheckedRunnable workToEnqueue)
Run a task on the loading thread at the next available opportunity, i.e.
|
public static java.util.concurrent.CompletableFuture<java.lang.Void> runLater(java.lang.Runnable workToEnqueue)
If the task must throw a checked exception, use
runLaterChecked(CheckedRunnable)
.
If the task has a result, use getLater(Supplier)
or
getLaterChecked(Callable)
.
workToEnqueue
- A Runnable
to execute later, on the loading
threadCompletableFuture
that completes at said timepublic static java.util.concurrent.CompletableFuture<java.lang.Void> runLaterChecked(DeferredWorkQueue.CheckedRunnable workToEnqueue)
If the task does not throw a checked exception, use
runLater(Runnable)
.
If the task has a result, use getLater(Supplier)
or
getLaterChecked(Callable)
.
workToEnqueue
- A DeferredWorkQueue.CheckedRunnable
to execute later, on the
loading threadCompletableFuture
that completes at said timepublic static <T> java.util.concurrent.CompletableFuture<T> getLater(java.util.function.Supplier<T> workToEnqueue)
If the task throws a checked exception, use
getLaterChecked(Callable)
.
If the task does not have a result, use runLater(Runnable)
or
runLaterChecked(CheckedRunnable)
.
T
- The result type of the taskworkToEnqueue
- A Supplier
to execute later, on the loading
threadCompletableFuture
that completes at said timepublic static <T> java.util.concurrent.CompletableFuture<T> getLaterChecked(java.util.concurrent.Callable<T> workToEnqueue)
If the task does not throw a checked exception, use
#getLater(Callable)
.
If the task does not have a result, use runLater(Runnable)
or
runLaterChecked(CheckedRunnable)
.
T
- The result type of the taskworkToEnqueue
- A Supplier
to execute later, on the loading
threadCompletableFuture
that completes at said time