Doubled the default number of I/O threads which seems to be more sensible better performing default

This commit is contained in:
Trustin Lee 2010-02-23 05:42:39 +00:00
parent b010cd15a5
commit 69450ee6ec
4 changed files with 8 additions and 6 deletions

View File

@ -91,7 +91,7 @@ public class NioClientSocketChannelFactory implements ClientSocketChannelFactory
/**
* Creates a new instance. Calling this constructor is same with calling
* {@link #NioClientSocketChannelFactory(Executor, Executor, int)} with
* {@link #NioClientSocketChannelFactory(Executor, Executor, int)} with 2 *
* the number of available processors in the machine. The number of
* available processors is obtained by {@link Runtime#availableProcessors()}.
*
@ -102,7 +102,7 @@ public class NioClientSocketChannelFactory implements ClientSocketChannelFactory
*/
public NioClientSocketChannelFactory(
Executor bossExecutor, Executor workerExecutor) {
this(bossExecutor, workerExecutor, Runtime.getRuntime().availableProcessors());
this(bossExecutor, workerExecutor, SelectorUtil.DEFAULT_IO_THREADS);
}
/**

View File

@ -87,7 +87,7 @@ public class NioDatagramChannelFactory implements DatagramChannelFactory {
/**
* Creates a new instance. Calling this constructor is same with calling
* {@link #NioDatagramChannelFactory(Executor, int)} with the number of
* {@link #NioDatagramChannelFactory(Executor, int)} with 2 * the number of
* available processors in the machine. The number of available processors
* is obtained by {@link Runtime#availableProcessors()}.
*
@ -95,7 +95,7 @@ public class NioDatagramChannelFactory implements DatagramChannelFactory {
* the {@link Executor} which will execute the I/O worker threads
*/
public NioDatagramChannelFactory(final Executor workerExecutor) {
this(workerExecutor, Runtime.getRuntime().availableProcessors());
this(workerExecutor, SelectorUtil.DEFAULT_IO_THREADS);
}
/**

View File

@ -95,7 +95,7 @@ public class NioServerSocketChannelFactory implements ServerSocketChannelFactory
/**
* Creates a new instance. Calling this constructor is same with calling
* {@link #NioServerSocketChannelFactory(Executor, Executor, int)} with
* {@link #NioServerSocketChannelFactory(Executor, Executor, int)} with 2 *
* the number of available processors in the machine. The number of
* available processors is obtained by {@link Runtime#availableProcessors()}.
*
@ -106,7 +106,7 @@ public class NioServerSocketChannelFactory implements ServerSocketChannelFactory
*/
public NioServerSocketChannelFactory(
Executor bossExecutor, Executor workerExecutor) {
this(bossExecutor, workerExecutor, Runtime.getRuntime().availableProcessors());
this(bossExecutor, workerExecutor, SelectorUtil.DEFAULT_IO_THREADS);
}
/**

View File

@ -31,6 +31,8 @@ final class SelectorUtil {
private static final InternalLogger logger =
InternalLoggerFactory.getInstance(SelectorUtil.class);
static final int DEFAULT_IO_THREADS = Runtime.getRuntime().availableProcessors() * 2;
static void select(Selector selector) throws IOException {
try {
selector.select(500);