Use AsyncExecutor for pings
This commit is contained in:
@@ -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){
|
||||
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user