geforkt von Mirrors/Velocity
Use Netty thread factory to take advantage of FastThreadLocal
This should reduce CPU usage slightly.
Dieser Commit ist enthalten in:
Ursprung
c0becce276
Commit
dab9c9a382
@ -4,6 +4,7 @@ import com.google.common.base.Preconditions;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.util.concurrent.FastThreadLocal;
|
||||
import java.security.GeneralSecurityException;
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.SecretKey;
|
||||
@ -24,8 +25,12 @@ public class JavaVelocityCipher implements VelocityCipher {
|
||||
}
|
||||
};
|
||||
private static final int INITIAL_BUFFER_SIZE = 1024 * 8;
|
||||
private static final ThreadLocal<byte[]> inBufLocal = ThreadLocal.withInitial(
|
||||
() -> new byte[INITIAL_BUFFER_SIZE]);
|
||||
private static final FastThreadLocal<byte[]> inBufLocal = new FastThreadLocal<byte[]>() {
|
||||
@Override
|
||||
protected byte[] initialValue() {
|
||||
return new byte[INITIAL_BUFFER_SIZE];
|
||||
}
|
||||
};
|
||||
|
||||
private final Cipher cipher;
|
||||
private boolean disposed = false;
|
||||
|
@ -19,6 +19,7 @@ import io.netty.channel.socket.SocketChannel;
|
||||
import io.netty.channel.socket.nio.NioDatagramChannel;
|
||||
import io.netty.channel.socket.nio.NioServerSocketChannel;
|
||||
import io.netty.channel.socket.nio.NioSocketChannel;
|
||||
import io.netty.util.concurrent.DefaultThreadFactory;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
@ -60,10 +61,7 @@ enum TransportType {
|
||||
}
|
||||
|
||||
private static ThreadFactory createThreadFactory(final String name, final Type type) {
|
||||
return new ThreadFactoryBuilder()
|
||||
.setNameFormat("Netty " + name + ' ' + type.toString() + " #%d")
|
||||
.setDaemon(true)
|
||||
.build();
|
||||
return new DefaultThreadFactory("Netty " + name + ' ' + type.toString(), false);
|
||||
}
|
||||
|
||||
public static TransportType bestType() {
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren