Class IdleExecutor

java.lang.Object
se.datadosen.util.IdleExecutor

public class IdleExecutor
extends java.lang.Object
Executor that executes task when it has been idle for specified amount of time, i.e. when specified amount of time has passed since the last onIdle call. Each onIdle call resets the countdown timer.
Since:
17.1
  • Constructor Summary

    Constructors 
    Constructor Description
    IdleExecutor​(int delayMillis, java.util.concurrent.TimeUnit delayUnit)  
  • Method Summary

    Modifier and Type Method Description
    void cancel()
    Cancel countdown timer so no scheduled task is executed.
    void cancel​(boolean interrupt)  
    java.util.concurrent.ScheduledFuture getFuture()  
    boolean isCancelled()  
    java.util.concurrent.Future onIdle​(java.lang.Runnable r)
    Schedule task for execution after specified delay.

    Methods inherited from class java.lang.Object

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

    • IdleExecutor

      public IdleExecutor​(int delayMillis, java.util.concurrent.TimeUnit delayUnit)
  • Method Details

    • getFuture

      public java.util.concurrent.ScheduledFuture getFuture()
      Returns:
      Scheduled task. Null if no scheduled task
    • cancel

      public void cancel()
      Cancel countdown timer so no scheduled task is executed. Does not try to interrupt already started scheduled task
    • cancel

      public void cancel​(boolean interrupt)
    • isCancelled

      public boolean isCancelled()
    • onIdle

      public java.util.concurrent.Future onIdle​(java.lang.Runnable r)
      Schedule task for execution after specified delay. Interrupts any already scheduled task
      Parameters:
      r -
      Returns: