Add names to network threads

This commit is contained in:
s809
2024-01-05 22:08:37 +05:00
parent 8b0f6a4414
commit dbc1ad4cb7
2 changed files with 5 additions and 3 deletions
@@ -30,6 +30,7 @@ import io.netty.bootstrap.Bootstrap;
import io.netty.channel.*;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioSocketChannel;
import io.netty.util.concurrent.DefaultThreadFactory;
import org.apache.logging.log4j.Logger;
import java.net.InetSocketAddress;
@@ -68,7 +69,7 @@ public class NetworkClient extends NetworkEventSource implements IConnection, Au
/** Indicates whether the connection is established and first message is sent. */
public boolean isReady() { return ready; }
private final EventLoopGroup workerGroup = new NioEventLoopGroup();
private final EventLoopGroup workerGroup = new NioEventLoopGroup(new DefaultThreadFactory("DH-Network - Client Thread"));
private final Bootstrap clientBootstrap = new Bootstrap()
.group(this.workerGroup)
.channel(NioSocketChannel.class)
@@ -33,6 +33,7 @@ import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioServerSocketChannel;
import io.netty.handler.logging.LogLevel;
import io.netty.handler.logging.LoggingHandler;
import io.netty.util.concurrent.DefaultThreadFactory;
import org.apache.logging.log4j.Logger;
import java.util.concurrent.ConcurrentMap;
@@ -45,8 +46,8 @@ public class NetworkServer extends NetworkEventSource implements AutoCloseable
// TODO move to the config
private final int port;
private final EventLoopGroup bossGroup = new NioEventLoopGroup(1);
private final EventLoopGroup workerGroup = new NioEventLoopGroup();
private final EventLoopGroup bossGroup = new NioEventLoopGroup(1, new DefaultThreadFactory("DH-Network - Server Boss Thread"));
private final EventLoopGroup workerGroup = new NioEventLoopGroup(new DefaultThreadFactory("DH-Network - Server Worker Thread"));
private final AtomicBoolean isClosed = new AtomicBoolean();
private final ConcurrentMap<ChannelHandlerContext, IConnection> connections = new MapMaker().weakKeys().weakValues().makeMap();