ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/tck/CompletableFutureTest.java
(Generate patch)

Comparing jsr166/src/test/tck/CompletableFutureTest.java (file contents):
Revision 1.139 by jsr166, Sat Jan 23 20:02:48 2016 UTC vs.
Revision 1.140 by jsr166, Mon Mar 28 19:18:16 2016 UTC

# Line 3925 | Line 3925 | public class CompletableFutureTest exten
3925                                   Monad.plus(godot, Monad.unit(5L)));
3926      }
3927  
3928 +    /**
3929 +     * A single CompletableFuture with many dependents.
3930 +     */
3931 +    public void testManyDependents() throws Throwable {
3932 +        final int n = 10_000;
3933 +        final CompletableFuture<Void> head = new CompletableFuture<>();
3934 +        final CompletableFuture<Void> incomplete = new CompletableFuture<>();
3935 +        final CompletableFuture<Void> complete = CompletableFuture.completedFuture((Void)null);
3936 +        final AtomicInteger count = new AtomicInteger(0);
3937 +        for (int i = 0; i < n; i++) {
3938 +            head.thenRun(() -> count.getAndIncrement());
3939 +            head.thenAccept((x) -> count.getAndIncrement());
3940 +            head.thenApply((x) -> count.getAndIncrement());
3941 +            head.runAfterBoth(complete, () -> count.getAndIncrement());
3942 +            head.thenAcceptBoth(complete, (x, y) -> count.getAndIncrement());
3943 +            head.thenCombine(complete, (x, y) -> count.getAndIncrement());
3944 +            head.runAfterEither(incomplete, () -> count.getAndIncrement());
3945 +            head.acceptEither(incomplete, (x) -> count.getAndIncrement());
3946 +            head.applyToEither(incomplete, (x) -> count.getAndIncrement());
3947 +        }
3948 +        head.complete(null);
3949 +        assertEquals(9 * n, count.get());
3950 +    }
3951 +
3952   //     static <U> U join(CompletionStage<U> stage) {
3953   //         CompletableFuture<U> f = new CompletableFuture<>();
3954   //         stage.whenComplete((v, ex) -> {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines