Package com.iizix.timeout
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 TypeMethodDescriptionvoid
dispose()
Disposes of the engine and disposes of all pending scheduled timers and timeouts.boolean
Checks if engine is disposed or not.registerTimeout
(long timeout, String description, ITimeoutListener listener) Registers a new timeout for processing.
Method Details
registerTimeout
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 thelistener
isnull
.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.