* This starts the flow and applies a mapping function fn in
* the same thread that completion happens
*/
public static <Config, T> Future<T> start(Flow<Config> flow, final scala.Function1<Flow<Config>, T> fn) {
final Promise<T> result = Promise$.MODULE$.<T>apply();
flow.addListener(new FlowListener() {
public void onStarting(Flow f) { } // ignore
public void onStopping(Flow f) { } // ignore
public void onCompleted(Flow f) {
// This is always called, but onThrowable is called first
if(!result.isCompleted()) {