Partial 7.0 merge - API preview

This commit is contained in:
Anuken
2021-06-02 11:08:08 -04:00
parent ea75a357ca
commit 28b235ef07
531 changed files with 12356 additions and 6286 deletions

View File

@@ -10,19 +10,14 @@ import static mindustry.Vars.*;
public class AsyncCore{
//all processes to be executed each frame
private final Seq<AsyncProcess> processes = Seq.with(
public final Seq<AsyncProcess> processes = Seq.with(
new PhysicsProcess()
);
//futures to be awaited
private final Seq<Future<?>> futures = new Seq<>();
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); }));
return thread;
});
private ExecutorService executor;
public AsyncCore(){
Events.on(WorldLoadEvent.class, e -> {
@@ -49,6 +44,16 @@ public class AsyncCore{
futures.clear();
//init executor with size of potentially-modified process list
if(executor == null){
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); }));
return thread;
});
}
//submit all tasks
for(AsyncProcess p : processes){
if(p.shouldProcess()){