mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-17 19:15:32 +00:00
Process the main modloading work on the async thread, but still
do deferred work on the main thread by passing in the executor. Signed-off-by: cpw <[email protected]>
This commit is contained in:
6 files changed
+54
-42
No files matched your search
@@ -23,7 +23,7 @@ import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.forgespi.language.ILifecycleEvent;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
@@ -41,7 +41,7 @@ public enum LifecycleEventProvider
|
||||
GATHERDATA(()->new GatherDataLifecycleEvent(ModLoadingStage.GATHERDATA), ModList.inlineDispatcher);
|
||||
|
||||
private final Supplier<? extends LifecycleEvent> event;
|
||||
private final BiConsumer<LifecycleEvent, Consumer<List<ModLoadingException>>> eventDispatcher;
|
||||
private final EventHandler<LifecycleEvent, Consumer<List<ModLoadingException>>,Executor> eventDispatcher;
|
||||
private Supplier<Event> customEventSupplier;
|
||||
private LifecycleEvent.Progression progression = LifecycleEvent.Progression.NEXT;
|
||||
|
||||
@@ -50,7 +50,7 @@ public enum LifecycleEventProvider
|
||||
this(e, ModList.parallelDispatcher);
|
||||
}
|
||||
|
||||
LifecycleEventProvider(Supplier<? extends LifecycleEvent> e, BiConsumer<LifecycleEvent, Consumer<List<ModLoadingException>>> eventDispatcher)
|
||||
LifecycleEventProvider(Supplier<? extends LifecycleEvent> e, EventHandler<LifecycleEvent, Consumer<List<ModLoadingException>>,Executor> eventDispatcher)
|
||||
{
|
||||
this.event = e;
|
||||
this.eventDispatcher = eventDispatcher;
|
||||
@@ -64,11 +64,11 @@ public enum LifecycleEventProvider
|
||||
this.progression = progression;
|
||||
}
|
||||
|
||||
public void dispatch(Consumer<List<ModLoadingException>> errorHandler) {
|
||||
public void dispatch(Consumer<List<ModLoadingException>> errorHandler, final Executor executor) {
|
||||
final LifecycleEvent lifecycleEvent = this.event.get();
|
||||
lifecycleEvent.setCustomEventSupplier(this.customEventSupplier);
|
||||
lifecycleEvent.changeProgression(this.progression);
|
||||
this.eventDispatcher.accept(lifecycleEvent, errorHandler);
|
||||
this.eventDispatcher.dispatchEvent(lifecycleEvent, errorHandler, executor);
|
||||
}
|
||||
|
||||
|
||||
@@ -147,4 +147,8 @@ public enum LifecycleEventProvider
|
||||
return ModLoadingStage.DONE;
|
||||
}
|
||||
}
|
||||
|
||||
public interface EventHandler<T extends LifecycleEvent, U extends Consumer<? extends List<? super ModLoadingException>>, V extends Executor> {
|
||||
void dispatchEvent(T event, U exceptionHandler, V executor);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user