@Override public Future<?> shutdownGracefully(long quietPeriod, long timeout, TimeUnit unit) { shuttingDown = true; for (EventLoop l: activeChildren) { l.shutdownGracefully(quietPeriod, timeout, unit); } for (EventLoop l: idleChildren) { l.shutdownGracefully(quietPeriod, timeout, unit); } // Notify the future if there was no children. if (isTerminated()) { terminationFuture.trySuccess(null); } return terminationFuture(); }
private EventLoop nextChild() throws Exception { if (shuttingDown) { throw new RejectedExecutionException("shutting down"); } EventLoop loop = idleChildren.poll(); if (loop == null) { if (maxChannels > 0 && activeChildren.size() >= maxChannels) { throw tooManyChannels; } loop = newChild(childArgs); loop.terminationFuture().addListener(childTerminationListener); } activeChildren.add(loop); return loop; } }
@Deprecated @Override public ChannelFuture register(Channel channel, ChannelPromise promise) { if (channel == null) { throw new NullPointerException("channel"); } try { return nextChild().register(channel, promise); } catch (Throwable t) { promise.setFailure(t); return promise; } }
@Override public void operationComplete(Future<Object> future) throws Exception { // Inefficient, but works. if (isTerminated()) { terminationFuture.trySuccess(null); } } };
@Override public void operationComplete(Future<Object> future) throws Exception { // Inefficient, but works. if (isTerminated()) { terminationFuture.trySuccess(null); } } };
@Override public Future<?> shutdownGracefully(long quietPeriod, long timeout, TimeUnit unit) { shuttingDown = true; for (EventLoop l: activeChildren) { l.shutdownGracefully(quietPeriod, timeout, unit); } for (EventLoop l: idleChildren) { l.shutdownGracefully(quietPeriod, timeout, unit); } // Notify the future if there was no children. if (isTerminated()) { terminationFuture.trySuccess(null); } return terminationFuture(); }
@Override public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException { long deadline = System.nanoTime() + unit.toNanos(timeout); for (EventLoop l: activeChildren) { for (;;) { long timeLeft = deadline - System.nanoTime(); if (timeLeft <= 0) { return isTerminated(); } if (l.awaitTermination(timeLeft, TimeUnit.NANOSECONDS)) { break; } } } for (EventLoop l: idleChildren) { for (;;) { long timeLeft = deadline - System.nanoTime(); if (timeLeft <= 0) { return isTerminated(); } if (l.awaitTermination(timeLeft, TimeUnit.NANOSECONDS)) { break; } } } return isTerminated(); }
@Override public ChannelFuture register(ChannelPromise promise) { try { return nextChild().register(promise); } catch (Throwable t) { promise.setFailure(t); return promise; } }
private EventLoop nextChild() throws Exception { if (shuttingDown) { throw new RejectedExecutionException("shutting down"); } EventLoop loop = idleChildren.poll(); if (loop == null) { if (maxChannels > 0 && activeChildren.size() >= maxChannels) { throw tooManyChannels; } loop = newChild(childArgs); loop.terminationFuture().addListener(childTerminationListener); } activeChildren.add(loop); return loop; } }
@Override public Future<?> shutdownGracefully(long quietPeriod, long timeout, TimeUnit unit) { shuttingDown = true; for (EventLoop l: activeChildren) { l.shutdownGracefully(quietPeriod, timeout, unit); } for (EventLoop l: idleChildren) { l.shutdownGracefully(quietPeriod, timeout, unit); } // Notify the future if there was no children. if (isTerminated()) { terminationFuture.trySuccess(null); } return terminationFuture(); }
@Override public void operationComplete(Future<Object> future) throws Exception { // Inefficient, but works. if (isTerminated()) { terminationFuture.trySuccess(null); } } };
@Deprecated @Override public ChannelFuture register(Channel channel, ChannelPromise promise) { if (channel == null) { throw new NullPointerException("channel"); } try { return nextChild().register(channel, promise); } catch (Throwable t) { promise.setFailure(t); return promise; } }
private EventLoop nextChild() throws Exception { if (shuttingDown) { throw new RejectedExecutionException("shutting down"); } EventLoop loop = idleChildren.poll(); if (loop == null) { if (maxChannels > 0 && activeChildren.size() >= maxChannels) { throw tooManyChannels; } loop = newChild(childArgs); loop.terminationFuture().addListener(childTerminationListener); } activeChildren.add(loop); return loop; } }
@Override public Future<?> shutdownGracefully(long quietPeriod, long timeout, TimeUnit unit) { shuttingDown = true; for (EventLoop l: activeChildren) { l.shutdownGracefully(quietPeriod, timeout, unit); } for (EventLoop l: idleChildren) { l.shutdownGracefully(quietPeriod, timeout, unit); } // Notify the future if there was no children. if (isTerminated()) { terminationFuture.trySuccess(null); } return terminationFuture(); }
@Override public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException { long deadline = System.nanoTime() + unit.toNanos(timeout); for (EventLoop l: activeChildren) { for (;;) { long timeLeft = deadline - System.nanoTime(); if (timeLeft <= 0) { return isTerminated(); } if (l.awaitTermination(timeLeft, TimeUnit.NANOSECONDS)) { break; } } } for (EventLoop l: idleChildren) { for (;;) { long timeLeft = deadline - System.nanoTime(); if (timeLeft <= 0) { return isTerminated(); } if (l.awaitTermination(timeLeft, TimeUnit.NANOSECONDS)) { break; } } } return isTerminated(); }
@Override public ChannelFuture register(Channel channel) { if (channel == null) { throw new NullPointerException("channel"); } try { EventLoop l = nextChild(); return l.register(new DefaultChannelPromise(channel, l)); } catch (Throwable t) { return new FailedChannelFuture(channel, GlobalEventExecutor.INSTANCE, t); } }
private EventLoop nextChild() throws Exception { if (shuttingDown) { throw new RejectedExecutionException("shutting down"); } EventLoop loop = idleChildren.poll(); if (loop == null) { if (maxChannels > 0 && activeChildren.size() >= maxChannels) { throw tooManyChannels; } loop = newChild(childArgs); loop.terminationFuture().addListener(childTerminationListener); } activeChildren.add(loop); return loop; } }
@Override public Future<?> shutdownGracefully(long quietPeriod, long timeout, TimeUnit unit) { shuttingDown = true; for (EventLoop l: activeChildren) { l.shutdownGracefully(quietPeriod, timeout, unit); } for (EventLoop l: idleChildren) { l.shutdownGracefully(quietPeriod, timeout, unit); } // Notify the future if there was no children. if (isTerminated()) { terminationFuture.trySuccess(null); } return terminationFuture(); }
@Override @Deprecated public void shutdown() { shuttingDown = true; for (EventLoop l: activeChildren) { l.shutdown(); } for (EventLoop l: idleChildren) { l.shutdown(); } // Notify the future if there was no children. if (isTerminated()) { terminationFuture.trySuccess(null); } }
@Override public ChannelFuture register(ChannelPromise promise) { try { return nextChild().register(promise); } catch (Throwable t) { promise.setFailure(t); return promise; } }