mirror of https://github.com/grpc/grpc-java.git
Daemonize OkHttp and Netty
This commit is contained in:
parent
f641e081a0
commit
07a7279742
|
|
@ -170,7 +170,10 @@ class Utils {
|
||||||
@Override
|
@Override
|
||||||
public EventLoopGroup create() {
|
public EventLoopGroup create() {
|
||||||
// Use the executor based constructor so we can work with both Netty4 & Netty5.
|
// Use the executor based constructor so we can work with both Netty4 & Netty5.
|
||||||
ThreadFactory threadFactory = new ThreadFactoryBuilder().setNameFormat(name + "-%d").build();
|
ThreadFactory threadFactory = new ThreadFactoryBuilder()
|
||||||
|
.setDaemon(true)
|
||||||
|
.setNameFormat(name + "-%d")
|
||||||
|
.build();
|
||||||
int parallelism = numEventLoops == 0
|
int parallelism = numEventLoops == 0
|
||||||
? Runtime.getRuntime().availableProcessors() * 2 : numEventLoops;
|
? Runtime.getRuntime().availableProcessors() * 2 : numEventLoops;
|
||||||
final ExecutorService executor = Executors.newFixedThreadPool(parallelism, threadFactory);
|
final ExecutorService executor = Executors.newFixedThreadPool(parallelism, threadFactory);
|
||||||
|
|
|
||||||
|
|
@ -80,6 +80,7 @@ public final class OkHttpChannelBuilder extends
|
||||||
@Override
|
@Override
|
||||||
public ExecutorService create() {
|
public ExecutorService create() {
|
||||||
return Executors.newCachedThreadPool(new ThreadFactoryBuilder()
|
return Executors.newCachedThreadPool(new ThreadFactoryBuilder()
|
||||||
|
.setDaemon(true)
|
||||||
.setNameFormat("grpc-okhttp-%d")
|
.setNameFormat("grpc-okhttp-%d")
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue