This commit is contained in:
@@ -18,7 +18,6 @@ import org.redkale.net.AsyncConnection;
|
||||
import org.redkale.net.nio.NioCompletionHandler;
|
||||
import org.redkale.net.nio.NioThread;
|
||||
import org.redkale.net.nio.NioThreadGroup;
|
||||
import org.redkale.util.ObjectPool;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -81,9 +80,9 @@ public class TcpNioAsyncConnection extends AsyncConnection {
|
||||
private SelectionKey writeKey;
|
||||
|
||||
public TcpNioAsyncConnection(NioThreadGroup ioGroup, NioThread ioThread, ExecutorService workExecutor,
|
||||
ObjectPool<ByteBuffer> bufferPool, SocketChannel ch,
|
||||
SocketChannel ch,
|
||||
SSLContext sslContext, final SocketAddress addr0, AtomicLong livingCounter, AtomicLong closedCounter) {
|
||||
super(bufferPool, sslContext, livingCounter, closedCounter);
|
||||
super(ioThread.getBufferPool(), sslContext, livingCounter, closedCounter);
|
||||
this.ioGroup = ioGroup;
|
||||
this.ioThread = ioThread;
|
||||
this.workExecutor = workExecutor;
|
||||
|
||||
@@ -85,7 +85,7 @@ public class TcpNioProtocolServer extends ProtocolServer {
|
||||
@Override
|
||||
public void accept(Server server) throws IOException {
|
||||
this.serverChannel.register(this.selector, SelectionKey.OP_ACCEPT);
|
||||
|
||||
|
||||
AtomicLong createBufferCounter = new AtomicLong();
|
||||
AtomicLong cycleBufferCounter = new AtomicLong();
|
||||
this.bufferPool = server.createBufferPool(createBufferCounter, cycleBufferCounter, server.bufferPoolSize);
|
||||
@@ -93,10 +93,10 @@ public class TcpNioProtocolServer extends ProtocolServer {
|
||||
AtomicLong cycleResponseCounter = new AtomicLong();
|
||||
this.responsePool = server.createResponsePool(createResponseCounter, cycleResponseCounter, server.responsePoolSize);
|
||||
this.responsePool.setCreator(server.createResponseCreator(bufferPool, responsePool));
|
||||
|
||||
|
||||
this.ioGroup = new NioThreadGroup(Runtime.getRuntime().availableProcessors(), context.executor, bufferPool);
|
||||
this.ioGroup.start();
|
||||
|
||||
|
||||
this.acceptThread = new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -129,7 +129,7 @@ public class TcpNioProtocolServer extends ProtocolServer {
|
||||
channel.setOption(StandardSocketOptions.SO_RCVBUF, 16 * 1024);
|
||||
channel.setOption(StandardSocketOptions.SO_SNDBUF, 16 * 1024);
|
||||
NioThread ioThread = ioGroup.nextThread();
|
||||
AsyncConnection conn = new TcpNioAsyncConnection(ioGroup, ioThread, context.executor, bufferPool, channel, context.getSSLContext(), null, livingCounter, closedCounter);
|
||||
AsyncConnection conn = new TcpNioAsyncConnection(ioGroup, ioThread, context.executor, channel, context.getSSLContext(), null, livingCounter, closedCounter);
|
||||
new PrepareRunner(context, responsePool, conn, null, null).run();
|
||||
}
|
||||
|
||||
|
||||
@@ -50,6 +50,10 @@ public class NioThread extends Thread {
|
||||
selector.wakeup();
|
||||
}
|
||||
|
||||
public ObjectPool<ByteBuffer> getBufferPool() {
|
||||
return bufferPool;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
this.localThread = Thread.currentThread();
|
||||
|
||||
Reference in New Issue
Block a user