hasOwnGroup status prop added to RedisClient

pull/382/head
Nikita 9 years ago
parent 87c67b1115
commit 3cac42263b

@ -47,9 +47,11 @@ public class RedisClient {
private final ChannelGroup channels = new DefaultChannelGroup(GlobalEventExecutor.INSTANCE); private final ChannelGroup channels = new DefaultChannelGroup(GlobalEventExecutor.INSTANCE);
private final long timeout; private final long timeout;
private boolean hasOwnGroup;
public RedisClient(String host, int port) { public RedisClient(String host, int port) {
this(new NioEventLoopGroup(), NioSocketChannel.class, host, port, 60 * 1000); this(new NioEventLoopGroup(), NioSocketChannel.class, host, port, 60 * 1000);
hasOwnGroup = true;
} }
public RedisClient(EventLoopGroup group, Class<? extends SocketChannel> socketChannelClass, String host, int port, int timeout) { public RedisClient(EventLoopGroup group, Class<? extends SocketChannel> socketChannelClass, String host, int port, int timeout) {
@ -138,8 +140,10 @@ public class RedisClient {
public void shutdown() { public void shutdown() {
shutdownAsync().syncUninterruptibly(); shutdownAsync().syncUninterruptibly();
if (hasOwnGroup) {
bootstrap.group().shutdownGracefully(); bootstrap.group().shutdownGracefully();
} }
}
public ChannelGroupFuture shutdownAsync() { public ChannelGroupFuture shutdownAsync() {
return channels.close(); return channels.close();

Loading…
Cancel
Save