Class MenuWorkers
java.lang.Object
dev.xichil.mvui.MenuWorkers
Where backends run
UiHost.runAsync(Callable, BiConsumer) tasks: one daemon thread per mod, so a mod whose task hangs (store IO
waiting on another instance's file lock) holds up only its own menu. Each mod's tasks run one at a time, in the
order they were started. A thread ends after a minute without work and comes back with the next task. Threads are
daemons named "Xi's Multiversion UI: <modid>", so they never keep the game from exiting and are easy to find in a
thread dump.
For backends; mods use UiHost.runAsync(Callable, BiConsumer). A backend's runAsync runs the task like this:
MenuWorkers.forTask(task).execute(() -> {
T result = null;
Throwable error = null;
try {
result = task.call();
} catch (Throwable t) {
error = t;
}
// back to the main thread: onDone.accept(result, error), then refresh
});
-
Method Summary
Modifier and TypeMethodDescriptionstatic ExecutorThe executor fortask, as passed to a backend'sUiHost.runAsync(Callable, BiConsumer): its mod's own single thread (Failsafemarks a registered menu's tasks with the mod id), or a shared one for tasks of no mod.
-
Method Details
-
forTask
The executor fortask, as passed to a backend'sUiHost.runAsync(Callable, BiConsumer): its mod's own single thread (Failsafemarks a registered menu's tasks with the mod id), or a shared one for tasks of no mod.- Parameters:
task- the task a backend'srunAsyncreceived- Returns:
- a single-threaded executor; the same one for every task of the same mod
-