org.ros.concurrent
Class RetryingExecutorService

java.lang.Object
  extended by org.ros.concurrent.RetryingExecutorService

public class RetryingExecutorService
extends java.lang.Object

Wraps an ScheduledExecutorService to execute Callables with retries.


Constructor Summary
RetryingExecutorService(java.util.concurrent.ScheduledExecutorService executorService)
           
 
Method Summary
 void setRetryDelay(long delay, java.util.concurrent.TimeUnit unit)
           
 void shutdown(long timeout, java.util.concurrent.TimeUnit unit)
          Stops accepting new Callables and waits for all submitted Callables to finish within the specified timeout.
 void submit(java.util.concurrent.Callable<java.lang.Boolean> callable)
          Submit a new Callable to be executed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RetryingExecutorService

public RetryingExecutorService(java.util.concurrent.ScheduledExecutorService executorService)
Parameters:
executorService - the ExecutorService to wrap
Method Detail

submit

public void submit(java.util.concurrent.Callable<java.lang.Boolean> callable)
Submit a new Callable to be executed. The submitted Callable should return true to be retried, false otherwise.

Parameters:
callable - the Callable to execute
Throws:
java.util.concurrent.RejectedExecutionException - if the RetryingExecutorService is shutting down

setRetryDelay

public void setRetryDelay(long delay,
                          java.util.concurrent.TimeUnit unit)
Parameters:
delay - the delay in units of unit
unit - the TimeUnit of the delay

shutdown

public void shutdown(long timeout,
                     java.util.concurrent.TimeUnit unit)
              throws java.lang.InterruptedException
Stops accepting new Callables and waits for all submitted Callables to finish within the specified timeout.

Parameters:
timeout - the timeout in units of unit
unit - the TimeUnit of timeout
Throws:
java.lang.InterruptedException