Package net.minecraftforge.fml
Class DeferredWorkQueue
java.lang.Object
net.minecraftforge.fml.DeferredWorkQueue
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
-
Field Summary
Modifier and TypeFieldDescriptionprivate static final org.apache.logging.log4j.Logger
private final ModLoadingStage
private final ConcurrentLinkedDeque<DeferredWorkQueue.TaskInfo>
private static Map<Class<? extends ParallelDispatchEvent>,
DeferredWorkQueue> -
Constructor Summary
ConstructorDescriptionDeferredWorkQueue
(ModLoadingStage modLoadingStage, Class<? extends ParallelDispatchEvent> eventClass) -
Method Summary
Modifier and TypeMethodDescriptionenqueueWork
(net.minecraftforge.forgespi.language.IModInfo modInfo, Runnable work) <T> CompletableFuture<T>
enqueueWork
(net.minecraftforge.forgespi.language.IModInfo modInfo, Supplier<T> work) static Optional<DeferredWorkQueue>
lookup
(Optional<Class<? extends ParallelDispatchEvent>> parallelClass) private static void
makeRunnable
(DeferredWorkQueue.TaskInfo ti, Executor executor) static CompletableFuture<Void>
Deprecated.(package private) void
runTasks()
-
Field Details
-
LOGGER
private static final org.apache.logging.log4j.Logger LOGGER -
workQueues
-
modLoadingStage
-
tasks
-
-
Constructor Details
-
DeferredWorkQueue
public DeferredWorkQueue(ModLoadingStage modLoadingStage, Class<? extends ParallelDispatchEvent> eventClass)
-
-
Method Details
-
lookup
public static Optional<DeferredWorkQueue> lookup(Optional<Class<? extends ParallelDispatchEvent>> parallelClass) -
runTasks
void runTasks() -
makeRunnable
-
enqueueWork
public CompletableFuture<Void> enqueueWork(net.minecraftforge.forgespi.language.IModInfo modInfo, Runnable work) -
enqueueWork
public <T> CompletableFuture<T> enqueueWork(net.minecraftforge.forgespi.language.IModInfo modInfo, Supplier<T> work) -
runLater
Deprecated.DEPRECATED FOR REMOVAL. UseParallelDispatchEvent.enqueueWork(Runnable)
orParallelDispatchEvent.enqueueWork(Supplier)
- Parameters:
workToEnqueue
- Runnable to execute later- Returns:
- a completable future
-