接口 IExecutor

所有超级接口:
Executor
所有已知子接口:
EventLoop, EventLoopGroup, FixedEventLoopGroup, IExecutorService, IScheduledExecutorService, UniExecutorService, UniScheduledExecutor
所有已知实现类:
AbstractEventLoop, AbstractEventLoopGroup, AbstractUniExecutor, AbstractUniScheduledExecutor, DefaultFixedEventLoopGroup, DefaultUniExecutor, DefaultUniScheduledExecutor, DisruptorEventLoop

public interface IExecutor extends Executor
IExecutorExecutor的基础上增加了调度选项。

该接口需要保持较高的抽象,因此将submit之类的方法下沉到子接口。如果需要获取任务结果, 可通过FutureUtils.submitFunc(Executor, Function, IContext)这类工具方法实现。

作者:
wjybxx date - 2024/1/9
  • 方法详细资料

    • execute

      void execute(Runnable command)
      在将来的某个时间执行给定的命令。 命令可以在新线程中执行,也可以在池线程中执行,或者在调用线程中执行,这由Executor实现决定。 Executor.execute(Runnable)
      指定者:
      execute 在接口中 Executor
      参数:
      command - 要执行的任务,注意ITask类型
      抛出:
      NullPointerException - 如果任务为null
      RejectedExecutionException - 如果Executor已开始关闭
    • execute

      default void execute(Runnable command, int options)
      在将来的某个时间执行给定的命令。 命令可以在新线程中执行,也可以在池线程中执行,或者在调用线程中执行,这由Executor实现决定。 Executor.execute(Runnable)

      任务的调度特征值 1.Executor需要感知用户任务的一些属性,以实现更好的管理。 2.选项可参考TaskOption。 3.该接口不应该测试任务的类型,应当以参数的options为准。

      参数:
      command - 要执行的任务
      options - 任务的调度特征值,见TaskOption
      抛出:
      NullPointerException - 如果任务为null
      RejectedExecutionException - 如果Executor已开始关闭
    • execute

      default void execute(Consumer<? super IContext> action, IContext ctx)
      ConsumerRunnable的lambda差异足够大,因此选择重载。
      参数:
      action - 要执行的任务
      ctx - 任务绑定的上下文
      抛出:
      NullPointerException - 如果任务为null
      RejectedExecutionException - 如果Executor已开始关闭
    • execute

      default void execute(Consumer<? super IContext> action, IContext ctx, int options)