simulationJob

This commit is contained in:
Jade 2021-05-11 15:17:48 +08:00
parent e41342f0ce
commit 980b0531d0
2 changed files with 8 additions and 6 deletions

View File

@ -133,12 +133,7 @@ public abstract class Simulation<U extends SimulationUser, M extends Simulation
try {
this.mainLogicRunning.set(true);
this.systemTime = this.systemTime.plusNanos(timeAdd);
this.jobMap.values().forEach(simulationJob -> {
if (getSystemTime().compareTo(simulationJob.runtime) >= 0) {
simulationJob.job.run();
simulationJob.afterRun();
}
});
this.jobMap.values().forEach(SimulationJob::run);
} catch (Throwable e) {
this.runError(e);
log.error(String.format("仿真[%s]主线程逻辑执行异常,仿真停止运行", this.id), e);

View File

@ -28,5 +28,12 @@ public abstract class SimulationJob {
this.runtime = runtime;
}
public void run() {
if (simulation.getSystemTime().compareTo(runtime) >= 0) {
this.job.run();
this.afterRun();
}
}
public abstract void afterRun();
}