public class OrderedItemProcessor<ItemType,ResultType>
extends java.lang.Object
implements java.lang.AutoCloseable
| Modifier and Type | Class and Description |
|---|---|
static class |
OrderedItemProcessor.ProcessingException |
| Constructor and Description |
|---|
OrderedItemProcessor(int capacity,
java.util.function.Function<ItemType,java.util.concurrent.CompletableFuture<ResultType>> processor,
java.util.concurrent.Executor executor)
Creates a new instance of the OrderedItemProcessor class.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
protected void |
executionComplete(java.lang.Throwable exception)
Callback that is invoked when an item has completed execution.
|
java.util.concurrent.CompletableFuture<ResultType> |
process(ItemType item)
Processes the given item.
|
public OrderedItemProcessor(int capacity,
java.util.function.Function<ItemType,java.util.concurrent.CompletableFuture<ResultType>> processor,
java.util.concurrent.Executor executor)
capacity - The maximum number of concurrent executions.processor - A Function that, given an Item, returns a CompletableFuture that indicates when the item has been
processed (successfully or not).executor - An Executor for async invocations.public void close()
close in interface java.lang.AutoCloseablepublic java.util.concurrent.CompletableFuture<ResultType> process(ItemType item)
item - The item to process.protected void executionComplete(java.lang.Throwable exception)
exception - (Optional) An exception from the execution. If set, it indicates the item has not been
processed successfully.