Interface Progress


public interface Progress
The only handle a background body has on the outside world while it runs: it can ask whether it has been cancelled, and it can say how far it has got.

Both methods are called from the worker thread running the body. Neither touches widget or scene state, and neither blocks; report(double) hands the value over and returns.

  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Whether the job has been cancelled.
    void
    report(double fraction)
    Reports how much of the work is finished, as a fraction of the whole.
  • Method Details

    • isCancelled

      boolean isCancelled()
      Whether the job has been cancelled.

      Cancellation is cooperative: nothing interrupts the worker thread and no exception is thrown into the body. A body that never asks runs to completion, and its result is then discarded instead of delivered. Ask between units of work (per block read, per row parsed) and return early when this answers true; returning early is not an error and whatever is returned is treated as an undeliverable result.

      Returns:
      true once cancellation has been requested
    • report

      void report(double fraction)
      Reports how much of the work is finished, as a fraction of the whole.

      Delivery is coalesced: at most one report is in flight to the UI thread at a time, and the one that arrives carries the newest value reported, so intermediate values are skipped when reports outrun frames. Values arrive in the order they were reported, and the last value reported before the body returns is always delivered, ahead of the success callback. Calling this allocates nothing, so a tight loop may report per iteration.

      Parameters:
      fraction - 0 to 1 inclusive; values outside that range are clamped and NaN is reported as 0