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 TypeMethodDescriptionbooleanCheck whether the timeout for the given key and ticket is still valid (not yet unregistered and not yet overwritten).voidregisterTimeout(K key, long delay, TimeUnit unit) Register a timeout for the given key which shall occur in the given delay.voidstart(TimeoutListener<K> timeoutListener) Starts this timer service.voidstop()Stops this timer service.voidunregisterTimeout(K key) Unregister the timeout for the given key.
-
Method Details
-
start
Starts this timer service.- Parameters:
timeoutListener- listener for timeouts that have fired
-
stop
void stop()Stops this timer service. -
registerTimeout
Register a timeout for the given key which shall occur in the given delay.- Parameters:
key- for which to register the timeoutdelay- until the timeoutunit- of the timeout delay
-
unregisterTimeout
Unregister the timeout for the given key.- Parameters:
key- for which to unregister the timeout
-
isValid
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 timeoutticket- of the timeout- Returns:
- True if the timeout ticket is still valid; otherwise false
-