Package org.onlab.util
Class SharedScheduledExecutorService
- java.lang.Object
-
- org.onlab.util.SharedScheduledExecutorService
-
- All Implemented Interfaces:
Executor,ExecutorService,ScheduledExecutorService
public class SharedScheduledExecutorService extends Object implements ScheduledExecutorService
A new scheduled executor service that does not eat exception.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanawaitTermination(long timeout, TimeUnit unit)voidexecute(Runnable command)<T> List<Future<T>>invokeAll(Collection<? extends Callable<T>> tasks)<T> List<Future<T>>invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit)<T> TinvokeAny(Collection<? extends Callable<T>> tasks)<T> TinvokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit)booleanisShutdown()booleanisTerminated()ScheduledFuture<?>schedule(Runnable command, long delay, TimeUnit unit)ScheduledFuture<?>schedule(Runnable command, long delay, TimeUnit unit, boolean repeatFlag)Creates and executes a one-shot action that becomes enabled after the given delay.<V> ScheduledFuture<V>schedule(Callable<V> callable, long delay, TimeUnit unit)ScheduledFuture<?>scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit)ScheduledFuture<?>scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit, boolean repeatFlag)Creates and executes a periodic action that becomes enabled first after the given initial delay, and subsequently with the given period; that is executions will commence afterinitialDelaytheninitialDelay+period, theninitialDelay + 2 * period, and so on.ScheduledFuture<?>scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit)ScheduledFuture<?>scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit, boolean repeatFlag)Creates and executes a periodic action that becomes enabled first after the given initial delay, and subsequently with the given delay between the termination of one execution and the commencement of the next.voidshutdown()List<Runnable>shutdownNow()Future<?>submit(Runnable task)<T> Future<T>submit(Runnable task, T result)<T> Future<T>submit(Callable<T> task)
-
-
-
Method Detail
-
schedule
public ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit, boolean repeatFlag)
Creates and executes a one-shot action that becomes enabled after the given delay.- Parameters:
command- the task to executedelay- the time from now to delay executionunit- the time unit of the delay parameterrepeatFlag- the flag to denote whether to restart a failed task- Returns:
- a ScheduledFuture representing pending completion of
the task and whose
get()method will returnnullupon completion
-
schedule
public ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit)
- Specified by:
schedulein interfaceScheduledExecutorService
-
schedule
public <V> ScheduledFuture<V> schedule(Callable<V> callable, long delay, TimeUnit unit)
- Specified by:
schedulein interfaceScheduledExecutorService
-
scheduleAtFixedRate
public ScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit, boolean repeatFlag)
Creates and executes a periodic action that becomes enabled first after the given initial delay, and subsequently with the given period; that is executions will commence afterinitialDelaytheninitialDelay+period, theninitialDelay + 2 * period, and so on. Depends on the repeat flag that the user set, the failed tasks can be either restarted or terminated. If the repeat flag is set to to true, ant execution of the task encounters an exception, subsequent executions are permitted, otherwise, subsequent executions are suppressed. If any execution of this task takes longer than its period, then subsequent executions may start late, but will not concurrently execute.- Parameters:
command- the task to executeinitialDelay- the time to delay first executionperiod- the period between successive executionsunit- the time unit of the initialDelay and period parametersrepeatFlag- the flag to denote whether to restart a failed task- Returns:
- a ScheduledFuture representing pending completion of
the task, and whose
get()method will throw an exception upon cancellation
-
scheduleAtFixedRate
public ScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit)
- Specified by:
scheduleAtFixedRatein interfaceScheduledExecutorService
-
scheduleWithFixedDelay
public ScheduledFuture<?> scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit, boolean repeatFlag)
Creates and executes a periodic action that becomes enabled first after the given initial delay, and subsequently with the given delay between the termination of one execution and the commencement of the next. Depends on the repeat flag that the user set, the failed tasks can be either restarted or terminated. If the repeat flag is set to to true, ant execution of the task encounters an exception, subsequent executions are permitted, otherwise, subsequent executions are suppressed.- Parameters:
command- the task to executeinitialDelay- the time to delay first executiondelay- the delay between the termination of one execution and the commencement of the nextunit- the time unit of the initialDelay and delay parametersrepeatFlag- the flag to denote whether to restart a failed task- Returns:
- a ScheduledFuture representing pending completion of
the task, and whose
get()method will throw an exception upon cancellation
-
scheduleWithFixedDelay
public ScheduledFuture<?> scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit)
- Specified by:
scheduleWithFixedDelayin interfaceScheduledExecutorService
-
shutdown
public void shutdown()
- Specified by:
shutdownin interfaceExecutorService
-
shutdownNow
public List<Runnable> shutdownNow()
- Specified by:
shutdownNowin interfaceExecutorService
-
isShutdown
public boolean isShutdown()
- Specified by:
isShutdownin interfaceExecutorService
-
isTerminated
public boolean isTerminated()
- Specified by:
isTerminatedin interfaceExecutorService
-
awaitTermination
public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException- Specified by:
awaitTerminationin interfaceExecutorService- Throws:
InterruptedException
-
submit
public <T> Future<T> submit(Callable<T> task)
- Specified by:
submitin interfaceExecutorService
-
submit
public <T> Future<T> submit(Runnable task, T result)
- Specified by:
submitin interfaceExecutorService
-
submit
public Future<?> submit(Runnable task)
- Specified by:
submitin interfaceExecutorService
-
invokeAll
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks) throws InterruptedException
- Specified by:
invokeAllin interfaceExecutorService- Throws:
InterruptedException
-
invokeAll
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException
- Specified by:
invokeAllin interfaceExecutorService- Throws:
InterruptedException
-
invokeAny
public <T> T invokeAny(Collection<? extends Callable<T>> tasks) throws InterruptedException, ExecutionException
- Specified by:
invokeAnyin interfaceExecutorService- Throws:
InterruptedExceptionExecutionException
-
invokeAny
public <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
- Specified by:
invokeAnyin interfaceExecutorService- Throws:
InterruptedExceptionExecutionExceptionTimeoutException
-
-