Interface ContextHandler<T>

Type Parameters:
T - the class of the context to capture

public interface ContextHandler<T>
A handler for propagating context from a task submitter to a task execution.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final ContextHandler<?>
    The context handler which captures no context.
  • Method Summary

    Modifier and Type
    Method
    Description
    Capture the current context from the submitting thread.
    void
    runWith(Runnable task, T context)
    Run the given task with the given captured context.
  • Field Details

    • NONE

      static final ContextHandler<?> NONE
      The context handler which captures no context.
  • Method Details

    • captureContext

      T captureContext()
      Capture the current context from the submitting thread.
      Returns:
      the captured context
    • runWith

      void runWith(Runnable task, T context)
      Run the given task with the given captured context. The context should be cleared when this method returns.
      Parameters:
      task - the task to run (not null)
      context - the context returned from captureContext()