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:
cpw committed 2019-06-23 12:26:45 -04:00
1 parent 359be1a880
commit 9067dbf6a0
6 files changed
+54 -42

No files matched your search

@@ -67,9 +67,9 @@ public class ClientModLoader
}
private static CompletableFuture<Void> onreload(final IFutureReloadListener.IStage stage, final IResourceManager resourceManager, final IProfiler prepareProfiler, final IProfiler executeProfiler, final Executor asyncExecutor, final Executor syncExecutor) {
return CompletableFuture.runAsync(createRunnableWithCatch(ClientModLoader::startModLoading), syncExecutor).
return CompletableFuture.runAsync(createRunnableWithCatch(() -> startModLoading(syncExecutor)), asyncExecutor).
thenCompose(stage::markCompleteAwaitingOthers).
thenRunAsync(ClientModLoader::finishModLoading, syncExecutor);
thenRunAsync(() -> finishModLoading(syncExecutor), asyncExecutor);
}
private static Runnable createRunnableWithCatch(Runnable r) {
@@ -83,15 +83,16 @@ public class ClientModLoader
};
}
private static void startModLoading() {
private static void startModLoading(Executor executor) {
earlyLoaderGUI.handleElsewhere();
createRunnableWithCatch(ModLoader.get()::loadMods).run();
createRunnableWithCatch(() -> ModLoader.get().loadMods(executor)).run();
}
private static void finishModLoading()
private static void finishModLoading(Executor executor)
{
createRunnableWithCatch(ModLoader.get()::finishMods).run();
createRunnableWithCatch(() -> ModLoader.get().finishMods(executor)).run();
loading = false;
mc.gameSettings.loadOptions();
// reload game settings on main thread
executor.execute(()->mc.gameSettings.loadOptions());
}
public static VersionChecker.Status checkForUpdates()