Class TimeoutProcessor
java.lang.Object
com.linkedin.alpini.base.concurrency.TimeoutProcessor
- All Implemented Interfaces:
Executor
More efficient handling of cancellable schedulable events. The default ScheduledExecutorService is
designed to handle schedulable tasks where cancellation is rare. However, for the purposes of handling
timeouts, we would prefer cancellation to be the common case and the tasks should be rarely run.
- See Also:
-
Nested Class Summary
-
Constructor Summary
ConstructorDescriptionTimeoutProcessor
(ResourceRegistry registry) TimeoutProcessor
(ResourceRegistry registry, boolean useTreeMap, int executorThreadCount) TimeoutProcessor
(ResourceRegistry registry, long tickingInterval, boolean useTreeMap, int executorThreadCount) -
Method Summary
Modifier and TypeMethodDescriptionvoid
awaitTermination
(int timeout, TimeUnit unit) void
Schedule a timeout event to occur after the specified delayvoid
toString()
-
Constructor Details
-
TimeoutProcessor
public TimeoutProcessor() -
TimeoutProcessor
-
TimeoutProcessor
-
TimeoutProcessor
public TimeoutProcessor(ResourceRegistry registry, long tickingInterval, boolean useTreeMap, int executorThreadCount)
-
-
Method Details
-
toString
-
schedule
Schedule a timeout event to occur after the specified delay- Parameters:
task
- Runnable event.delay
- delay time.unit
- unit of time delay.- Returns:
- Cancellable TimeoutFuture.
- See Also:
-
shutdownNow
public void shutdownNow()- See Also:
-
awaitTermination
- Parameters:
timeout
- the maximum time to waitunit
- the time unit of the timeout argument- Throws:
InterruptedException
- if interrupted while waiting- See Also:
-
execute
-