Class GlobalEventExecutor

    • Method Detail

      • pendingTasks

        public int pendingTasks()
        Return the number of tasks that are pending for processing.
      • inEventLoop

        public boolean inEventLoop​(Thread thread)
        Description copied from interface: EventExecutor
        Return true if the given Thread is executed in the event loop, false otherwise.
        Specified by:
        inEventLoop in interface EventExecutor
      • shutdownGracefully

        public Future<Void> shutdownGracefully​(long quietPeriod,
                                               long timeout,
                                               TimeUnit unit)
        Description copied from interface: EventExecutorGroup
        Signals this executor that the caller wants the executor to be shut down. Once this method is called, EventExecutorGroup.isShuttingDown() starts to return true, and the executor prepares to shut itself down. This method ensures that no tasks are submitted for 'the quiet period' (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.
        Specified by:
        shutdownGracefully in interface EventExecutorGroup
        Parameters:
        quietPeriod - the quiet period as described in the documentation
        timeout - the maximum amount of time to wait until the executor is shutting down regardless if a task was submitted during the quiet period.
        unit - the unit of quietPeriod and timeout
        Returns:
        the EventExecutorGroup.terminationFuture()
      • isShuttingDown

        public boolean isShuttingDown()
        Description copied from interface: EventExecutorGroup
        Returns true if and only if all EventExecutors managed by this EventExecutorGroup are being shut down gracefully or was shut down.

        An executor group that "is shutting down" can still accept new tasks for a little while (the grace period), but will eventually start rejecting new tasks. At that point, the executor group will be shut down.

        Specified by:
        isShuttingDown in interface EventExecutorGroup
        Returns:
        true if all executors in this group have at least started shutting down, otherwise false.
      • isShutdown

        public boolean isShutdown()
        Description copied from interface: EventExecutorGroup
        Returns true if all EventExecutors managed by this EventExecutorGroup have been shut down gracefully and moved past the grace period so that they are no longer accepting any new tasks.

        An executor group that "is shut down" might still be executing tasks that it has queued up, but it will no longer be accepting any new tasks. Once all running and queued tasks have completed, the executor group will be terminated.

        Specified by:
        isShutdown in interface EventExecutorGroup
        Returns:
        true if all executors in this group have shut down and are no longer accepting any new tasks.
      • awaitTermination

        public boolean awaitTermination​(long timeout,
                                        TimeUnit unit)
        Description copied from interface: EventExecutorGroup
        Wait for this EventExecutorGroup to terminate, up to the given timeout.
        Specified by:
        awaitTermination in interface EventExecutorGroup
        Parameters:
        timeout - The non-negative maximum amount of time to wait for the executor group to terminate.
        unit - The non-null time unit of the timeout.
        Returns:
        true if the executor group terminated within the specific timeout.
      • awaitInactivity

        public boolean awaitInactivity​(long timeout,
                                       TimeUnit unit)
                                throws InterruptedException
        Waits until the worker thread of this executor has no tasks left in its task queue and terminates itself. Because a new worker thread will be started again when a new task is submitted, this operation is only useful when you want to ensure that the worker thread is terminated after your application is shut down and there's no chance of submitting a new task afterwards.
        Returns:
        true if and only if the worker thread has been terminated
        Throws:
        InterruptedException