Interface TimerService<K>

Type Parameters:
K - Type of the key
All Known Implementing Classes:
DefaultTimerService

public interface TimerService<K>
Service to register timeouts for a given key. The timeouts are identified by a ticket so that newly registered timeouts for the same key can be distinguished from older timeouts.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    isValid(K key, UUID ticket)
    Check whether the timeout for the given key and ticket is still valid (not yet unregistered and not yet overwritten).
    void
    registerTimeout(K key, long delay, TimeUnit unit)
    Register a timeout for the given key which shall occur in the given delay.
    void
    start(TimeoutListener<K> timeoutListener)
    Starts this timer service.
    void
    Stops this timer service.
    void
    Unregister the timeout for the given key.
  • Method Details

    • start

      void start(TimeoutListener<K> timeoutListener)
      Starts this timer service.
      Parameters:
      timeoutListener - listener for timeouts that have fired
    • stop

      void stop()
      Stops this timer service.
    • registerTimeout

      void registerTimeout(K key, long delay, TimeUnit unit)
      Register a timeout for the given key which shall occur in the given delay.
      Parameters:
      key - for which to register the timeout
      delay - until the timeout
      unit - of the timeout delay
    • unregisterTimeout

      void unregisterTimeout(K key)
      Unregister the timeout for the given key.
      Parameters:
      key - for which to unregister the timeout
    • isValid

      boolean isValid(K key, UUID ticket)
      Check whether the timeout for the given key and ticket is still valid (not yet unregistered and not yet overwritten).
      Parameters:
      key - for which to check the timeout
      ticket - of the timeout
      Returns:
      True if the timeout ticket is still valid; otherwise false