Class TransferRateProgressReporter

    • Field Detail

      • maxTicksPerSecond

        private final int maxTicksPerSecond
      • maxDelay

        private final int maxDelay
      • startTime

        private long startTime
    • Constructor Detail

      • TransferRateProgressReporter

        public TransferRateProgressReporter​(AbsoluteProgressReporter parent,
                                            int maxTicksPerSecond)
        Create a new progress reporter. Max delay per progress update is 8 seconds.
        Parameters:
        parent - An optional parent progress reporter
        maxTicksPerSecond - Max allowed ticks-per-second, if the rate goes above this, the displayAbsolute(long, String) method will wait a short time before returning
      • TransferRateProgressReporter

        public TransferRateProgressReporter​(AbsoluteProgressReporter parent,
                                            int maxTicksPerSecond,
                                            int maxDelay)
        Create a new progress reporter. Max delay per progress update is 8 seconds.
        Parameters:
        parent - An optional parent progress reporter
        maxTicksPerSecond - Max allowed ticks-per-second, if the rate goes above this, the displayAbsolute(long, String) method will wait a short time before returning
        maxDelay - The max delay in milliseconds for each call to displayAbsolute(long, String)
    • Method Detail

      • display

        public void display​(int percent,
                            String message)
        Forward the call to the parent if one exists. There is no rate control in this method.
        Specified by:
        display in interface ProgressReporter
        Parameters:
        percent - How many percent of the task that is completed or -1 if not known
        message - A message, or null
      • append

        public void append​(String message)
        Forward the call to the parent if one exists.
        Specified by:
        append in interface ProgressReporter
        Parameters:
        message - The message
      • displayAbsolute

        public void displayAbsolute​(long completed,
                                    String message)
        Forward the call to the parent if one exists. Then check the number of completed ticks and time since start against the max transfer rate. If the max rate has been exceeded pause the thread for a while.
        Specified by:
        displayAbsolute in interface AbsoluteProgressReporter
        Parameters:
        completed - The progress of the task
        message - A message, or null