Multithreading cleanup
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user