Class AbstractEventExecutor

    • Constructor Detail

      • AbstractEventExecutor

        public AbstractEventExecutor()
    • Method Detail

      • submit

        public final <T> Future<T> submit​(Runnable task,
                                          T result)
        Description copied from interface: EventExecutorGroup
        Submit the given task for execution in the next available EventExecutor in this group, and return a future that produces the given result when the task completes.
        Specified by:
        submit in interface EventExecutor
        Specified by:
        submit in interface EventExecutorGroup
        Type Parameters:
        T - The type of the future result.
        Parameters:
        task - The task that should be executed in this EventExecutorGroup.
        result - The value that the returned future will complete with, if the task completes successfully.
        Returns:
        A future that represents the completion of the submitted task.
      • submit

        public final <T> Future<T> submit​(Callable<T> task)
        Description copied from interface: EventExecutorGroup
        Submit the given task for execution in the next available EventExecutor in this group, and return a future that will return the result of the callable when the task completes.
        Specified by:
        submit in interface EventExecutor
        Specified by:
        submit in interface EventExecutorGroup
        Type Parameters:
        T - The type of the future result.
        Parameters:
        task - The task that should be executed in this EventExecutorGroup.
        Returns:
        A future that represents the completion of the submitted task.
      • newTaskFor

        protected <T> RunnableFuture<T> newTaskFor​(Runnable runnable,
                                                   T value)
        Decorate the given Runnable and its return value, as a RunnableFuture, such that the returned RunnableFuture completes with the given result at the end of executing its Runnable.run() method.

        The returned RunnableFuture is the task that will actually be run by a thread in this executor.

        This method can be overridden by sub-classes to hook into the life cycle of the given task.

        Type Parameters:
        T - The type of the result value.
        Parameters:
        runnable - The task to be decorated.
        value - The value that the returned future will complete with, assuming the given Runnable doesn't throw an exception.
        Returns:
        The decorated Runnable that is now also a Future.
      • newTaskFor

        protected <T> RunnableFuture<T> newTaskFor​(Callable<T> callable)
        Decorate the given Callable and its return value, as a RunnableFuture, such that the returned RunnableFuture completes with the returned result from the Callable at the end of executing its Runnable.run() method.

        The returned RunnableFuture is the task that will actually be run by a thread in this executor.

        This method can be overridden by sub-classes to hook into the life cycle of the given task.

        Type Parameters:
        T - The type of the result value.
        Parameters:
        callable - The task to be decorated.
        Returns:
        The decorated Runnable that is now also a Future.