org.eclipse.wst.jsdt.chromium.util

## Class AsyncFutureMerger<T>

- java.lang.Object
- - org.eclipse.wst.jsdt.chromium.util.AsyncFutureMerger<T>

Type Parameters:
  `T` - type of sub-operation result

    public class AsyncFutureMerger<T>
    extends java.lang.Object

A class that provides an `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 Summary

Constructors
Constructor and Description
`AsyncFutureMerger()`

### Method Summary

All Methods Instance Methods Concrete Methods
`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.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### AsyncFutureMerger

    public AsyncFutureMerger()

### Method Detail

#### addSubOperation

    public void addSubOperation()

Registers a new sub-operation. This method is not thread-safe. User must synchronize access himself.

#### subOperationDone

    public void subOperationDone(T result)

Registers a sub-operation completion and saves its result. This call is not mandatory and user may fail to make it; this won't cause waiting thread to block forever. This method is not thread-safe. User must synchronize access himself.

#### subOperationDoneSync

    public void subOperationDoneSync(java.lang.RuntimeException exception)

Additionally registers a sub-operation completion. This method should be called only after `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.

Parameters:
  `exception` - optional value of a failure that prevented corresponding call to `subOperationDone(T)`

#### getFuture

    public AsyncFuture<java.util.List<T>> getFuture()

Returns `AsyncFuture` that provides the group result. This method is thread-safe.