T - type of sub-operation resultpublic class AsyncFutureMerger<T>
extends java.lang.Object
AsyncFuture for a group operation: one that consists of any
number of sub-operations and completes once all of them have completed.
The class does not care about nature of sub-operations, it only keeps their number. User
registers new sub-operations (addSubOperation()) and reports on their completion
(subOperationDone(T) and (subOperationDoneSync(java.lang.RuntimeException)). One sub-operation is registered
by default. Once all sub-operations completed,
the main operation is considered done and the future returns the group result. Groups result is
a list of sub-operation results.| Constructor and Description |
|---|
AsyncFutureMerger() |
| Modifier and Type | Method and Description |
|---|---|
void |
addSubOperation()
Registers a new sub-operation.
|
AsyncFuture<java.util.List<T>> |
getFuture()
Returns
AsyncFuture that provides the group result. |
void |
subOperationDone(T result)
Registers a sub-operation completion and saves its result.
|
void |
subOperationDoneSync(java.lang.RuntimeException exception)
Additionally registers a sub-operation completion.
|
public void addSubOperation()
public void subOperationDone(T result)
public void subOperationDoneSync(java.lang.RuntimeException exception)
subOperationDone(T) and this call is mandatory and must be made even in case of
sub-operation failure; this method is typically called form finally section of
the top-level procedure.
Other threads may block infinitely unless this method is being called a proper number of times.
This method is not thread-safe. User must synchronize access himself.exception - optional value of a failure that prevented corresponding call
to subOperationDone(T)public AsyncFuture<java.util.List<T>> getFuture()
AsyncFuture that provides the group result.
This method is thread-safe.Copyright (c) IBM Corp. and others 2000, 2016. All Rights Reserved.