Skip to content

Commit

Permalink
Add CommandFuture.immediate(v) to create a future with a set value.
Browse files Browse the repository at this point in the history
  • Loading branch information
rogermb committed Oct 31, 2015
1 parent d758a60 commit 8eeeede
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,22 @@ public synchronized void forwardResult(final CommandFuture<V> otherFuture) {
forwardSuccess(otherFuture).forwardFailure(otherFuture);
}

/**
* Returns a new {@code CommandFuture} that already has a value set.
*
* @param value
* the default value for the new {@code CommandFuture}
* @param <V>
* the dynamic type of the value, will usually be inferred
*
* @return a new {@code CommandFuture} with a default value
*/
public static <V> CommandFuture<V> immediate(V value) {
final CommandFuture<V> future = new CommandFuture<>();
future.set(value);
return future;
}

/**
* Combines multiple {@code CommandFuture}s into a single future, which will
* succeed if all futures succeed and fail as soon as one future fails.
Expand Down

0 comments on commit 8eeeede

Please sign in to comment.