Class ProgressTask

    • Constructor Summary

      Constructors 
      Constructor Description
      ProgressTask​(Process process, Map<String,​Object> input)
      Creates a ProgressTask that will execute the given Process when run.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean cancel​(boolean mayInterruptIfRunning)  
      protected void done()
      This protected method is invoked when this process transitions to state isDone (whether normally or via cancellation).
      Map<String,​Object> get()  
      Map<String,​Object> get​(long timeout, TimeUnit unit)  
      float getProgress()
      Amount of work completed.
      boolean isCancelled()  
      boolean isDone()  
      void run()
      Sets this ProgressTask to the result of the computation unless it has been canceled.
      protected boolean runAndReset()
      Executes the process without setting its result, and then resets this ProgressTask to its initial state, failing to do so if the computation encounters an exception or is canceled.
      protected void set​(Map<String,​Object> value)
      Sets the result of this ProgressTask to the given value unless this ProgressTask has already been set or has been canceled.
      protected void setException​(Throwable t)
      Causes this ProgressTask to report an ExecutionException with the given throwable as its cause, unless this ProgressTask has already been set or has been canceled.
    • Constructor Detail

      • ProgressTask

        public ProgressTask​(Process process,
                            Map<String,​Object> input)
        Creates a ProgressTask that will execute the given Process when run.
        Parameters:
        process - the process to execute
        input - the inputs to use when executing the process
        Throws:
        NullPointerException - if process is null
    • Method Detail

      • getProgress

        public float getProgress()
        Description copied from interface: Progress
        Amount of work completed.
        Specified by:
        getProgress in interface Progress
        Returns:
        Percent completed, or WORKING if amount of work is unknown.
      • done

        protected void done()
        This protected method is invoked when this process transitions to state isDone (whether normally or via cancellation). The default implementation does nothing. Subclasses may override this method to invoke completion callbacks. You can query status inside the implementation of this method to determine whether this task has been canceled.
      • set

        protected void set​(Map<String,​Object> value)
        Sets the result of this ProgressTask to the given value unless this ProgressTask has already been set or has been canceled.
        Parameters:
        value - the value to set
      • setException

        protected void setException​(Throwable t)
        Causes this ProgressTask to report an ExecutionException with the given throwable as its cause, unless this ProgressTask has already been set or has been canceled.
        Parameters:
        t - the cause of failure.
      • run

        public void run()
        Sets this ProgressTask to the result of the computation unless it has been canceled.
        Specified by:
        run in interface Runnable
      • runAndReset

        protected boolean runAndReset()
        Executes the process without setting its result, and then resets this ProgressTask to its initial state, failing to do so if the computation encounters an exception or is canceled. This is designed for use with processes that execute more than once.
        Returns:
        true if successfully run and reset