File tree 2 files changed +8
-2
lines changed
main/java/net/jodah/failsafe
test/java/net/jodah/failsafe
2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change 34
34
* Failsafe#with(Policy[])}.
35
35
* <p>
36
36
* Async executions are run by default on the {@link ForkJoinPool#commonPool()}. Alternative executors can be configured
37
- * via {@link #with(ScheduledExecutorService)} and similar methods. All async executions are cancellable via the
38
- * returned CompletableFuture, even those run by a {@link ForkJoinPool} or {@link CompletionStage}.
37
+ * via {@link #with(ScheduledExecutorService)} and similar methods. All async executions are cancellable and
38
+ * interruptable via the returned CompletableFuture, even those run by a {@link ForkJoinPool} or {@link CompletionStage}.
39
39
*
40
40
* @param <R> result type
41
41
* @author Jonathan Halterman
Original file line number Diff line number Diff line change @@ -85,12 +85,18 @@ public static <T extends CircuitState> T stateFor(CircuitBreaker breaker) {
85
85
}
86
86
}
87
87
88
+ /**
89
+ * Returns a future that is completed with the {@code result} on the {@code executor}.
90
+ */
88
91
public static CompletableFuture <Object > futureResult (ScheduledExecutorService executor , Object result ) {
89
92
CompletableFuture <Object > future = new CompletableFuture <>();
90
93
executor .schedule (() -> future .complete (result ), 0 , TimeUnit .MILLISECONDS );
91
94
return future ;
92
95
}
93
96
97
+ /**
98
+ * Returns a future that is completed with the {@code exception} on the {@code executor}.
99
+ */
94
100
public static CompletableFuture <Object > futureException (ScheduledExecutorService executor , Exception exception ) {
95
101
CompletableFuture <Object > future = new CompletableFuture <>();
96
102
executor .schedule (() -> future .completeExceptionally (exception ), 0 , TimeUnit .MILLISECONDS );
You can’t perform that action at this time.
0 commit comments