Interface EventExecutor

    • Method Detail

      • inEventLoop

        boolean inEventLoop​(Thread thread)
        Return true if the given Thread is executed in the event loop, false otherwise.
      • newSucceededFuture

        default <V> Future<V> newSucceededFuture​(V result)
        Create a new Future which is marked as succeeded already. So AsynchronousResult.isSuccess() will return true. All FutureListener added to it will be notified directly. Also every call of blocking methods will just return without blocking.
        Specified by:
        newSucceededFuture in interface FuturePromiseFactory
      • newFailedFuture

        default <V> Future<V> newFailedFuture​(Throwable cause)
        Create a new Future which is marked as failed already. So AsynchronousResult.isSuccess() will return false. All FutureListener added to it will be notified directly. Also every call of blocking methods will just return without blocking.
        Specified by:
        newFailedFuture in interface FuturePromiseFactory
      • submit

        Future<Void> submit​(Runnable 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 produces a null result when the task completes.
        Specified by:
        submit in interface EventExecutorGroup
        Parameters:
        task - The task that should be executed in this EventExecutorGroup.
        Returns:
        A future that represents the completion of the submitted task.
      • submit

        <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 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

        <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 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.
      • schedule

        Future<Void> schedule​(Runnable task,
                              long delay,
                              TimeUnit unit)
        Description copied from interface: EventExecutorGroup
        Schedule the given task for execution after the given delay, in the next available EventExecutor in this group, and return a future that produces a null result when the task completes.
        Specified by:
        schedule in interface EventExecutorGroup
        Parameters:
        task - The task that should be executed in this EventExecutorGroup after the given delay.
        delay - A positive time delay, in the given time unit.
        unit - The non-null time unit for the delay.
        Returns:
        A future that represents the completion of the scheduled task.
      • schedule

        <V> Future<V> schedule​(Callable<V> task,
                               long delay,
                               TimeUnit unit)
        Description copied from interface: EventExecutorGroup
        Schedule the given task for execution after the given delay, 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:
        schedule in interface EventExecutorGroup
        Type Parameters:
        V - The type of the future result.
        Parameters:
        task - The task that should be executed in this EventExecutorGroup after the given delay.
        delay - A positive time delay, in the given time unit.
        unit - The non-null time unit for the delay.
        Returns:
        A future that represents the completion of the scheduled task.
      • scheduleAtFixedRate

        Future<Void> scheduleAtFixedRate​(Runnable task,
                                         long initialDelay,
                                         long period,
                                         TimeUnit unit)
        Description copied from interface: EventExecutorGroup
        Schedule the given task for periodic execution in the next available EventExecutor. The first execution will occur after the given initial delay, and the following repeated executions will occur with the given period of time between each execution is started. If the task takes longer to complete than the requested period, then the following executions will be delayed, rather than allowing multiple instances of the task to run concurrently.

        The task will be executed repeatedly until it either fails with an exception, or its future is cancelled. The future thus will never complete successfully.

        Specified by:
        scheduleAtFixedRate in interface EventExecutorGroup
        Parameters:
        task - The task that should be scheduled to execute at a fixed rate in this EventExecutorGroup.
        initialDelay - The positive initial delay for the first task execution, in terms of the given time unit.
        period - The positive period for the execution frequency to use after the first execution has started, in terms of the given time unit.
        unit - The non-null time unit for the delay and period.
        Returns:
        A future that represents the recurring task, and which can be cancelled to stop future executions.
      • scheduleWithFixedDelay

        Future<Void> scheduleWithFixedDelay​(Runnable task,
                                            long initialDelay,
                                            long delay,
                                            TimeUnit unit)
        Description copied from interface: EventExecutorGroup
        Schedule the given task for periodic execution in the next available EventExecutor. The first execution will occur after the given initial delay, and the following repeated executions will occur with the given subsequent delay between one task completing and the next task starting. The delay from the completion of one task, to the start of the next, stays unchanged regardless of how long a task takes to complete.

        This is in contrast to EventExecutorGroup.scheduleAtFixedRate(Runnable, long, long, TimeUnit) which varies the delays between the tasks in order to hit a given frequency.

        The task will be executed repeatedly until it either fails with an exception, or its future is cancelled. The future thus will never complete successfully.

        Specified by:
        scheduleWithFixedDelay in interface EventExecutorGroup
        Parameters:
        task - The task that should be scheduled to execute with fixed delays in this EventExecutorGroup.
        initialDelay - The positive initial delay for the first task execution, in terms of the given time unit.
        delay - The positive subsequent delay between task, to use after the first execution has completed, in terms of the given time unit.
        unit - The non-null time unit for the delays.
        Returns:
        A future that represents the recurring task, and which can be cancelled to stop future executions.