Package uk.ac.ebi.utils.runcontrol
Class ChainExecutor
java.lang.Object
uk.ac.ebi.utils.runcontrol.ChainExecutor
- All Implemented Interfaces:
Executor
An
Executor
that is able to chain/stack two other executors.- Author:
- brandizi
- Date:
- 6 Oct 2015
-
Constructor Summary
ConstructorDescriptionChainExecutor
(Executor internalExecutor) This reduces to running one executor only, so it's conceptually equivalent to use theinternalExecutor
straight, but it's a base to useandThen(Executor)
.ChainExecutor
(Executor externalExecutor, Executor internalExecutor) -
Method Summary
Modifier and TypeMethodDescriptionIt's the reverse ofwrap(Executor)
.void
The external executor calls the run() method of the internal executor, passing the action to it.This allows you to indent multiple executors, without having to write big nested expressions.
-
Constructor Details
-
ChainExecutor
- See Also:
-
ChainExecutor
This reduces to running one executor only, so it's conceptually equivalent to use theinternalExecutor
straight, but it's a base to useandThen(Executor)
.
-
-
Method Details
-
execute
The external executor calls the run() method of the internal executor, passing the action to it. The result is that the two executors wrap their job around the action in a nested way. -
wrap
This allows you to indent multiple executors, without having to write big nested expressions. This is equivalent to creating a new executor using
ChainExecutor(Executor, Executor)
with the current instance as internal executor. So, it wraps the current executor with a new one.This also implies that a composition like
ex3(ex2(ex1))
here must be created viawrap( ex1 ).wrap ( ex2 ).wrap ( ex3 )
. -
andThen
It's the reverse ofwrap(Executor)
. Returns an executor that passesits runnable
to this executor, which then invokes nextExecutor. This can be used to chain things inside-out:new ChainExecutor ( multiAttemptsExec ).andThen ( rateLimitedExec )
TODO: never tested!
-