netty: make default number of event loops defer to netty

This commit is contained in:
Carl Mastrangelo 2019-04-12 12:42:18 -07:00 committed by GitHub
parent 62b03fd7e6
commit 21141cc837
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 6 deletions

View File

@ -176,7 +176,7 @@ class Utils {
return s; return s;
} }
private static class DefaultEventLoopGroupResource implements Resource<EventLoopGroup> { private static final class DefaultEventLoopGroupResource implements Resource<EventLoopGroup> {
private final String name; private final String name;
private final int numEventLoops; private final int numEventLoops;
@ -188,11 +188,8 @@ class Utils {
@Override @Override
public EventLoopGroup create() { public EventLoopGroup create() {
// Use Netty's DefaultThreadFactory in order to get the benefit of FastThreadLocal. // Use Netty's DefaultThreadFactory in order to get the benefit of FastThreadLocal.
boolean useDaemonThreads = true; ThreadFactory threadFactory = new DefaultThreadFactory(name, /* daemon= */ true);
ThreadFactory threadFactory = new DefaultThreadFactory(name, useDaemonThreads); return new NioEventLoopGroup(numEventLoops, threadFactory);
int parallelism = numEventLoops == 0
? Runtime.getRuntime().availableProcessors() * 2 : numEventLoops;
return new NioEventLoopGroup(parallelism, threadFactory);
} }
@Override @Override