Skip to content

Commit

Permalink
ChainExecutor.andThen() added.
Browse files Browse the repository at this point in the history
  • Loading branch information
marco-brandizi committed Nov 6, 2023
1 parent 25b1452 commit b21f17f
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/main/java/uk/ac/ebi/utils/runcontrol/ChainExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,21 @@ public void execute ( final Runnable action )
*/
public ChainExecutor wrap ( Executor externalExecutor ) {
return new ChainExecutor ( externalExecutor, this );
}
}

/**
* It's the reverse of {@link #wrap(Executor)}.
*
* Returns an executor that passes {@link #execute(Runnable) its runnable} to this executor, which
* then invokes nextExecutor.
*
* This can be used to chain things inside-out:
* {@code new ChainExecutor ( multiAttemptsExec ).andThen ( rateLimitedExec ) }
*
* TODO: never tested!
*
*/
public ChainExecutor andThen ( Executor nextExecutor ) {
return new ChainExecutor ( this, nextExecutor );
}
}

0 comments on commit b21f17f

Please sign in to comment.