@Deprecated
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. This is being deprecated in favour of a new interface on loading events, to remove confusion about how it operates. #TODO
Modifier and Type | Class and Description |
---|---|
static interface |
DeferredWorkQueue.CheckedRunnable
Deprecated.
Runnable except it allows throwing checked exceptions. |
private static class |
DeferredWorkQueue.TaskInfo
Deprecated.
|
Modifier and Type | Field and Description |
---|---|
private static java.lang.ThreadLocal<ModContainer> |
currentOwner
Deprecated.
|
private static java.util.concurrent.Executor |
deferredExecutor
Deprecated.
|
private static org.apache.logging.log4j.Logger |
LOGGER
Deprecated.
|
private static java.util.List<ModLoadingException> |
raisedExceptions
Deprecated.
|
private static java.util.concurrent.ConcurrentLinkedDeque<DeferredWorkQueue.TaskInfo> |
taskQueue
Deprecated.
|
(package private) static java.util.concurrent.Executor |
workExecutor
Deprecated.
|
Constructor and Description |
---|
DeferredWorkQueue()
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
(package private) static void |
clear()
Deprecated.
|
static <T> java.util.concurrent.CompletableFuture<T> |
getLater(java.util.function.Supplier<T> workToEnqueue)
Deprecated.
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)
Deprecated.
Run a task computing a result on the loading thread at the next available
opportunity, i.e.
|
private static <T> com.google.common.base.Function<java.lang.Throwable,T> |
handleException()
Deprecated.
|
private static java.util.concurrent.CompletableFuture<?> |
makeRunnable(DeferredWorkQueue.TaskInfo ti,
java.util.concurrent.Executor executor)
Deprecated.
|
static java.util.concurrent.CompletableFuture<java.lang.Void> |
runLater(java.lang.Runnable workToEnqueue)
Deprecated.
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)
Deprecated.
Run a task on the loading thread at the next available opportunity, i.e.
|
(package private) static void |
runTasks(ModLoadingStage fromStage,
java.util.function.Consumer<java.util.List<ModLoadingException>> errorHandler)
Deprecated.
|
private static final org.apache.logging.log4j.Logger LOGGER
private static java.lang.ThreadLocal<ModContainer> currentOwner
private static java.util.List<ModLoadingException> raisedExceptions
private static final java.util.concurrent.ConcurrentLinkedDeque<DeferredWorkQueue.TaskInfo> taskQueue
private static final java.util.concurrent.Executor deferredExecutor
static java.util.concurrent.Executor workExecutor
private static <T> com.google.common.base.Function<java.lang.Throwable,T> handleException()
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 timestatic void clear()
static void runTasks(ModLoadingStage fromStage, java.util.function.Consumer<java.util.List<ModLoadingException>> errorHandler)
private static java.util.concurrent.CompletableFuture<?> makeRunnable(DeferredWorkQueue.TaskInfo ti, java.util.concurrent.Executor executor)