org.ros.concurrent
Class RetryingExecutorService
java.lang.Object
org.ros.concurrent.RetryingExecutorService
public class RetryingExecutorService
- extends java.lang.Object
Wraps an ScheduledExecutorService
to execute Callable
s with retries.
Method Summary |
void |
setRetryDelay(long delay,
java.util.concurrent.TimeUnit unit)
|
void |
shutdown(long timeout,
java.util.concurrent.TimeUnit unit)
Stops accepting new Callable s and waits for all submitted
Callable s 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 |
RetryingExecutorService
public RetryingExecutorService(java.util.concurrent.ScheduledExecutorService executorService)
- Parameters:
executorService
- the ExecutorService
to wrap
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
Callable
s and waits for all submitted
Callable
s to finish within the specified timeout.
- Parameters:
timeout
- the timeout in units of unit
unit
- the TimeUnit
of timeout
- Throws:
java.lang.InterruptedException