Class DefaultTimer

  • All Implemented Interfaces:
    NeedsClose, Timer

    public class DefaultTimer
    extends Object
    implements Timer
    Standard timer implementation. Due timer tasks are executed via a scheduler that runs at most every second (lag time, configurable). There is always only one pending scheduler job per timer.
    Author:
    Jens Wilke
    • Constructor Detail

      • DefaultTimer

        public DefaultTimer​(org.cache2k.operation.TimeReference clock,
                            org.cache2k.operation.Scheduler scheduler,
                            long lagMillis)
      • DefaultTimer

        public DefaultTimer​(org.cache2k.operation.TimeReference c,
                            org.cache2k.operation.Scheduler scheduler,
                            long lagMillis,
                            int steps)
    • Method Detail

      • schedule

        public void schedule​(TimerTask task,
                             long time)
        Schedule the specified timer task for execution at the specified time, in milliseconds.
        Specified by:
        schedule in interface Timer
        time - the time when the task should be run. must be positive or 0.
      • cancel

        public void cancel​(TimerTask t)
        Description copied from interface: Timer
        Cancel the timer task.
        Specified by:
        cancel in interface Timer
      • getLagMillis

        public long getLagMillis()
        Lag to gather timer tasks processing. In milliseconds.
        Specified by:
        getLagMillis in interface Timer
      • cancelAll

        public void cancelAll()
        Terminates all timer tasks current pending.
        Specified by:
        cancelAll in interface Timer