Interface Dispatcher

All Known Implementing Classes:
SwingDispatcher

public interface Dispatcher

Resolves the platform's UI thread, for running ProgressWorker handlers and for determining whether a model refresh should run asynchronously.

The implementation is provided via ServiceLoader, defaulting to SYNCHRONOUS same-thread dispatch when no implementation is available.

See Also:
  • Field Details

    • SYNCHRONOUS

      static final Dispatcher SYNCHRONOUS
      A synchronous Dispatcher, running tasks on the calling thread and reporting no UI thread.

      Used when no implementation is available, and useful for testing.

  • Method Details

    • executor

      Executor executor()

      Returns an Executor running tasks on the UI thread, resolved for the current context.

      Called when a ProgressWorker is executed, on the UI thread, so that context sensitive implementations, such as web frameworks providing a per-session UI thread, can bind to the current context.

      Returns:
      an Executor running tasks on the UI thread
    • isUserInterfaceThread

      boolean isUserInterfaceThread()
      Returns:
      true if the calling thread is the UI thread
    • instance

      static Dispatcher instance()
      Returns the Dispatcher implementation, as provided via ServiceLoader, or SYNCHRONOUS in case no implementation is available.
      Returns:
      the Dispatcher implementation to use