Skip to content

Commit

Permalink
ref: maby better load System for Names and Signals
Browse files Browse the repository at this point in the history
  • Loading branch information
Uhutown committed Oct 20, 2024
1 parent f531842 commit bca07d6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
public final class NameHandler implements INetworkSync {

private static ExecutorService writeService = Executors.newFixedThreadPool(5);
private static final ExecutorService readService = Executors.newCachedThreadPool();
private static final Map<StateInfo, String> ALL_NAMES = new HashMap<>();
private static final Map<World, NameHandlerFileV2> ALL_LEVEL_FILES = new HashMap<>();
private static final Map<StateInfo, List<NameStateListener>> TASKS_WHEN_LOAD = new HashMap<>();
Expand Down Expand Up @@ -322,7 +323,7 @@ public static void loadNames(final List<StateLoadHolder> infos,
final @Nullable EntityPlayer player) {
if (infos == null || infos.isEmpty())
return;
new Thread(() -> {
readService.execute(() -> {
infos.forEach(info -> {
boolean isLoaded = false;
synchronized (LOAD_COUNTER) {
Expand Down Expand Up @@ -368,7 +369,7 @@ public static void loadNames(final List<StateLoadHolder> infos,
}
}
});
}, "OSNameHandler:loadNames").start();
});
}

public static void unloadName(final StateLoadHolder holder) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ private SignalStateHandler() {
}

private static ExecutorService writeService = Executors.newFixedThreadPool(5);
private static final ExecutorService readService = Executors.newCachedThreadPool();
private static final Map<SignalStateInfo, Map<SEProperty, String>> CURRENTLY_LOADED_STATES = new HashMap<>();
private static final Map<World, SignalStateFileV2> ALL_LEVEL_FILES = new HashMap<>();
private static final Map<SignalStateInfo, List<LoadHolder<?>>> SIGNAL_COUNTER = new HashMap<>();
Expand Down Expand Up @@ -532,7 +533,7 @@ public static void loadSignals(final List<SignalStateLoadHoler> signals,
final @Nullable EntityPlayer player) {
if (signals == null || signals.isEmpty())
return;
new Thread(() -> {
readService.execute(() -> {
signals.forEach(info -> {
boolean isLoaded = false;
synchronized (SIGNAL_COUNTER) {
Expand Down Expand Up @@ -567,7 +568,7 @@ public static void loadSignals(final List<SignalStateLoadHoler> signals,
}
}
});
}, "OSSignalStateHandler:loadSignals").start();
});
}

public static void unloadSignal(final SignalStateLoadHoler info) {
Expand Down

0 comments on commit bca07d6

Please sign in to comment.