Class Progress


  • public final class Progress
    extends Object
    A static utility class serving as the interface between progress reporters and progress listeners.
    Author:
    Gabriel Selzer
    • Method Detail

      • addGlobalListener

        public static void addGlobalListener​(Consumer<Task> l)
        Invokes the given Consumer as a callback for all progressible Objects.
        Parameters:
        l - a Consumer that would like to know about the progress of progressible Objects
      • addListener

        public static void addListener​(Object progressible,
                                       Consumer<Task> l)
        Invokes the given Consumer as a callback for the specified progressible Object.
        Parameters:
        progressible - an Object that reports its progress
        l - a Consumer that would like to know about the progress of progressible
      • complete

        public static void complete()
        Completes the current task on this Thread's execution hierarchy, removing it in the process. This method also takes care to ping relevant Consumers.
        See Also:
        Task.complete()
      • ignore

        public static void ignore()
        Adds a new NOP Task to the current execution chain, used to ignore Progress calls by a progressible object. This NOP task will handle all Progress calls on this Thread between the time this method is invoked and the time when complete() is called.
      • register

        public static void register​(Object progressible)
        Creates a new Task for progressible. This method makes the assumption that progressible is responsible for any calls to Progress' progress-reporting API between the time this method is called and the time when complete() is called.
        Parameters:
        progressible - an Object that would like to report its progress.
      • register

        public static void register​(Object progressible,
                                    String description)
        Creates a new Task for progressible. This method makes the assumption that progressible is responsible for any calls to Progress' progress-reporting API between the time this method is called and the time when complete() is called.
        Parameters:
        progressible - an Object that would like to report its progress.
        description - a String describing progressible
      • currentTask

        public static Task currentTask()
        Returns the currently-executing Task on this Thread
        Returns:
        the currently-execution Task
      • update

        public static void update​(long elements)
        Updates the progress of the current Task, pinging any interested Consumers.
        Parameters:
        elements - the number of elements completed in the current stage.
        See Also:
        Task.update(long)
      • update

        public static void update​(long numElements,
                                  Task task)
        Updates the progress of the provided Task, pinging any interested Consumers.
        Parameters:
        numElements - the number of elements completed in the current stage.
        task - the Task to update
        See Also:
        Task.update(long)
      • defineTotal

        public static void defineTotal​(long elements)
        Defines the total progress of the current Task
        Parameters:
        elements - the number of discrete packets of computation.
        See Also:
        Task.defineTotal(long)
      • defineTotal

        public static void defineTotal​(long elements,
                                       long subTasks)
        Defines the total progress of the current Task
        Parameters:
        elements - the number of discrete packets of computation.
        subTasks - the number of times subtasks are called upon within the task. This is not the same as the number of subtasks used (as one subtask may run multiple times).
        See Also:
        Task.defineTotal(long, long)