Interface FilterDispatchExecutor

All Superinterfaces:
AutoCloseable, Executor, ExecutorService, ScheduledExecutorService

public interface FilterDispatchExecutor extends ScheduledExecutorService
An Executor backed by the Filter Dispatch Thread. That is the single thread associated with the Channel for a Filter Instance. All invocations of that instance's methods are made by the Filter Dispatch Thread.

If all accesses/mutations of Filter Members happen on the Filter Dispatch Thread, then those interactions are serial and threadsafe. This executor enables Authors to do work in uncontrolled threads and then return to the Filter Dispatch Thread to take advantage of this convenient threading guarantee.

Note that implementations of FilterDispatchExecutor will not honour the shut-down methods ExecutorService.shutdown() and ExecutorService.shutdownNow() and will throw a RuntimeException if those methods are called, as the client is not allowed to shut down the Filter Dispatch Thread.

See Also:
  • Method Details

    • isInFilterDispatchThread

      boolean isInFilterDispatchThread()
      Returns:
      Return true if Thread.currentThread() is this Filter Dispatch Thread, false otherwise
    • completeOnFilterDispatchThread

      <T> CompletionStage<T> completeOnFilterDispatchThread(CompletionStage<T> stage)
      Switches to this Filter Dispatch Thread. The CompletionStage returned is an implementation that discourages blocking work and will throw if the client attempts to call CompletionStage.toCompletableFuture(). Any async work chained onto the result CompletionStage using methods like CompletionStage.thenApplyAsync(Function) will also be executed on the Filter Dispatch Thread.
      Type Parameters:
      T - stage value type
      Parameters:
      stage - input stage
      Returns:
      a stage completed (both exceptionally and normally) by this Filter Dispatch Thread