mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-02-23 21:19:39 +07:00
Use AsyncExecutor for pings
This commit is contained in:
parent
7ffd46aee9
commit
e87e678d0f
@ -22,6 +22,7 @@ import static mindustry.Vars.*;
|
|||||||
public class ArcNetProvider implements NetProvider{
|
public class ArcNetProvider implements NetProvider{
|
||||||
final Client client;
|
final Client client;
|
||||||
final Prov<DatagramPacket> packetSupplier = () -> new DatagramPacket(new byte[512], 512);
|
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 Server server;
|
||||||
final CopyOnWriteArrayList<ArcConnection> connections = new CopyOnWriteArrayList<>();
|
final CopyOnWriteArrayList<ArcConnection> connections = new CopyOnWriteArrayList<>();
|
||||||
@ -179,7 +180,7 @@ public class ArcNetProvider implements NetProvider{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void pingHost(String address, int port, Cons<Host> valid, Cons<Exception> invalid){
|
public void pingHost(String address, int port, Cons<Host> valid, Cons<Exception> invalid){
|
||||||
Threads.daemon(() -> {
|
executor.submit(() -> {
|
||||||
try{
|
try{
|
||||||
DatagramSocket socket = new DatagramSocket();
|
DatagramSocket socket = new DatagramSocket();
|
||||||
long time = Time.millis();
|
long time = Time.millis();
|
||||||
@ -255,7 +256,7 @@ public class ArcNetProvider implements NetProvider{
|
|||||||
@Override
|
@Override
|
||||||
public void closeServer(){
|
public void closeServer(){
|
||||||
connections.clear();
|
connections.clear();
|
||||||
Threads.daemon(server::stop);
|
executor.submit(server::stop);
|
||||||
}
|
}
|
||||||
|
|
||||||
ArcConnection getByArcID(int id){
|
ArcConnection getByArcID(int id){
|
||||||
|
@ -45,9 +45,9 @@ public class BeControl{
|
|||||||
}, updateInterval, updateInterval);
|
}, updateInterval, updateInterval);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(System.getProperties().containsKey("becopy")){
|
if(OS.hasProp("becopy")){
|
||||||
try{
|
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());
|
Fi self = Fi.get(BeControl.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath());
|
||||||
|
|
||||||
for(Fi file : self.parent().findAll(f -> !f.equals(self))) file.delete();
|
for(Fi file : self.parent().findAll(f -> !f.equals(self))) file.delete();
|
||||||
@ -101,8 +101,8 @@ public class BeControl{
|
|||||||
float[] progress = {0};
|
float[] progress = {0};
|
||||||
int[] length = {0};
|
int[] length = {0};
|
||||||
Fi file = bebuildDirectory.child("client-be-" + updateBuild + ".jar");
|
Fi file = bebuildDirectory.child("client-be-" + updateBuild + ".jar");
|
||||||
Fi fileDest = System.getProperties().contains("becopy") ?
|
Fi fileDest = OS.hasProp("becopy") ?
|
||||||
Fi.get(System.getProperty("becopy")) :
|
Fi.get(OS.prop("becopy")) :
|
||||||
Fi.get(BeControl.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath());
|
Fi.get(BeControl.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath());
|
||||||
|
|
||||||
BaseDialog dialog = new BaseDialog("@be.updating");
|
BaseDialog dialog = new BaseDialog("@be.updating");
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
org.gradle.daemon=true
|
org.gradle.daemon=true
|
||||||
org.gradle.jvmargs=-Xms256m -Xmx1024m
|
org.gradle.jvmargs=-Xms256m -Xmx1024m
|
||||||
archash=0c7618428502c75e08b4e15239df297c7ab95be9
|
archash=2e35f7b6bda1d3dea4ee1ae95db76cce37bae506
|
||||||
|
Loading…
Reference in New Issue
Block a user