package io.netty.util.concurrent;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
/**
* The {@link EventExecutorGroup} is responsible for providing the
* {@link EventExecutor}'s to use via its {@link #next()} method. Besides this,
* it is also responsible for handling their life-cycle and allows shutting them
* down in a global fashion.
* EventExecutorGroup负责调用他的next()方法来提供EventExecutor,除了这个之外,他还负责处理他们的生命周期,
* 并且提供了一个全局的方式来关闭他们。
*
*/
public interface EventExecutorGroup extends ScheduledExecutorService, Iterable<EventExecutor> {
/**
* * Returns {@code true} if and only if all {@link EventExecutor}s managed by
* this {@link EventExecutorGroup} * are being {@linkplain #shutdownGracefully()
* shut down gracefully} or was {@linkplain #isShutdown() shut down}.
* 当且且当这个EventExecutorGroup所管理的全部EventExecutor正在被优雅的关闭或者关闭之后才会返回true.
*/
boolean isShuttingDown();
/**
* Shortcut method for {@link #shutdownGracefully(long, long, TimeUnit)} with
* sensible default values. *z * @return the {@link #terminationFuture()}
* 这是对另一个全参数方法的缩写,会提供一些默认的值。
*/
Future<?> shutdownGracefully();
/**
* Signals this executor that the caller wants the executor to be shut down.
* Once this method is called, {@link #isShuttingDown()} starts to return
* {@code true}, and the executor prepares to shut itself down. Unlike
* {@link #shutdown()}, graceful shutdown ensures that no tasks are submitted
* for <i>'the quiet period'</i> (usually a couple seconds) before it shuts
* itself down. If a task is submitted during the quiet period, it is guaranteed
* to be accepted and the quiet period will start over.
* 调用者想让这个执行者关闭,就会通过这个方法告诉执行者。一旦这个方法被调用,isShuttingDown()就会返回true,执行者准备关闭他们自身。
* 不像shutdown()方法,优雅的shutdown保证了在它关闭他自身之前的一段的时间内没有任务会被提交,通常这个时间段就是几秒。
* 如果一个任务在这个时间内被提交到excutor当中,他就一定会被接受,并且这个时间会被重新开始计算。
*
* @param quietPeriod
* the quiet period as described in the documentation
* @param timeout the maximum amount of time to wait until the executor is{@linkplain #shutdown()}
* regardless if a task was submitted during the quiet period
* @param unit the unit of {@code quietPeriod} and {@code timeout}
* @return the {@link #terminationFuture()}
*/
Future<?> shutdownGracefully(long quietPeriod, long timeout, TimeUnit unit);
/**
* Returns the {@link Future} which is notified when all
* {@link EventExecutor}s managed by this * {@link EventExecutorGroup} have been
* terminated.
*/
Future<?> terminationFuture();
/**
* Returns one of the {@link EventExecutor}s managed by this {@link EventExecutorGroup}.
返回EventExecutorGroup所管理的EventExecutor
*/
EventExecutor next();
.....
}
Netty中的EventExecutorGroup
最新推荐文章于 2024-06-28 14:42:40 发布