Class TimeoutProcessor
- java.lang.Object
-
- com.linkedin.alpini.base.concurrency.TimeoutProcessor
-
- All Implemented Interfaces:
java.util.concurrent.Executor
public class TimeoutProcessor extends java.lang.Object implements java.util.concurrent.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:
ScheduledExecutorService
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
TimeoutProcessor.TimeoutFuture
-
Constructor Summary
Constructors Constructor Description TimeoutProcessor()
TimeoutProcessor(ResourceRegistry registry)
TimeoutProcessor(ResourceRegistry registry, boolean useTreeMap, int executorThreadCount)
TimeoutProcessor(ResourceRegistry registry, long tickingInterval, boolean useTreeMap, int executorThreadCount)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
awaitTermination(int timeout, java.util.concurrent.TimeUnit unit)
void
execute(java.lang.Runnable command)
TimeoutProcessor.TimeoutFuture
schedule(java.lang.Runnable task, long delay, java.util.concurrent.TimeUnit unit)
Schedule a timeout event to occur after the specified delayvoid
shutdownNow()
java.lang.String
toString()
-
-
-
Constructor Detail
-
TimeoutProcessor
public TimeoutProcessor()
-
TimeoutProcessor
public TimeoutProcessor(ResourceRegistry registry)
-
TimeoutProcessor
public TimeoutProcessor(ResourceRegistry registry, boolean useTreeMap, int executorThreadCount)
-
TimeoutProcessor
public TimeoutProcessor(ResourceRegistry registry, long tickingInterval, boolean useTreeMap, int executorThreadCount)
-
-
Method Detail
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
schedule
public TimeoutProcessor.TimeoutFuture schedule(java.lang.Runnable task, long delay, java.util.concurrent.TimeUnit unit)
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:
ScheduledExecutorService.schedule(Runnable, long, java.util.concurrent.TimeUnit)
-
shutdownNow
public void shutdownNow()
- See Also:
ExecutorService.shutdownNow()
-
awaitTermination
public void awaitTermination(int timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
- Parameters:
timeout
- the maximum time to waitunit
- the time unit of the timeout argument- Throws:
java.lang.InterruptedException
- if interrupted while waiting- See Also:
ExecutorService.awaitTermination(long, java.util.concurrent.TimeUnit)
-
execute
public void execute(java.lang.Runnable command)
- Specified by:
execute
in interfacejava.util.concurrent.Executor
-
-