Cached ping executor

This commit is contained in:
Anuken
2021-07-03 23:21:29 -04:00
parent 3382d56590
commit ed4156850b
3 changed files with 3 additions and 10 deletions

View File

@@ -34,7 +34,7 @@ public class Net{
private final ObjectMap<Class<?>, Cons> clientListeners = new ObjectMap<>();
private final ObjectMap<Class<?>, Cons2<NetConnection, Object>> serverListeners = new ObjectMap<>();
private final IntMap<StreamBuilder> streams = new IntMap<>();
private final ExecutorService pingExecutor = Threads.executor(Math.max(Runtime.getRuntime().availableProcessors(), 6));
private final ExecutorService pingExecutor = Threads.cachedExecutor();
private final NetProvider provider;
@@ -326,13 +326,6 @@ public class Net{
pingExecutor.submit(() -> provider.pingHost(address, port, valid, failed));
}
/**
* Pings a host in an new thread. If an error occurred, failed() should be called with the exception.
*/
public void pingHostThread(String address, int port, Cons<Host> valid, Cons<Exception> failed){
Threads.daemon(() -> provider.pingHost(address, port, valid, failed));
}
/**
* Whether the net is active, e.g. whether this is a multiplayer game.
*/