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 Detail

      • NONE

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

      • 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()