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.17 by jsr166, Wed Sep 9 00:33:23 2015 UTC vs.
Revision 1.20 by jsr166, Tue Oct 6 00:36:55 2015 UTC

# Line 74 | Line 74 | public class ForkJoinTask8Test extends J
74      }
75  
76      private void testInvokeOnPool(ForkJoinPool pool, RecursiveAction a) {
77 <        try {
77 >        try (PoolCleaner cleaner = cleaner(pool)) {
78              assertFalse(a.isDone());
79              assertFalse(a.isCompletedNormally());
80              assertFalse(a.isCompletedAbnormally());
# Line 90 | Line 90 | public class ForkJoinTask8Test extends J
90              assertFalse(a.isCancelled());
91              assertNull(a.getException());
92              assertNull(a.getRawResult());
93        } finally {
94            joinPool(pool);
93          }
94      }
95  
# Line 128 | Line 126 | public class ForkJoinTask8Test extends J
126  
127          {
128              Thread.currentThread().interrupt();
129 <            long t0 = System.nanoTime();
129 >            long startTime = System.nanoTime();
130              assertSame(expected, a.join());
131 <            assertTrue(millisElapsedSince(t0) < SMALL_DELAY_MS);
131 >            assertTrue(millisElapsedSince(startTime) < SMALL_DELAY_MS);
132              Thread.interrupted();
133          }
134  
135          {
136              Thread.currentThread().interrupt();
137 <            long t0 = System.nanoTime();
137 >            long startTime = System.nanoTime();
138              a.quietlyJoin();        // should be no-op
139 <            assertTrue(millisElapsedSince(t0) < SMALL_DELAY_MS);
139 >            assertTrue(millisElapsedSince(startTime) < SMALL_DELAY_MS);
140              Thread.interrupted();
141          }
142  
# Line 174 | Line 172 | public class ForkJoinTask8Test extends J
172          Thread.interrupted();
173  
174          {
175 <            long t0 = System.nanoTime();
175 >            long startTime = System.nanoTime();
176              a.quietlyJoin();        // should be no-op
177 <            assertTrue(millisElapsedSince(t0) < SMALL_DELAY_MS);
177 >            assertTrue(millisElapsedSince(startTime) < SMALL_DELAY_MS);
178          }
179  
180          try {
# Line 200 | Line 198 | public class ForkJoinTask8Test extends J
198  
199      abstract static class BinaryAsyncAction extends ForkJoinTask<Void> {
200  
201 <        private BinaryAsyncAction parent;
201 >        private volatile BinaryAsyncAction parent;
202  
203 <        private BinaryAsyncAction sibling;
203 >        private volatile BinaryAsyncAction sibling;
204  
205          protected BinaryAsyncAction() {
206              setForkJoinTaskTag(INITIAL_STATE);
# Line 1165 | Line 1163 | public class ForkJoinTask8Test extends J
1163          final ForkJoinTask b = ForkJoinTask.adapt(awaiter(done));
1164          final ForkJoinTask c = ForkJoinTask.adapt(awaiter(done));
1165          final ForkJoinPool p = singletonPool();
1166 <        Thread external = new Thread(new CheckedRunnable() {
1167 <            public void realRun() {
1168 <                p.execute(a);
1169 <                p.execute(b);
1170 <                p.execute(c);
1171 <            }});
1172 <        RecursiveAction s = new CheckedRecursiveAction() {
1173 <            protected void realCompute() {
1174 <                external.start();
1175 <                try {
1176 <                    external.join();
1177 <                } catch (Exception ex) {
1178 <                    threadUnexpectedException(ex);
1179 <                }
1180 <                assertTrue(p.hasQueuedSubmissions());
1181 <                assertTrue(Thread.currentThread() instanceof ForkJoinWorkerThread);
1182 <                ForkJoinTask r = ForkJoinTask.pollSubmission();
1183 <                assertTrue(r == a || r == b || r == c);
1184 <                assertFalse(r.isDone());
1185 <            }};
1186 <        try {
1166 >        try (PoolCleaner cleaner = cleaner(p)) {
1167 >            Thread external = new Thread(new CheckedRunnable() {
1168 >                public void realRun() {
1169 >                    p.execute(a);
1170 >                    p.execute(b);
1171 >                    p.execute(c);
1172 >                }});
1173 >            RecursiveAction s = new CheckedRecursiveAction() {
1174 >                protected void realCompute() {
1175 >                    external.start();
1176 >                    try {
1177 >                        external.join();
1178 >                    } catch (Exception ex) {
1179 >                        threadUnexpectedException(ex);
1180 >                    }
1181 >                    assertTrue(p.hasQueuedSubmissions());
1182 >                    assertTrue(Thread.currentThread() instanceof ForkJoinWorkerThread);
1183 >                    ForkJoinTask r = ForkJoinTask.pollSubmission();
1184 >                    assertTrue(r == a || r == b || r == c);
1185 >                    assertFalse(r.isDone());
1186 >                }};
1187              p.invoke(s);
1190        } finally {
1188              done.countDown();
1192            joinPool(p);
1189          }
1190      }
1191  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines