trackAndRunTreeFuture

fun <T : PotentiallyPartialResult, F : TreeFuture<T>> trackAndRunTreeFuture(treeFuture: F, futureList: MutableList<F>, source: Int, mutex: Any, futureExecutionListener: TreeFuture.FutureExecutionListener?): TreeFuture.TreeFutureResult<T>

Given a provided tree-future, this method will track it via a given list, and run it.

If an equivalent tree-future is found in the given list of futures, the sequence in this method will attempt to reuse it and increase the wait-count on it if successful.

If an async operation is requested and an equivalent future is already running, it will be discarded and return null.

If no equivalent running future was found in the provided list, it will be added to the list for the duration of the run, and then, provided it has a 0 wait-count, it will be removed from the provided list.

Return

The result holder of running the future. It will contain the result if there were no issues running the future, or a message explaining why the result is null.

Parameters

treeFuture

The future to executed

futureList

The list of futures this future will be added to

source

The source of the calculation

mutex

A mutex to use to synchronize access to the provided future list

futureExecutionListener

optional listener that will be invoked just before the future is run

The generic type of the provided future & expected result