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

Comparing jsr166/src/test/tck/ForkJoinTask8Test.java (file contents):
Revision 1.14 by jsr166, Sat Apr 25 04:55:30 2015 UTC vs.
Revision 1.15 by dl, Tue Sep 8 23:56:19 2015 UTC

# Line 9 | Line 9 | import static java.util.concurrent.TimeU
9  
10   import java.util.Arrays;
11   import java.util.Collections;
12 + import java.util.concurrent.CountDownLatch;
13   import java.util.concurrent.ExecutionException;
14   import java.util.concurrent.ForkJoinPool;
15   import java.util.concurrent.ForkJoinTask;
16 + import java.util.concurrent.ForkJoinWorkerThread;
17   import java.util.concurrent.RecursiveAction;
18   import java.util.concurrent.TimeoutException;
19  
# Line 1152 | Line 1154 | public class ForkJoinTask8Test extends J
1154          testInvokeOnPool(mainPool(), a);
1155      }
1156  
1157 +    // jdk9
1158 +    
1159 +    /**
1160 +     * pollSubmission returns unexecuted submitted task, if present
1161 +     */
1162 +    public void testPollSubmission() {
1163 +        final CountDownLatch done = new CountDownLatch(1);
1164 +        final ForkJoinTask a = ForkJoinTask.adapt(awaiter(done));
1165 +        final ForkJoinTask b = ForkJoinTask.adapt(awaiter(done));
1166 +        final ForkJoinTask c = ForkJoinTask.adapt(awaiter(done));
1167 +        final ForkJoinPool p = singletonPool();
1168 +        Thread external = new Thread() {
1169 +                public void run() {
1170 +                    p.execute(a);
1171 +                    p.execute(b);
1172 +                    p.execute(c);
1173 +                }};
1174 +        RecursiveAction s = new CheckedRecursiveAction() {
1175 +                protected void realCompute() {
1176 +                    external.start();
1177 +                    try {
1178 +                        external.join();
1179 +                    } catch(Exception ex) {
1180 +                        threadUnexpectedException(ex);
1181 +                    }
1182 +                    assertTrue(p.hasQueuedSubmissions());
1183 +                    assertTrue(Thread.currentThread() instanceof ForkJoinWorkerThread);
1184 +                    ForkJoinTask r = ForkJoinTask.pollSubmission();
1185 +                    assertTrue(r == a || r == b || r == c);
1186 +                    assertFalse(r.isDone());
1187 +                }};
1188 +        try {
1189 +            p.invoke(s);
1190 +        } finally {
1191 +            done.countDown();
1192 +            joinPool(p);
1193 +        }
1194 +    }
1195 +
1196 +    
1197   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines