Package net.minecraftforge.fml
Class DeferredWorkQueue
- java.lang.Object
-
- net.minecraftforge.fml.DeferredWorkQueue
-
public class DeferredWorkQueue extends java.lang.Object
Utility for running code on the main launch thread at the next available opportunity. There is no guaranteed order that work from various mods will be run, but your own work will be run sequentially.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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
DeferredWorkQueue.TaskInfo
-
Field Summary
Fields Modifier and Type Field Description private static org.apache.logging.log4j.Logger
LOGGER
private ModLoadingStage
modLoadingStage
private java.util.concurrent.ConcurrentLinkedDeque<DeferredWorkQueue.TaskInfo>
tasks
private static java.util.Map<java.lang.Class<? extends ParallelDispatchEvent>,DeferredWorkQueue>
workQueues
-
Constructor Summary
Constructors Constructor Description DeferredWorkQueue(ModLoadingStage modLoadingStage, java.lang.Class<? extends ParallelDispatchEvent> eventClass)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description java.util.concurrent.CompletableFuture<java.lang.Void>
enqueueWork(net.minecraftforge.forgespi.language.IModInfo modInfo, java.lang.Runnable work)
<T> java.util.concurrent.CompletableFuture<T>
enqueueWork(net.minecraftforge.forgespi.language.IModInfo modInfo, java.util.function.Supplier<T> work)
static java.util.Optional<DeferredWorkQueue>
lookup(java.util.Optional<java.lang.Class<? extends ParallelDispatchEvent>> parallelClass)
private static void
makeRunnable(DeferredWorkQueue.TaskInfo ti, java.util.concurrent.Executor executor)
static java.util.concurrent.CompletableFuture<java.lang.Void>
runLater(java.lang.Runnable workToEnqueue)
Deprecated.(package private) void
runTasks()
-
-
-
Field Detail
-
LOGGER
private static final org.apache.logging.log4j.Logger LOGGER
-
workQueues
private static java.util.Map<java.lang.Class<? extends ParallelDispatchEvent>,DeferredWorkQueue> workQueues
-
modLoadingStage
private final ModLoadingStage modLoadingStage
-
tasks
private final java.util.concurrent.ConcurrentLinkedDeque<DeferredWorkQueue.TaskInfo> tasks
-
-
Constructor Detail
-
DeferredWorkQueue
public DeferredWorkQueue(ModLoadingStage modLoadingStage, java.lang.Class<? extends ParallelDispatchEvent> eventClass)
-
-
Method Detail
-
lookup
public static java.util.Optional<DeferredWorkQueue> lookup(java.util.Optional<java.lang.Class<? extends ParallelDispatchEvent>> parallelClass)
-
runTasks
void runTasks()
-
makeRunnable
private static void makeRunnable(DeferredWorkQueue.TaskInfo ti, java.util.concurrent.Executor executor)
-
enqueueWork
public java.util.concurrent.CompletableFuture<java.lang.Void> enqueueWork(net.minecraftforge.forgespi.language.IModInfo modInfo, java.lang.Runnable work)
-
enqueueWork
public <T> java.util.concurrent.CompletableFuture<T> enqueueWork(net.minecraftforge.forgespi.language.IModInfo modInfo, java.util.function.Supplier<T> work)
-
runLater
@Deprecated public static java.util.concurrent.CompletableFuture<java.lang.Void> runLater(java.lang.Runnable workToEnqueue)
Deprecated.DEPRECATED FOR REMOVAL. UseParallelDispatchEvent.enqueueWork(Runnable)
orParallelDispatchEvent.enqueueWork(Supplier)
- Parameters:
workToEnqueue
- Runnable to execute later- Returns:
- a completable future
-
-