Interface PhasedProgressObserver

All Superinterfaces:
AutoCloseable, CancelObserver

@PublicAPI public interface PhasedProgressObserver extends CancelObserver, AutoCloseable
Observer for reporting the progress of long-running tasks.

Design aspects of this progress observing facility:

  • The execution observed is divided into phases.
  • Each phase is started with a call to phase(String), which returns a progress observer that monitors the progress of the phase.
  • Observers are also used for cancellation reporting. Since it is a cross-cutting concern, it is exposed as a separate, but extended interface.

Thread-safety: implementations are not required to be thread-safe. Observed processes must be prepared for working with non-thread-safe observers. Consequently, observer methods can be called only on the thread that invoked the observed function. Alternatively, proper synchronization must be ensured by the observed code.

  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    Notifies that the represented task has completed (either successfully or because of a failure), and no further work will be done.
    Returns an observer that ignores progress report and cannot be cancelled.
    phase(String name)
    Called when a new phase is started, returns a progress observer that should be used in this phase.

    Methods inherited from interface com.chemaxon.calculations.common.CancelObserver

    isCancelled
  • Method Details

    • nullObserver

      static PhasedProgressObserver nullObserver()
      Returns an observer that ignores progress report and cannot be cancelled.
      Returns:
      a null observer
    • phase

      ProgressObserver phase(String name)
      Called when a new phase is started, returns a progress observer that should be used in this phase.
      Parameters:
      name - the name of the phase
      Returns:
      the observer that should be notified about the progress of the new phase
    • close

      default void close()
      Notifies that the represented task has completed (either successfully or because of a failure), and no further work will be done.

      Repeated calls to this method has no effect (idempotency).

      Specified by:
      close in interface AutoCloseable