Class ActionTimeoutHelper

java.lang.Object
com.kingsrook.qqq.backend.core.actions.tables.helpers.ActionTimeoutHelper

public class ActionTimeoutHelper extends Object
For actions that may want to set a timeout, and cancel themselves if they run too long - this class helps. Construct with the timeout (delay invalid input: '&' timeUnit), and a runnable that takes care of doing the cancel (e.g., cancelling a JDBC statement). Call start() to make a future get scheduled (note, if delay was null or invalid input: '<'= 0, then it doesn't get scheduled at all). Call cancel() if the action got far enough/completed, to cancel the future. You can check didTimeout (getDidTimeout()) to know if the timeout did occur.
  • Constructor Details

    • ActionTimeoutHelper

      public ActionTimeoutHelper(Integer delay, TimeUnit timeUnit, Runnable runnable)
      Constructor
  • Method Details

    • start

      public void start()
    • cancel

      public void cancel()
    • getDidTimeout

      public boolean getDidTimeout()
      Getter for didTimeout