Class Throttler


  • public class Throttler
    extends java.lang.Object
    A utility class that throttles the execution of a runnable in the UI thread.
    Since:
    3.14
    • Constructor Summary

      Constructors 
      Constructor Description
      Throttler​(Display display, java.time.Duration minWaitTime, java.lang.Runnable runnable)
      Initializes a new throttler object that will throttle the execution of the given runnable in the UI thread of the given display.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void throttledExec()
      Schedules the wrapped runnable to be run after the configured wait time or do nothing if it has already been scheduled but not executed yet.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Throttler

        public Throttler​(Display display,
                         java.time.Duration minWaitTime,
                         java.lang.Runnable runnable)
        Initializes a new throttler object that will throttle the execution of the given runnable in the UI thread of the given display. The throttler will ensure that the runnable will not run more than every minWaitTime, even if it is executed more often.
        Parameters:
        display - the display owning the thread onto which the runnable will be executed.
        minWaitTime - the minimum duration between each execution of the given runnable.
        runnable - the runnable to throttle.
    • Method Detail

      • throttledExec

        public void throttledExec()
        Schedules the wrapped runnable to be run after the configured wait time or do nothing if it has already been scheduled but not executed yet.