|
28 | 28 |
|
29 | 29 | public class J8Examples { |
30 | 30 |
|
31 | | - static BigInteger tryCalc(RetryContext<Number> ctx) { |
32 | | - return BigInteger.ONE; |
33 | | - } |
34 | | - |
35 | 31 | public static void main(final String[] argv) throws InterruptedException, ExecutionException { |
36 | 32 | final TaskExecutorService executorService = TaskExecutors.newFixedThreadPool(6); |
37 | 33 |
|
| 34 | + @SuppressWarnings("unused") |
| 35 | + Promise<Void> t1 = Promises.retry(() -> System.out.println("Hello!"), executorService, RetryPolicy.DEFAULT); |
| 36 | + |
| 37 | + @SuppressWarnings("unused") |
| 38 | + Promise<String> t2 = Promises.retry(() -> "Hello!", executorService, RetryPolicy.DEFAULT); |
| 39 | + |
| 40 | + // Must be a block of code in next sample -- otherwise ambiguity |
| 41 | + @SuppressWarnings("unused") |
| 42 | + Promise<Void> t3 = Promises.retry(ctx -> {System.out.println("Hello!");}, executorService, RetryPolicy.DEFAULT); |
| 43 | + |
| 44 | + @SuppressWarnings("unused") |
| 45 | + Promise<String> t4 = Promises.retry(ctx -> "Hello!", executorService, RetryPolicy.DEFAULT); |
| 46 | + |
| 47 | + @SuppressWarnings("unused") |
| 48 | + Promise<Void> t5 = Promises.retry(J8Examples::nop, executorService, RetryPolicy.DEFAULT); |
| 49 | + |
| 50 | + @SuppressWarnings("unused") |
| 51 | + Promise<Void> t6 = Promises.retry(J8Examples::nopCtx, executorService, RetryPolicy.DEFAULT); |
| 52 | + |
| 53 | + |
38 | 54 | Promise<BigInteger> tryTyping = Promises.retry( |
39 | 55 | J8Examples::tryCalc, executorService, |
40 | 56 | RetryPolicy.<Number>create().withResultValidator(v -> v.intValue() > 0).withMaxRetries(2) |
@@ -265,6 +281,18 @@ private static CompletionStage<String> pollingFutureMethod(RetryContext<String> |
265 | 281 | return CompletableTask.supplyAsync(() -> "42", executor); |
266 | 282 | } |
267 | 283 |
|
| 284 | + static BigInteger tryCalc(RetryContext<Number> ctx) { |
| 285 | + return BigInteger.ONE; |
| 286 | + } |
| 287 | + |
| 288 | + static void nop() { |
| 289 | + |
| 290 | + } |
| 291 | + |
| 292 | + static void nopCtx(RetryContext<?> ctx) { |
| 293 | + |
| 294 | + } |
| 295 | + |
268 | 296 | private static void onComplete(int i) { |
269 | 297 | System.out.println(">>> Result " + i + ", " + Thread.currentThread()); |
270 | 298 | } |
|
0 commit comments