Interface BlockingExecutor

All Superinterfaces:
AutoCloseable, Executor, Registration

public interface BlockingExecutor extends Executor, Registration
Allows safe invocation of tasks that require resources not otherwise available after Registration.close() to block a service from stopping.
Author:
Paul Ferraro
  • Field Summary

    Fields inherited from interface org.wildfly.clustering.server.Registration

    EMPTY
  • Method Summary

    Modifier and Type
    Method
    Description
    <R> Optional<R>
    execute(Supplier<R> executeTask)
    Executes the specified task, but only if the service was not already closed.
    <E extends Exception>
    void
    execute(org.wildfly.common.function.ExceptionRunnable<E> runner)
    Executes the specified runner, but only if the executor was not already closed.
    <R, E extends Exception>
    Optional<R>
    execute(org.wildfly.common.function.ExceptionSupplier<R,E> executeTask)
    Executes the specified task, but only if the service was not already closed.
    newInstance(Runnable closeTask)
    Creates new blocking executor that runs the specified task upon Registration.close().

    Methods inherited from interface java.util.concurrent.Executor

    execute

    Methods inherited from interface org.wildfly.clustering.server.Registration

    close
  • Method Details

    • execute

      <E extends Exception> void execute(org.wildfly.common.function.ExceptionRunnable<E> runner) throws E
      Executes the specified runner, but only if the executor was not already closed.
      Type Parameters:
      E - the exception type
      Parameters:
      runner - a runnable task
      Throws:
      E - if execution fails
    • execute

      <R> Optional<R> execute(Supplier<R> executeTask)
      Executes the specified task, but only if the service was not already closed. If service is already closed, the task is not run. If executed, the specified task must return a non-null value, to be distinguishable from a non-execution.
      Parameters:
      executeTask - a task to execute
      Returns:
      an optional value that is present only if the specified task was run.
    • execute

      <R, E extends Exception> Optional<R> execute(org.wildfly.common.function.ExceptionSupplier<R,E> executeTask) throws E
      Executes the specified task, but only if the service was not already closed. If service is already closed, the task is not run. If executed, the specified task must return a non-null value, to be distinguishable from a non-execution.
      Parameters:
      executeTask - a task to execute
      Returns:
      an optional value that is present only if the specified task was run.
      Throws:
      E - if the task execution failed
    • newInstance

      static BlockingExecutor newInstance(Runnable closeTask)
      Creates new blocking executor that runs the specified task upon Registration.close(). The specified task will only execute once, upon the first Registration.close() invocation.
      Parameters:
      closeTask - a task to run when this executor is closed.
      Returns:
      a new blocking executor