640 |
|
|
641 |
|
ASYNC { |
642 |
|
public void checkExecutionMode() { |
643 |
< |
// If tests are added that may run across different |
644 |
< |
// pools, this needs to be weakened to no-op. |
645 |
< |
ForkJoinPool p = ForkJoinTask.getPool(); |
646 |
< |
assertTrue(p == null || |
647 |
< |
(defaultExecutorIsCommonPool && |
648 |
< |
p == ForkJoinPool.commonPool())); |
643 |
> |
assertEquals(defaultExecutorIsCommonPool, |
644 |
> |
(ForkJoinPool.commonPool() == ForkJoinTask.getPool())); |
645 |
|
} |
646 |
|
public CompletableFuture<Void> runAsync(Runnable a) { |
647 |
|
return CompletableFuture.runAsync(a); |
3525 |
|
long timeoutMillis = timeoutMillis(); |
3526 |
|
CompletableFuture<Integer> f = new CompletableFuture<>(); |
3527 |
|
long startTime = System.nanoTime(); |
3528 |
< |
f.orTimeout(timeoutMillis, MILLISECONDS); |
3528 |
> |
assertSame(f, f.orTimeout(timeoutMillis, MILLISECONDS)); |
3529 |
|
checkCompletedWithTimeoutException(f); |
3530 |
|
assertTrue(millisElapsedSince(startTime) >= timeoutMillis); |
3531 |
|
} |
3540 |
|
CompletableFuture<Integer> g = new CompletableFuture<>(); |
3541 |
|
long startTime = System.nanoTime(); |
3542 |
|
f.complete(v1); |
3543 |
< |
f.orTimeout(LONG_DELAY_MS, MILLISECONDS); |
3544 |
< |
g.orTimeout(LONG_DELAY_MS, MILLISECONDS); |
3543 |
> |
assertSame(f, f.orTimeout(LONG_DELAY_MS, MILLISECONDS)); |
3544 |
> |
assertSame(g, g.orTimeout(LONG_DELAY_MS, MILLISECONDS)); |
3545 |
|
g.complete(v1); |
3546 |
|
checkCompletedNormally(f, v1); |
3547 |
|
checkCompletedNormally(g, v1); |
3560 |
|
long timeoutMillis = timeoutMillis(); |
3561 |
|
CompletableFuture<Integer> f = new CompletableFuture<>(); |
3562 |
|
long startTime = System.nanoTime(); |
3563 |
< |
f.completeOnTimeout(v, timeoutMillis, MILLISECONDS); |
3563 |
> |
assertSame(f, f.completeOnTimeout(v, timeoutMillis, MILLISECONDS)); |
3564 |
|
assertSame(v, f.join()); |
3565 |
|
assertTrue(millisElapsedSince(startTime) >= timeoutMillis); |
3566 |
|
f.complete(99); // should have no effect |
3577 |
|
CompletableFuture<Integer> g = new CompletableFuture<>(); |
3578 |
|
long startTime = System.nanoTime(); |
3579 |
|
f.complete(v1); |
3580 |
< |
f.completeOnTimeout(-1, LONG_DELAY_MS, MILLISECONDS); |
3581 |
< |
g.completeOnTimeout(-1, LONG_DELAY_MS, MILLISECONDS); |
3580 |
> |
assertSame(f, f.completeOnTimeout(-1, LONG_DELAY_MS, MILLISECONDS)); |
3581 |
> |
assertSame(g, g.completeOnTimeout(-1, LONG_DELAY_MS, MILLISECONDS)); |
3582 |
|
g.complete(v1); |
3583 |
|
checkCompletedNormally(f, v1); |
3584 |
|
checkCompletedNormally(g, v1); |