public static < T > CompletableFuture < T > asyncFuture ( CompletableFuture < T > future , Executor executor ) { CompletableFuture < T > newFuture = new AtomixFuture <> ( ) ; future . whenComplete ( ( result , error ) -> { executor . execute ( ( ) -> { if ( error == null ) { newFuture . complete ( result ) ; } else { newFuture . completeExceptionally ( error ) ; } } ) ; } ) ; return newFuture ; }
Returns a wrapped future that will be completed on the given executor .