mirror of https://github.com/grpc/grpc-java.git
netty: make default number of event loops defer to netty
This commit is contained in:
parent
62b03fd7e6
commit
21141cc837
|
|
@ -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
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue