Interface ITimerEngine


public interface ITimerEngine
The timer engine handles timeouts and scheduled events.

It can be used to register a timeout for a task that runs in a thread. When timeout is reached, the method ITimeoutListener.onTimeout() is called from another thread, informing the running thread of this timeout. It is up to the running thread to take appropriate action.

It can also handle a scheduled periodic event notification that also runs in a thread.

Author:
Christopher Mindus
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Disposes of the engine and disposes of all pending scheduled timers and timeouts.
    long
    Gets the unique timer engine ID.
    boolean
    Checks if engine is disposed or not.
    registerTimeout(long timeout, String description, ITimeoutListener listener)
    Registers a new timeout for processing.
  • Method Details

    • getID

      long getID()
      Gets the unique timer engine ID.
      Returns:
      A unique timer engine ID: the system engine has ID = 0L.
    • registerTimeout

      ITimeoutTask registerTimeout(long timeout, String description, ITimeoutListener listener)
      Registers a new timeout for processing.
      Parameters:
      timeout - The timeout in milliseconds, -1 for indefinite.
      description - The description of the timeout operation, null for none.
      listener - The listener for timeout notification.
      Throws:
      NullPointerException - If the listener is null.
      IllegalStateException - If the engine has been disposed of.
    • dispose

      void dispose()
      Disposes of the engine and disposes of all pending scheduled timers and timeouts.
    • isDisposed

      boolean isDisposed()
      Checks if engine is disposed or not.
      Returns:
      true if disposed, false otherwise.