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

Comparing jsr166/src/test/tck/ForkJoinPoolTest.java (file contents):
Revision 1.35 by dl, Fri Nov 19 00:20:47 2010 UTC vs.
Revision 1.36 by jsr166, Mon Nov 29 07:42:58 2010 UTC

# Line 328 | Line 328 | public class ForkJoinPoolTest extends JS
328       * pollSubmission returns unexecuted submitted task, if present
329       */
330      public void testPollSubmission() {
331 +        final CountDownLatch done = new CountDownLatch(1);
332          SubFJP p = new SubFJP();
333          try {
334 <            ForkJoinTask a = p.submit(new ShortRunnable());
335 <            ForkJoinTask b = p.submit(new ShortRunnable());
336 <            ForkJoinTask c = p.submit(new ShortRunnable());
334 >            ForkJoinTask a = p.submit(awaiter(done));
335 >            ForkJoinTask b = p.submit(awaiter(done));
336 >            ForkJoinTask c = p.submit(awaiter(done));
337              ForkJoinTask r = p.pollSubmission();
338              assertTrue(r == a || r == b || r == c);
339              assertFalse(r.isDone());
340          } finally {
341 +            done.countDown();
342              joinPool(p);
343          }
344      }
# Line 345 | Line 347 | public class ForkJoinPoolTest extends JS
347       * drainTasksTo transfers unexecuted submitted tasks, if present
348       */
349      public void testDrainTasksTo() {
350 +        final CountDownLatch done = new CountDownLatch(1);
351          SubFJP p = new SubFJP();
352          try {
353 <            ForkJoinTask a = p.submit(new ShortRunnable());
354 <            ForkJoinTask b = p.submit(new ShortRunnable());
355 <            ForkJoinTask c = p.submit(new ShortRunnable());
353 >            ForkJoinTask a = p.submit(awaiter(done));
354 >            ForkJoinTask b = p.submit(awaiter(done));
355 >            ForkJoinTask c = p.submit(awaiter(done));
356              ArrayList<ForkJoinTask> al = new ArrayList();
357              p.drainTasksTo(al);
358              assertTrue(al.size() > 0);
# Line 358 | Line 361 | public class ForkJoinPoolTest extends JS
361                  assertFalse(r.isDone());
362              }
363          } finally {
364 +            done.countDown();
365              joinPool(p);
366          }
367      }
# Line 375 | Line 379 | public class ForkJoinPoolTest extends JS
379              assertFalse(task.isDone());
380              Future<?> future = e.submit(task);
381              assertNull(future.get());
382 +            assertNull(future.get(MEDIUM_DELAY_MS, MILLISECONDS));
383              assertTrue(task.isDone());
384 +            assertTrue(future.isDone());
385              assertFalse(future.isCancelled());
386          } finally {
387              joinPool(e);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines