Class AggregatingCalculationListener<T>
- java.lang.Object
-
- com.opengamma.strata.calc.runner.AggregatingCalculationListener<T>
-
- Type Parameters:
T
- the type of the aggregate result
- All Implemented Interfaces:
CalculationListener
- Direct Known Subclasses:
ResultsListener
public abstract class AggregatingCalculationListener<T> extends Object implements CalculationListener
Superclass for mutable calculation listeners that collect the results of individual calculations and create a single aggregate result when the calculations are complete.
-
-
Constructor Summary
Constructors Constructor Description AggregatingCalculationListener()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
calculationsComplete()
Invoked when all calculations have completed.protected abstract T
createAggregateResult()
Invoked to create the aggregate result when the individual calculations are complete.CompletableFuture<T>
getFuture()
A future providing asynchronous notification when the results are available.T
result()
Returns the aggregate result of the calculations, blocking until it is available.abstract void
resultReceived(CalculationTarget target, CalculationResult result)
Invoked when a calculation completes.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.opengamma.strata.calc.runner.CalculationListener
calculationsStarted
-
-
-
-
Method Detail
-
calculationsComplete
public final void calculationsComplete()
Description copied from interface:CalculationListener
Invoked when all calculations have completed.This is guaranteed to be called after all results have been passed to
CalculationListener.resultReceived(com.opengamma.strata.basics.CalculationTarget, com.opengamma.strata.calc.runner.CalculationResult)
.This method will be called immediately after
CalculationListener.calculationsStarted(List, List)
and without any calls toCalculationListener.resultReceived(CalculationTarget, CalculationResult)
if there are no calculations to be performed. This can happen if an empty list of targets is passed to the calculation runner.- Specified by:
calculationsComplete
in interfaceCalculationListener
-
result
public T result()
Returns the aggregate result of the calculations, blocking until it is available.If the thread is interrupted while this method is blocked, then a runtime exception is thrown, but with the interrupt flag set. For additional control, use
getFuture()
.- Returns:
- the aggregate result of the calculations, blocking until it is available
-
getFuture
public CompletableFuture<T> getFuture()
A future providing asynchronous notification when the results are available.- Returns:
- a future providing asynchronous notification when the results are available
-
resultReceived
public abstract void resultReceived(CalculationTarget target, CalculationResult result)
Description copied from interface:CalculationListener
Invoked when a calculation completes.It is guaranteed that
CalculationListener.calculationsStarted(List, List)
will be called before this method and that this method will never be called afterCalculationListener.calculationsComplete()
.It is possible that this method will never be called. This can happen if an empty list of targets is passed to the calculation runner.
- Specified by:
resultReceived
in interfaceCalculationListener
- Parameters:
target
- the calculation target, such as a traderesult
- the result of the calculation
-
createAggregateResult
protected abstract T createAggregateResult()
Invoked to create the aggregate result when the individual calculations are complete.This is guaranteed to be invoked after all results have been passed to
resultReceived(com.opengamma.strata.basics.CalculationTarget, com.opengamma.strata.calc.runner.CalculationResult)
.- Returns:
- the aggregate result of all the calculations
-
-