cleanup
This commit is contained in:
@@ -7,17 +7,19 @@ import mindustry.game.EventType.*;
|
||||
|
||||
import java.util.concurrent.*;
|
||||
|
||||
import static mindustry.Vars.state;
|
||||
|
||||
public class AsyncLogic{
|
||||
//all processes to be executed each frame
|
||||
private Array<AsyncProcess> processes = Array.with(
|
||||
private final Array<AsyncProcess> processes = Array.with(
|
||||
new PhysicsProcess(),
|
||||
Vars.teamIndex = new TeamIndexProcess()
|
||||
);
|
||||
|
||||
//futures to be awaited
|
||||
private Array<Future<?>> futures = new Array<>();
|
||||
private final Array<Future<?>> futures = new Array<>();
|
||||
|
||||
private ExecutorService executor = Executors.newFixedThreadPool(processes.size, r -> {
|
||||
private final ExecutorService executor = Executors.newFixedThreadPool(processes.size, r -> {
|
||||
Thread thread = new Thread(r, "AsyncLogic-Thread");
|
||||
thread.setDaemon(true);
|
||||
thread.setUncaughtExceptionHandler((t, e) -> Core.app.post(() -> { throw new RuntimeException(e); }));
|
||||
@@ -41,7 +43,7 @@ public class AsyncLogic{
|
||||
}
|
||||
|
||||
public void begin(){
|
||||
if(Vars.state.isPlaying()){
|
||||
if(state.isPlaying()){
|
||||
//sync begin
|
||||
for(AsyncProcess p : processes){
|
||||
p.begin();
|
||||
@@ -59,7 +61,7 @@ public class AsyncLogic{
|
||||
}
|
||||
|
||||
public void end(){
|
||||
if(Vars.state.isPlaying()){
|
||||
if(state.isPlaying()){
|
||||
complete();
|
||||
|
||||
//sync end (flush data)
|
||||
|
||||
Reference in New Issue
Block a user