From 21141cc83742c4b712561bc91de30816d028d3b8 Mon Sep 17 00:00:00 2001 From: Carl Mastrangelo Date: Fri, 12 Apr 2019 12:42:18 -0700 Subject: [PATCH] netty: make default number of event loops defer to netty --- netty/src/main/java/io/grpc/netty/Utils.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/netty/src/main/java/io/grpc/netty/Utils.java b/netty/src/main/java/io/grpc/netty/Utils.java index 6cb5b9f221..f0e59e108e 100644 --- a/netty/src/main/java/io/grpc/netty/Utils.java +++ b/netty/src/main/java/io/grpc/netty/Utils.java @@ -176,7 +176,7 @@ class Utils { return s; } - private static class DefaultEventLoopGroupResource implements Resource { + private static final class DefaultEventLoopGroupResource implements Resource { private final String name; private final int numEventLoops; @@ -188,11 +188,8 @@ class Utils { @Override public EventLoopGroup create() { // Use Netty's DefaultThreadFactory in order to get the benefit of FastThreadLocal. - boolean useDaemonThreads = true; - ThreadFactory threadFactory = new DefaultThreadFactory(name, useDaemonThreads); - int parallelism = numEventLoops == 0 - ? Runtime.getRuntime().availableProcessors() * 2 : numEventLoops; - return new NioEventLoopGroup(parallelism, threadFactory); + ThreadFactory threadFactory = new DefaultThreadFactory(name, /* daemon= */ true); + return new NioEventLoopGroup(numEventLoops, threadFactory); } @Override