Skip to content

Commit

Permalink
ref: changed to static reference
Browse files Browse the repository at this point in the history
  • Loading branch information
Uhutown committed Oct 27, 2024
1 parent ad98818 commit 1443e5c
Showing 1 changed file with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ public final class SignalConfig {

private static final LoadHolder<Class<SignalConfig>> LOAD_HOLDER = new LoadHolder<>(
SignalConfig.class);
private static final ExecutorService SERVICE = Executors.newCachedThreadPool();

private final ExecutorService service = Executors.newCachedThreadPool();
private final SignalBoxPathway pathway;

public SignalConfig(final SignalBoxPathway pathway) {
Expand All @@ -53,7 +53,7 @@ public void change(final ConfigInfo info) {
final List<ConfigProperty> shuntingValues = OneSignalNonPredicateConfigParser.SHUNTINGCONFIGS
.get(currentSignal);
if (shuntingValues != null && info.currentinfo.isValid()) {
service.execute(() -> loadWithoutPredicate(shuntingValues, info.currentinfo));
loadWithoutPredicate(shuntingValues, info.currentinfo);
}
}
}
Expand Down Expand Up @@ -100,16 +100,14 @@ public void loadDisable(final ConfigInfo info) {
}

private void changeIfPresent(final List<ConfigProperty> values, final ConfigInfo info) {
service.execute(() -> {
loadSignalAndRunTask(info.currentinfo, (stateInfo, oldProperties, _u) -> {
if (info.nextinfo != null) {
loadSignalAndRunTask(info.nextinfo, (nextInfo, nextProperties, _u2) -> {
changeSignals(values, info, oldProperties, nextProperties);
});
} else {
changeSignals(values, info, oldProperties, null);
}
});
loadSignalAndRunTask(info.currentinfo, (stateInfo, oldProperties, _u) -> {
if (info.nextinfo != null) {
loadSignalAndRunTask(info.nextinfo, (nextInfo, nextProperties, _u2) -> {
changeSignals(values, info, oldProperties, nextProperties);
});
} else {
changeSignals(values, info, oldProperties, null);
}
});
}

Expand Down Expand Up @@ -155,12 +153,14 @@ private void loadWithoutPredicate(final List<ConfigProperty> values,

private static void loadSignalAndRunTask(final SignalStateInfo info,
final SignalStateListener task) {
final boolean isSignalLoaded = SignalStateHandler.isSignalLoaded(info);
if (!isSignalLoaded) {
SignalStateHandler.loadSignal(new SignalStateLoadHoler(info, LOAD_HOLDER));
task.andThen((_u1, _u2, _u3) -> SignalStateHandler
.unloadSignal(new SignalStateLoadHoler(info, LOAD_HOLDER)));
}
SignalStateHandler.runTaskWhenSignalLoaded(info, task);
SERVICE.execute(() -> {
final boolean isSignalLoaded = SignalStateHandler.isSignalLoaded(info);
if (!isSignalLoaded) {
SignalStateHandler.loadSignal(new SignalStateLoadHoler(info, LOAD_HOLDER));
task.andThen((_u1, _u2, _u3) -> SignalStateHandler
.unloadSignal(new SignalStateLoadHoler(info, LOAD_HOLDER)));
}
SignalStateHandler.runTaskWhenSignalLoaded(info, task);
});
}
}

0 comments on commit 1443e5c

Please sign in to comment.