- Type Parameters:
T- The type of result produced / accepted
- Direct Known Subclasses:
public abstract class FlowControlledProcessor<T> extends java.lang.ObjectAbstract implementation which will do async processing, but only submit a limited number of tasks processing concurrently. This is different from something like an ExecutorLimiter because it not only limits execution, but pulls for new tasks when ready. This makes it easier to limit how much is held in heap. Otherwise while pools may limit execution to prevent over utilizing resources, this will help prevent task submission to ensure that the running processor does not over-consume its heap.
This object is one time use. Once
falseit should be considered done forever. If more work needs to be processed then this object needs to be reconstructed with a new instance.
Constructors Constructor Description
FlowControlledProcessor(int maxRunningTasks, boolean provideResultsInOrder)Construct a new processor.
public FlowControlledProcessor(int maxRunningTasks, boolean provideResultsInOrder)Construct a new processor. You must invoke
start()once constructed to start processing.
maxRunningTasks- Maximum number of concurrent running tasks
truecompleted results will be provided in the order they are submitted
public ListenableFuture<?> start()Start processing tasks. The returned future wont complete until task execution has completed or unless
falseindicating 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
- Future to indicate state of completion. This future's result