Package org.eclipse.jetty.io
Class CyclicTimeout
- java.lang.Object
-
- org.eclipse.jetty.io.CyclicTimeout
-
- All Implemented Interfaces:
org.eclipse.jetty.util.component.Destroyable
public abstract class CyclicTimeout extends java.lang.Object implements org.eclipse.jetty.util.component.DestroyableAn 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 booleancancel()Cancels this CyclicTimeout so that it won't expire.voiddestroy()Destroys this CyclicTimeout.org.eclipse.jetty.util.thread.SchedulergetScheduler()abstract voidonTimeoutExpired()Invoked when the timeout expires.booleanschedule(long delay, java.util.concurrent.TimeUnit units)Schedules a timeout, even if already set, cancelled or expired.
-
-
-
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:
destroyin interfaceorg.eclipse.jetty.util.component.Destroyable
-
-