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

Comparing jsr166/src/test/tck/RecursiveActionTest.java (file contents):
Revision 1.9 by jsr166, Sat Nov 21 02:07:27 2009 UTC vs.
Revision 1.10 by dl, Wed Aug 11 19:50:02 2010 UTC

# Line 19 | Line 19 | public class RecursiveActionTest extends
19  
20      static final ForkJoinPool mainPool = new ForkJoinPool();
21      static final ForkJoinPool singletonPool = new ForkJoinPool(1);
22 <    static final ForkJoinPool asyncSingletonPool = new ForkJoinPool(1);
23 <    static {
24 <        asyncSingletonPool.setAsyncMode(true);
25 <    }
22 >    static final ForkJoinPool asyncSingletonPool =
23 >        new ForkJoinPool(1, ForkJoinPool.defaultForkJoinWorkerThreadFactory,
24 >                         null, true);
25  
26      static final class FJException extends RuntimeException {
27          FJException() { super(); }
# Line 177 | Line 176 | public class RecursiveActionTest extends
176      }
177  
178      /**
180     * helpJoin of a forked task returns when task completes
181     */
182    public void testForkHelpJoin() {
183        RecursiveAction a = new RecursiveAction() {
184            public void compute() {
185                FibAction f = new FibAction(8);
186                f.fork();
187                f.helpJoin();
188                threadAssertTrue(f.result == 21);
189                threadAssertTrue(f.isDone());
190            }};
191        mainPool.invoke(a);
192    }
193
194    /**
179       * quietlyJoin of a forked task returns when task completes
180       */
181      public void testForkQuietlyJoin() {
# Line 208 | Line 192 | public class RecursiveActionTest extends
192  
193  
194      /**
211     * quietlyHelpJoin of a forked task returns when task completes
212     */
213    public void testForkQuietlyHelpJoin() {
214        RecursiveAction a = new RecursiveAction() {
215            public void compute() {
216                FibAction f = new FibAction(8);
217                f.fork();
218                f.quietlyHelpJoin();
219                threadAssertTrue(f.result == 21);
220                threadAssertTrue(f.isDone());
221            }};
222        mainPool.invoke(a);
223    }
224
225
226    /**
195       * helpQuiesce returns when tasks are complete.
196       * getQueuedTaskCount returns 0 when quiescent
197       */
# Line 326 | Line 294 | public class RecursiveActionTest extends
294      }
295  
296      /**
329     * join of a forked task throws exception when task completes abnormally
330     */
331    public void testAbnormalForkHelpJoin() {
332        RecursiveAction a = new RecursiveAction() {
333            public void compute() {
334                try {
335                    FailingFibAction f = new FailingFibAction(8);
336                    f.fork();
337                    f.helpJoin();
338                    shouldThrow();
339                } catch (FJException success) {
340                }
341            }};
342        mainPool.invoke(a);
343    }
344
345    /**
346     * quietlyHelpJoin of a forked task returns when task completes abnormally.
347     * getException of failed task returns its exception.
348     * isCompletedAbnormally of a failed task returns true.
349     * isCancelled of a failed uncancelled task returns false
350     */
351    public void testAbnormalForkQuietlyHelpJoin() {
352        RecursiveAction a = new RecursiveAction() {
353            public void compute() {
354                FailingFibAction f = new FailingFibAction(8);
355                f.fork();
356                f.quietlyHelpJoin();
357                threadAssertTrue(f.isDone());
358                threadAssertTrue(f.isCompletedAbnormally());
359                threadAssertFalse(f.isCancelled());
360                threadAssertTrue(f.getException() instanceof FJException);
361            }};
362        mainPool.invoke(a);
363    }
364
365    /**
297       * quietlyJoin of a forked task returns when task completes abnormally
298       */
299      public void testAbnormalForkQuietlyJoin() {
# Line 452 | Line 383 | public class RecursiveActionTest extends
383              }};
384          mainPool.invoke(a);
385      }
455
456    /**
457     * join of a forked task throws exception when task cancelled
458     */
459    public void testCancelledForkHelpJoin() {
460        RecursiveAction a = new RecursiveAction() {
461            public void compute() {
462                try {
463                    FibAction f = new FibAction(8);
464                    f.cancel(true);
465                    f.fork();
466                    f.helpJoin();
467                    shouldThrow();
468                } catch (CancellationException success) {
469                }
470            }};
471        mainPool.invoke(a);
472    }
473
474    /**
475     * quietlyHelpJoin of a forked task returns when task cancelled.
476     * getException of cancelled task returns its exception.
477     * isCompletedAbnormally of a cancelled task returns true.
478     * isCancelled of a cancelled task returns true
479     */
480    public void testCancelledForkQuietlyHelpJoin() {
481        RecursiveAction a = new RecursiveAction() {
482            public void compute() {
483                FibAction f = new FibAction(8);
484                f.cancel(true);
485                f.fork();
486                f.quietlyHelpJoin();
487                threadAssertTrue(f.isDone());
488                threadAssertTrue(f.isCompletedAbnormally());
489                threadAssertTrue(f.isCancelled());
490                threadAssertTrue(f.getException() instanceof CancellationException);
491            }};
492        mainPool.invoke(a);
493    }
386  
387      /**
388       * quietlyJoin of a forked task returns when task cancelled

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines