T
- The type of result produced / acceptedpublic abstract class FlowControlledProcessor<T>
extends java.lang.Object
This object is one time use. Once hasNext()
returns false
it should be
considered done forever. If more work needs to be processed then this object needs to be
reconstructed with a new instance.
Constructor and Description |
---|
FlowControlledProcessor(int maxRunningTasks,
boolean provideResultsInOrder)
Construct a new processor.
|
Modifier and Type | Method and Description |
---|---|
ListenableFuture<?> |
start()
Start processing tasks.
|
public FlowControlledProcessor(int maxRunningTasks, boolean provideResultsInOrder)
start()
once constructed to start
processing.maxRunningTasks
- Maximum number of concurrent running tasksprovideResultsInOrder
- If true
completed results will be provided in the order they are submittedpublic ListenableFuture<?> start()
handleFailure(Throwable)
returns false
indicating an error is not
able to be handled.
In the case of an unhandled error the returned future will finish with the error condition.
Because of that, it's important the returned futures state is checked to verify an unhandled
error did not occur. This can be done easily with
ListenableFuture.failureCallback(java.util.function.Consumer)
.