Class CyclicTimeout

  • All Implemented Interfaces:
    org.eclipse.jetty.util.component.Destroyable

    public abstract class CyclicTimeout
    extends java.lang.Object
    implements org.eclipse.jetty.util.component.Destroyable

    An abstract implementation of a timeout.

    Subclasses should implement onTimeoutExpired().

    This implementation is optimised assuming that the timeout will mostly be cancelled and then reused with a similar value.

    • Constructor Summary

      Constructors 
      Constructor Description
      CyclicTimeout​(org.eclipse.jetty.util.thread.Scheduler scheduler)  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      boolean cancel()
      Cancels this CyclicTimeout so that it won't expire.
      void destroy()
      Destroys this CyclicTimeout.
      org.eclipse.jetty.util.thread.Scheduler getScheduler()  
      abstract void onTimeoutExpired()
      Invoked when the timeout expires.
      boolean schedule​(long delay, java.util.concurrent.TimeUnit units)
      Schedules a timeout, even if already set, cancelled or expired.
      • Methods inherited from class java.lang.Object

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

      • CyclicTimeout

        public CyclicTimeout​(org.eclipse.jetty.util.thread.Scheduler scheduler)
        Parameters:
        scheduler - A scheduler used to schedule wakeups
    • Method Detail

      • getScheduler

        public org.eclipse.jetty.util.thread.Scheduler getScheduler()
      • schedule

        public boolean schedule​(long delay,
                                java.util.concurrent.TimeUnit units)
        Schedules a timeout, even if already set, cancelled or expired.
        Parameters:
        delay - The period of time before the timeout expires.
        units - The unit of time of the period.
        Returns:
        true if the timer was already set.
      • cancel

        public boolean cancel()

        Cancels this CyclicTimeout so that it won't expire.

        After being cancelled, this CyclicTimeout can be scheduled again.

        Returns:
        true if this CyclicTimeout was scheduled to expire
        See Also:
        destroy()
      • onTimeoutExpired

        public abstract void onTimeoutExpired()

        Invoked when the timeout expires.

      • destroy

        public void destroy()

        Destroys this CyclicTimeout.

        After being destroyed, this CyclicTimeout is not used anymore.

        Specified by:
        destroy in interface org.eclipse.jetty.util.component.Destroyable