Package org.cache2k.core.timing
Interface TimerStructure
-
- All Known Implementing Classes:
TimerWheels
public interface TimerStructureInterface of the timer task data structure.The interface allows different implementations for timer data structures, like tree, heap oder timer wheels. The interface is not 100% abstracted, since the implementation makes use of TimerTask internals (prev and next pointers).
The timer data structure is not supposed to be thread safe, it is called with proper locking from the timer code.
- Author:
- Jens Wilke
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidcancelAll()Cancel all tasksvoidcancelAll(TimerTask t)Cancel this timer tasklongnextRun()Time of next run, or -1 if no more tasks are scheduledTimerTaskremoveNextToRun(long time)Return a task that is supposed to execute at the given time or earlier.booleanschedule(TimerTask task, long time)Insert task.
-
-
-
Method Detail
-
schedule
boolean schedule(TimerTask task, long time)
Insert task. Scheduling might be not possible if tasks for the requested time have already be run.- Returns:
- true if scheduled successfully, false if scheduling was not possible because the target time slot would be in the past
-
cancelAll
void cancelAll(TimerTask t)
Cancel this timer task
-
cancelAll
void cancelAll()
Cancel all tasks
-
removeNextToRun
TimerTask removeNextToRun(long time)
Return a task that is supposed to execute at the given time or earlier. This also moves the clock hand of the timer structure.It may rarely happen that a subsequent method call has an earlier time, in case the operating system schedule delays a thread until the next scheduler event happens.
- Returns:
- a task or null, if no more tasks are scheduled for the given time
-
nextRun
long nextRun()
Time of next run, or -1 if no more tasks are scheduled
-
-