1
0
mirror of https://github.com/Anuken/Mindustry.git synced 2024-11-11 03:31:19 +03:00

Use AsyncExecutor for pings

This commit is contained in:
Anuken 2021-03-22 11:32:36 -04:00
parent 7ffd46aee9
commit e87e678d0f
3 changed files with 8 additions and 7 deletions

View File

@ -22,6 +22,7 @@ import static mindustry.Vars.*;
public class ArcNetProvider implements NetProvider{
final Client client;
final Prov<DatagramPacket> packetSupplier = () -> new DatagramPacket(new byte[512], 512);
final AsyncExecutor executor = new AsyncExecutor(Math.max(Runtime.getRuntime().availableProcessors(), 4));
final Server server;
final CopyOnWriteArrayList<ArcConnection> connections = new CopyOnWriteArrayList<>();
@ -179,7 +180,7 @@ public class ArcNetProvider implements NetProvider{
@Override
public void pingHost(String address, int port, Cons<Host> valid, Cons<Exception> invalid){
Threads.daemon(() -> {
executor.submit(() -> {
try{
DatagramSocket socket = new DatagramSocket();
long time = Time.millis();
@ -255,7 +256,7 @@ public class ArcNetProvider implements NetProvider{
@Override
public void closeServer(){
connections.clear();
Threads.daemon(server::stop);
executor.submit(server::stop);
}
ArcConnection getByArcID(int id){

View File

@ -45,9 +45,9 @@ public class BeControl{
}, updateInterval, updateInterval);
}
if(System.getProperties().containsKey("becopy")){
if(OS.hasProp("becopy")){
try{
Fi dest = Fi.get(System.getProperty("becopy"));
Fi dest = Fi.get(OS.prop("becopy"));
Fi self = Fi.get(BeControl.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath());
for(Fi file : self.parent().findAll(f -> !f.equals(self))) file.delete();
@ -101,8 +101,8 @@ public class BeControl{
float[] progress = {0};
int[] length = {0};
Fi file = bebuildDirectory.child("client-be-" + updateBuild + ".jar");
Fi fileDest = System.getProperties().contains("becopy") ?
Fi.get(System.getProperty("becopy")) :
Fi fileDest = OS.hasProp("becopy") ?
Fi.get(OS.prop("becopy")) :
Fi.get(BeControl.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath());
BaseDialog dialog = new BaseDialog("@be.updating");

View File

@ -1,3 +1,3 @@
org.gradle.daemon=true
org.gradle.jvmargs=-Xms256m -Xmx1024m
archash=0c7618428502c75e08b4e15239df297c7ab95be9
archash=2e35f7b6bda1d3dea4ee1ae95db76cce37bae506