Class TaskNotifyingExecutor

java.lang.Object
com.apple.foundationdb.async.TaskNotifyingExecutor
All Implemented Interfaces:
Executor

@API(EXPERIMENTAL) public abstract class TaskNotifyingExecutor extends Object implements Executor
An executor that can perform pre- and post- work in the context of the thread executing a task. A typical use for this executor is to perform actions such as setting up and tearing down thread local variables that need to be present for code that is executed within the tasks.
  • Field Details

    • delegate

      @Nonnull protected final Executor delegate
  • Constructor Details

    • TaskNotifyingExecutor

      public TaskNotifyingExecutor(@Nonnull Executor executor)
  • Method Details

    • execute

      public void execute(Runnable task)
      Specified by:
      execute in interface Executor
    • beforeTask

      public abstract void beforeTask()
      Called in the context of an executor thread, immediately prior to actually executing a task. Exceptions thrown from this method will prevent the execution of the task itself, however the afterTask() will still be executed.
    • afterTask

      public abstract void afterTask()
      Called in the context of an executor thread, immediately after a task has completed execution (either successfully or with error). Exceptions thrown from this will cause the task to be treated as a failure and will mask any exception that the task may have produced.