Multithreading cleanup

This commit is contained in:
Anuken
2018-10-10 23:43:48 -04:00
parent 67db5e9dfc
commit 52bd079c0a
18 changed files with 50 additions and 359 deletions

View File

@@ -9,8 +9,6 @@ import io.anuke.ucore.util.Pooling;
import java.nio.ByteBuffer;
import static io.anuke.mindustry.net.Net.packetPoolLock;
@SuppressWarnings("unchecked")
public class ByteSerializer implements Serialization {
@@ -36,11 +34,9 @@ public class ByteSerializer implements Serialization {
if(id == -2){
return FrameworkSerializer.read(byteBuffer);
}else{
synchronized (packetPoolLock) {
Packet packet = Pooling.obtain((Class<Packet>) Registrator.getByID(id).type, (Supplier<Packet>) Registrator.getByID(id).constructor);
packet.read(byteBuffer);
return packet;
}
Packet packet = Pooling.obtain((Class<Packet>) Registrator.getByID(id).type, (Supplier<Packet>) Registrator.getByID(id).constructor);
packet.read(byteBuffer);
return packet;
}
}

View File

@@ -28,7 +28,6 @@ import java.nio.channels.ClosedSelectorException;
import java.util.List;
import static io.anuke.mindustry.Vars.*;
import static io.anuke.mindustry.net.Net.packetPoolLock;
public class KryoClient implements ClientProvider{
Client client;
@@ -146,9 +145,7 @@ public class KryoClient implements ClientProvider{
client.sendUDP(object);
}
synchronized (packetPoolLock) {
Pooling.free(object);
}
Pooling.free(object);
}
@Override