public TimeoutAsyncPoolHandle( AsyncPool<T> pool, ScheduledExecutorService scheduler, long timeout, TimeUnit unit, T item) { _pool = pool; _timeout = new Timeout<>(scheduler, timeout, unit, item); _timeout.addTimeoutTask(() -> _pool.put(item)); }
@Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { if (msg == CHANNEL_RELEASE_SIGNAL) { AsyncPool<Channel> pool = ctx.channel().attr(CHANNEL_POOL_ATTR_KEY).getAndSet(null); if (pool != null) { pool.put(ctx.channel()); } } else if (msg == CHANNEL_DESTROY_SIGNAL) { AsyncPool<Channel> pool = ctx.channel().attr(CHANNEL_POOL_ATTR_KEY).getAndSet(null); if (pool != null) { pool.dispose(ctx.channel()); } } }
@Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { AsyncPool<Channel> pool = ctx.channel().attr(CHANNEL_POOL_ATTR_KEY).getAndSet(null); if (pool != null) { RestResponse restResponse = (RestResponse) msg; List<String> connectionTokens = restResponse.getHeaderValues("connection"); if (connectionTokens != null) { for (String token: connectionTokens) { if ("close".equalsIgnoreCase(token)) { pool.dispose(ctx.channel()); return; } } } pool.put(ctx.channel()); } }
if (pool != null) pool.put(channel);
_pool.put(channel); return;
if (pool != null) pool.put(channel);