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.140 by jsr166, Mon Mar 28 19:18:16 2016 UTC vs.
Revision 1.141 by jsr166, Tue Mar 29 04:42:54 2016 UTC

# Line 3927 | Line 3927 | public class CompletableFutureTest exten
3927  
3928      /**
3929       * A single CompletableFuture with many dependents.
3930 +     * A demo of scalability - runtime is O(n).
3931       */
3932      public void testManyDependents() throws Throwable {
3933 <        final int n = 10_000;
3933 >        final int n = 1_000;
3934          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 +
3942              head.runAfterBoth(complete, () -> count.getAndIncrement());
3943              head.thenAcceptBoth(complete, (x, y) -> count.getAndIncrement());
3944              head.thenCombine(complete, (x, y) -> count.getAndIncrement());
3945 <            head.runAfterEither(incomplete, () -> count.getAndIncrement());
3946 <            head.acceptEither(incomplete, (x) -> count.getAndIncrement());
3947 <            head.applyToEither(incomplete, (x) -> count.getAndIncrement());
3945 >            complete.runAfterBoth(head, () -> count.getAndIncrement());
3946 >            complete.thenAcceptBoth(head, (x, y) -> count.getAndIncrement());
3947 >            complete.thenCombine(head, (x, y) -> count.getAndIncrement());
3948 >
3949 >            head.runAfterEither(new CompletableFuture<Void>(), () -> count.getAndIncrement());
3950 >            head.acceptEither(new CompletableFuture<Void>(), (x) -> count.getAndIncrement());
3951 >            head.applyToEither(new CompletableFuture<Void>(), (x) -> count.getAndIncrement());
3952 >            new CompletableFuture<Void>().runAfterEither(head, () -> count.getAndIncrement());
3953 >            new CompletableFuture<Void>().acceptEither(head, (x) -> count.getAndIncrement());
3954 >            new CompletableFuture<Void>().applyToEither(head, (x) -> count.getAndIncrement());
3955          }
3956          head.complete(null);
3957 <        assertEquals(9 * n, count.get());
3957 >        assertEquals(5 * 3 * n, count.get());
3958      }
3959  
3960   //     static <U> U join(CompletionStage<U> stage) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines