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.6 by jsr166, Tue Aug 4 10:13:48 2009 UTC vs.
Revision 1.9 by jsr166, Sat Nov 21 02:07:27 2009 UTC

# Line 11 | Line 11 | import java.util.*;
11   public class RecursiveActionTest extends JSR166TestCase {
12  
13      public static void main(String[] args) {
14 <        junit.textui.TestRunner.run (suite());
14 >        junit.textui.TestRunner.run (suite());
15      }
16      public static Test suite() {
17 <        return new TestSuite(RecursiveActionTest.class);
17 >        return new TestSuite(RecursiveActionTest.class);
18      }
19  
20      static final ForkJoinPool mainPool = new ForkJoinPool();
# Line 72 | Line 72 | public class RecursiveActionTest extends
72       */
73      public void testInvoke() {
74          RecursiveAction a = new RecursiveAction() {
75 <                public void compute() {
76 <                    FibAction f = new FibAction(8);
77 <                    f.invoke();
78 <                    threadAssertTrue(f.result == 21);
79 <                    threadAssertTrue(f.isDone());
80 <                    threadAssertFalse(f.isCancelled());
81 <                    threadAssertFalse(f.isCompletedAbnormally());
82 <                    threadAssertTrue(f.getRawResult() == null);
83 <                }
84 <            };
75 >            public void compute() {
76 >                FibAction f = new FibAction(8);
77 >                f.invoke();
78 >                threadAssertTrue(f.result == 21);
79 >                threadAssertTrue(f.isDone());
80 >                threadAssertFalse(f.isCancelled());
81 >                threadAssertFalse(f.isCompletedAbnormally());
82 >                threadAssertTrue(f.getRawResult() == null);
83 >            }};
84          mainPool.invoke(a);
85      }
86  
# Line 92 | Line 91 | public class RecursiveActionTest extends
91       */
92      public void testQuietlyInvoke() {
93          RecursiveAction a = new RecursiveAction() {
94 <                public void compute() {
95 <                    FibAction f = new FibAction(8);
96 <                    f.quietlyInvoke();
97 <                    threadAssertTrue(f.result == 21);
98 <                    threadAssertTrue(f.isDone());
99 <                    threadAssertFalse(f.isCancelled());
100 <                    threadAssertFalse(f.isCompletedAbnormally());
101 <                    threadAssertTrue(f.getRawResult() == null);
102 <                }
104 <            };
94 >            public void compute() {
95 >                FibAction f = new FibAction(8);
96 >                f.quietlyInvoke();
97 >                threadAssertTrue(f.result == 21);
98 >                threadAssertTrue(f.isDone());
99 >                threadAssertFalse(f.isCancelled());
100 >                threadAssertFalse(f.isCompletedAbnormally());
101 >                threadAssertTrue(f.getRawResult() == null);
102 >            }};
103          mainPool.invoke(a);
104      }
105  
# Line 110 | Line 108 | public class RecursiveActionTest extends
108       */
109      public void testForkJoin() {
110          RecursiveAction a = new RecursiveAction() {
111 <                public void compute() {
112 <                    FibAction f = new FibAction(8);
113 <                    f.fork();
114 <                    f.join();
115 <                    threadAssertTrue(f.result == 21);
116 <                    threadAssertTrue(f.isDone());
117 <                    threadAssertTrue(f.getRawResult() == null);
118 <                }
121 <            };
111 >            public void compute() {
112 >                FibAction f = new FibAction(8);
113 >                f.fork();
114 >                f.join();
115 >                threadAssertTrue(f.result == 21);
116 >                threadAssertTrue(f.isDone());
117 >                threadAssertTrue(f.getRawResult() == null);
118 >            }};
119          mainPool.invoke(a);
120      }
121  
# Line 127 | Line 124 | public class RecursiveActionTest extends
124       */
125      public void testForkGet() {
126          RecursiveAction a = new RecursiveAction() {
127 <                public void compute() {
128 <                    try {
129 <                        FibAction f = new FibAction(8);
130 <                        f.fork();
131 <                        f.get();
132 <                        threadAssertTrue(f.result == 21);
133 <                        threadAssertTrue(f.isDone());
134 <                    } catch (Exception ex) {
135 <                        unexpectedException(ex);
139 <                    }
127 >            public void compute() {
128 >                try {
129 >                    FibAction f = new FibAction(8);
130 >                    f.fork();
131 >                    f.get();
132 >                    threadAssertTrue(f.result == 21);
133 >                    threadAssertTrue(f.isDone());
134 >                } catch (Exception ex) {
135 >                    unexpectedException(ex);
136                  }
137 <            };
137 >            }};
138          mainPool.invoke(a);
139      }
140  
# Line 147 | Line 143 | public class RecursiveActionTest extends
143       */
144      public void testForkTimedGet() {
145          RecursiveAction a = new RecursiveAction() {
146 <                public void compute() {
147 <                    try {
148 <                        FibAction f = new FibAction(8);
149 <                        f.fork();
150 <                        f.get(5L, TimeUnit.SECONDS);
151 <                        threadAssertTrue(f.result == 21);
152 <                        threadAssertTrue(f.isDone());
153 <                    } catch (Exception ex) {
154 <                        unexpectedException(ex);
159 <                    }
146 >            public void compute() {
147 >                try {
148 >                    FibAction f = new FibAction(8);
149 >                    f.fork();
150 >                    f.get(5L, TimeUnit.SECONDS);
151 >                    threadAssertTrue(f.result == 21);
152 >                    threadAssertTrue(f.isDone());
153 >                } catch (Exception ex) {
154 >                    unexpectedException(ex);
155                  }
156 <            };
156 >            }};
157          mainPool.invoke(a);
158      }
159  
# Line 167 | Line 162 | public class RecursiveActionTest extends
162       */
163      public void testForkTimedGetNPE() {
164          RecursiveAction a = new RecursiveAction() {
165 <                public void compute() {
166 <                    try {
167 <                        FibAction f = new FibAction(8);
168 <                        f.fork();
169 <                        f.get(5L, null);
170 <                        shouldThrow();
171 <                    } catch (NullPointerException success) {
172 <                    } catch (Exception ex) {
173 <                        unexpectedException(ex);
179 <                    }
165 >            public void compute() {
166 >                try {
167 >                    FibAction f = new FibAction(8);
168 >                    f.fork();
169 >                    f.get(5L, null);
170 >                    shouldThrow();
171 >                } catch (NullPointerException success) {
172 >                } catch (Exception ex) {
173 >                    unexpectedException(ex);
174                  }
175 <            };
175 >            }};
176          mainPool.invoke(a);
177      }
178  
# Line 187 | Line 181 | public class RecursiveActionTest extends
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 <                }
197 <            };
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  
# Line 203 | Line 196 | public class RecursiveActionTest extends
196       */
197      public void testForkQuietlyJoin() {
198          RecursiveAction a = new RecursiveAction() {
199 <                public void compute() {
200 <                    FibAction f = new FibAction(8);
201 <                    f.fork();
202 <                    f.quietlyJoin();
203 <                    threadAssertTrue(f.result == 21);
204 <                    threadAssertTrue(f.isDone());
205 <                }
213 <            };
199 >            public void compute() {
200 >                FibAction f = new FibAction(8);
201 >                f.fork();
202 >                f.quietlyJoin();
203 >                threadAssertTrue(f.result == 21);
204 >                threadAssertTrue(f.isDone());
205 >            }};
206          mainPool.invoke(a);
207      }
208  
# Line 220 | Line 212 | public class RecursiveActionTest extends
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 <                }
230 <            };
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  
# Line 238 | Line 229 | public class RecursiveActionTest extends
229       */
230      public void testForkHelpQuiesce() {
231          RecursiveAction a = new RecursiveAction() {
232 <                public void compute() {
233 <                    FibAction f = new FibAction(8);
234 <                    f.fork();
235 <                    f.helpQuiesce();
236 <                    threadAssertTrue(f.result == 21);
237 <                    threadAssertTrue(f.isDone());
238 <                    threadAssertTrue(getQueuedTaskCount() == 0);
239 <                }
249 <            };
232 >            public void compute() {
233 >                FibAction f = new FibAction(8);
234 >                f.fork();
235 >                f.helpQuiesce();
236 >                threadAssertTrue(f.result == 21);
237 >                threadAssertTrue(f.isDone());
238 >                threadAssertTrue(getQueuedTaskCount() == 0);
239 >            }};
240          mainPool.invoke(a);
241      }
242  
# Line 256 | Line 246 | public class RecursiveActionTest extends
246       */
247      public void testAbnormalInvoke() {
248          RecursiveAction a = new RecursiveAction() {
249 <                public void compute() {
250 <                    try {
251 <                        FailingFibAction f = new FailingFibAction(8);
252 <                        f.invoke();
253 <                        shouldThrow();
254 <                    } catch (FJException success) {
265 <                    }
249 >            public void compute() {
250 >                try {
251 >                    FailingFibAction f = new FailingFibAction(8);
252 >                    f.invoke();
253 >                    shouldThrow();
254 >                } catch (FJException success) {
255                  }
256 <            };
256 >            }};
257          mainPool.invoke(a);
258      }
259  
# Line 273 | Line 262 | public class RecursiveActionTest extends
262       */
263      public void testAbnormalQuietlyInvoke() {
264          RecursiveAction a = new RecursiveAction() {
265 <                public void compute() {
266 <                    FailingFibAction f = new FailingFibAction(8);
267 <                    f.quietlyInvoke();
268 <                    threadAssertTrue(f.isDone());
269 <                }
281 <            };
265 >            public void compute() {
266 >                FailingFibAction f = new FailingFibAction(8);
267 >                f.quietlyInvoke();
268 >                threadAssertTrue(f.isDone());
269 >            }};
270          mainPool.invoke(a);
271      }
272  
# Line 287 | Line 275 | public class RecursiveActionTest extends
275       */
276      public void testAbnormalForkJoin() {
277          RecursiveAction a = new RecursiveAction() {
278 <                public void compute() {
279 <                    try {
280 <                        FailingFibAction f = new FailingFibAction(8);
281 <                        f.fork();
282 <                        f.join();
283 <                        shouldThrow();
284 <                    } catch (FJException success) {
297 <                    }
278 >            public void compute() {
279 >                try {
280 >                    FailingFibAction f = new FailingFibAction(8);
281 >                    f.fork();
282 >                    f.join();
283 >                    shouldThrow();
284 >                } catch (FJException success) {
285                  }
286 <            };
286 >            }};
287          mainPool.invoke(a);
288      }
289  
# Line 305 | Line 292 | public class RecursiveActionTest extends
292       */
293      public void testAbnormalForkGet() {
294          RecursiveAction a = new RecursiveAction() {
295 <                public void compute() {
296 <                    try {
297 <                        FailingFibAction f = new FailingFibAction(8);
298 <                        f.fork();
299 <                        f.get();
300 <                        shouldThrow();
301 <                    } catch (ExecutionException success) {
302 <                    } catch (Exception ex) {
303 <                        unexpectedException(ex);
317 <                    }
295 >            public void compute() {
296 >                try {
297 >                    FailingFibAction f = new FailingFibAction(8);
298 >                    f.fork();
299 >                    f.get();
300 >                    shouldThrow();
301 >                } catch (ExecutionException success) {
302 >                } catch (Exception ex) {
303 >                    unexpectedException(ex);
304                  }
305 <            };
305 >            }};
306          mainPool.invoke(a);
307      }
308  
# Line 325 | Line 311 | public class RecursiveActionTest extends
311       */
312      public void testAbnormalForkTimedGet() {
313          RecursiveAction a = new RecursiveAction() {
314 <                public void compute() {
315 <                    try {
316 <                        FailingFibAction f = new FailingFibAction(8);
317 <                        f.fork();
318 <                        f.get(5L, TimeUnit.SECONDS);
319 <                        shouldThrow();
320 <                    } catch (ExecutionException success) {
321 <                    } catch (Exception ex) {
322 <                        unexpectedException(ex);
337 <                    }
314 >            public void compute() {
315 >                try {
316 >                    FailingFibAction f = new FailingFibAction(8);
317 >                    f.fork();
318 >                    f.get(5L, TimeUnit.SECONDS);
319 >                    shouldThrow();
320 >                } catch (ExecutionException success) {
321 >                } catch (Exception ex) {
322 >                    unexpectedException(ex);
323                  }
324 <            };
324 >            }};
325          mainPool.invoke(a);
326      }
327  
# Line 345 | Line 330 | public class RecursiveActionTest extends
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) {
355 <                    }
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 <            };
341 >            }};
342          mainPool.invoke(a);
343      }
344  
# Line 366 | Line 350 | public class RecursiveActionTest extends
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 <                }
378 <            };
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  
# Line 384 | Line 367 | public class RecursiveActionTest extends
367       */
368      public void testAbnormalForkQuietlyJoin() {
369          RecursiveAction a = new RecursiveAction() {
370 <                public void compute() {
371 <                    FailingFibAction f = new FailingFibAction(8);
372 <                    f.fork();
373 <                    f.quietlyJoin();
374 <                    threadAssertTrue(f.isDone());
375 <                    threadAssertTrue(f.isCompletedAbnormally());
376 <                    threadAssertTrue(f.getException() instanceof FJException);
377 <                }
395 <            };
370 >            public void compute() {
371 >                FailingFibAction f = new FailingFibAction(8);
372 >                f.fork();
373 >                f.quietlyJoin();
374 >                threadAssertTrue(f.isDone());
375 >                threadAssertTrue(f.isCompletedAbnormally());
376 >                threadAssertTrue(f.getException() instanceof FJException);
377 >            }};
378          mainPool.invoke(a);
379      }
380  
# Line 401 | Line 383 | public class RecursiveActionTest extends
383       */
384      public void testCancelledInvoke() {
385          RecursiveAction a = new RecursiveAction() {
386 <                public void compute() {
387 <                    try {
388 <                        FibAction f = new FibAction(8);
389 <                        f.cancel(true);
390 <                        f.invoke();
391 <                        shouldThrow();
392 <                    } catch (CancellationException success) {
411 <                    }
386 >            public void compute() {
387 >                try {
388 >                    FibAction f = new FibAction(8);
389 >                    f.cancel(true);
390 >                    f.invoke();
391 >                    shouldThrow();
392 >                } catch (CancellationException success) {
393                  }
394 <            };
394 >            }};
395          mainPool.invoke(a);
396      }
397  
# Line 419 | Line 400 | public class RecursiveActionTest extends
400       */
401      public void testCancelledForkJoin() {
402          RecursiveAction a = new RecursiveAction() {
403 <                public void compute() {
404 <                    try {
405 <                        FibAction f = new FibAction(8);
406 <                        f.cancel(true);
407 <                        f.fork();
408 <                        f.join();
409 <                        shouldThrow();
410 <                    } catch (CancellationException success) {
430 <                    }
403 >            public void compute() {
404 >                try {
405 >                    FibAction f = new FibAction(8);
406 >                    f.cancel(true);
407 >                    f.fork();
408 >                    f.join();
409 >                    shouldThrow();
410 >                } catch (CancellationException success) {
411                  }
412 <            };
412 >            }};
413          mainPool.invoke(a);
414      }
415  
# Line 438 | Line 418 | public class RecursiveActionTest extends
418       */
419      public void testCancelledForkGet() {
420          RecursiveAction a = new RecursiveAction() {
421 <                public void compute() {
422 <                    try {
423 <                        FibAction f = new FibAction(8);
424 <                        f.cancel(true);
425 <                        f.fork();
426 <                        f.get();
427 <                        shouldThrow();
428 <                    } catch (CancellationException success) {
429 <                    } catch (Exception ex) {
430 <                        unexpectedException(ex);
451 <                    }
421 >            public void compute() {
422 >                try {
423 >                    FibAction f = new FibAction(8);
424 >                    f.cancel(true);
425 >                    f.fork();
426 >                    f.get();
427 >                    shouldThrow();
428 >                } catch (CancellationException success) {
429 >                } catch (Exception ex) {
430 >                    unexpectedException(ex);
431                  }
432 <            };
432 >            }};
433          mainPool.invoke(a);
434      }
435  
# Line 459 | Line 438 | public class RecursiveActionTest extends
438       */
439      public void testCancelledForkTimedGet() {
440          RecursiveAction a = new RecursiveAction() {
441 <                public void compute() {
442 <                    try {
443 <                        FibAction f = new FibAction(8);
444 <                        f.cancel(true);
445 <                        f.fork();
446 <                        f.get(5L, TimeUnit.SECONDS);
447 <                        shouldThrow();
448 <                    } catch (CancellationException success) {
449 <                    } catch (Exception ex) {
450 <                        unexpectedException(ex);
472 <                    }
441 >            public void compute() {
442 >                try {
443 >                    FibAction f = new FibAction(8);
444 >                    f.cancel(true);
445 >                    f.fork();
446 >                    f.get(5L, TimeUnit.SECONDS);
447 >                    shouldThrow();
448 >                } catch (CancellationException success) {
449 >                } catch (Exception ex) {
450 >                    unexpectedException(ex);
451                  }
452 <            };
452 >            }};
453          mainPool.invoke(a);
454      }
455  
# Line 480 | Line 458 | public class RecursiveActionTest extends
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) {
491 <                    }
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 <            };
470 >            }};
471          mainPool.invoke(a);
472      }
473  
# Line 502 | Line 479 | public class RecursiveActionTest extends
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 <                }
515 <            };
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      }
494  
# Line 521 | Line 497 | public class RecursiveActionTest extends
497       */
498      public void testCancelledForkQuietlyJoin() {
499          RecursiveAction a = new RecursiveAction() {
500 <                public void compute() {
501 <                    FibAction f = new FibAction(8);
502 <                    f.cancel(true);
503 <                    f.fork();
504 <                    f.quietlyJoin();
505 <                    threadAssertTrue(f.isDone());
506 <                    threadAssertTrue(f.isCompletedAbnormally());
507 <                    threadAssertTrue(f.getException() instanceof CancellationException);
508 <                }
533 <            };
500 >            public void compute() {
501 >                FibAction f = new FibAction(8);
502 >                f.cancel(true);
503 >                f.fork();
504 >                f.quietlyJoin();
505 >                threadAssertTrue(f.isDone());
506 >                threadAssertTrue(f.isCompletedAbnormally());
507 >                threadAssertTrue(f.getException() instanceof CancellationException);
508 >            }};
509          mainPool.invoke(a);
510      }
511  
# Line 539 | Line 514 | public class RecursiveActionTest extends
514       */
515      public void testGetPool() {
516          RecursiveAction a = new RecursiveAction() {
517 <                public void compute() {
518 <                    threadAssertTrue(getPool() == mainPool);
519 <                }
545 <            };
517 >            public void compute() {
518 >                threadAssertTrue(getPool() == mainPool);
519 >            }};
520          mainPool.invoke(a);
521      }
522  
# Line 551 | Line 525 | public class RecursiveActionTest extends
525       */
526      public void testGetPool2() {
527          RecursiveAction a = new RecursiveAction() {
528 <                public void compute() {
529 <                    threadAssertTrue(getPool() == null);
530 <                }
557 <            };
528 >            public void compute() {
529 >                threadAssertTrue(getPool() == null);
530 >            }};
531          a.invoke();
532      }
533  
# Line 563 | Line 536 | public class RecursiveActionTest extends
536       */
537      public void testInForkJoinPool() {
538          RecursiveAction a = new RecursiveAction() {
539 <                public void compute() {
540 <                    threadAssertTrue(inForkJoinPool());
541 <                }
569 <            };
539 >            public void compute() {
540 >                threadAssertTrue(inForkJoinPool());
541 >            }};
542          mainPool.invoke(a);
543      }
544  
# Line 575 | Line 547 | public class RecursiveActionTest extends
547       */
548      public void testInForkJoinPool2() {
549          RecursiveAction a = new RecursiveAction() {
550 <                public void compute() {
551 <                    threadAssertTrue(!inForkJoinPool());
552 <                }
581 <            };
550 >            public void compute() {
551 >                threadAssertTrue(!inForkJoinPool());
552 >            }};
553          a.invoke();
554      }
555  
# Line 587 | Line 558 | public class RecursiveActionTest extends
558       */
559      public void testWorkerGetPool() {
560          RecursiveAction a = new RecursiveAction() {
561 <                public void compute() {
562 <                    ForkJoinWorkerThread w =
563 <                        (ForkJoinWorkerThread)(Thread.currentThread());
564 <                    threadAssertTrue(w.getPool() == mainPool);
565 <                }
595 <            };
561 >            public void compute() {
562 >                ForkJoinWorkerThread w =
563 >                    (ForkJoinWorkerThread)(Thread.currentThread());
564 >                threadAssertTrue(w.getPool() == mainPool);
565 >            }};
566          mainPool.invoke(a);
567      }
568  
# Line 602 | Line 572 | public class RecursiveActionTest extends
572       */
573      public void testWorkerGetPoolIndex() {
574          RecursiveAction a = new RecursiveAction() {
575 <                public void compute() {
576 <                    ForkJoinWorkerThread w =
577 <                        (ForkJoinWorkerThread)(Thread.currentThread());
578 <                    int idx = w.getPoolIndex();
579 <                    threadAssertTrue(idx >= 0);
580 <                    threadAssertTrue(idx < mainPool.getPoolSize());
581 <                }
612 <            };
575 >            public void compute() {
576 >                ForkJoinWorkerThread w =
577 >                    (ForkJoinWorkerThread)(Thread.currentThread());
578 >                int idx = w.getPoolIndex();
579 >                threadAssertTrue(idx >= 0);
580 >                threadAssertTrue(idx < mainPool.getPoolSize());
581 >            }};
582          mainPool.invoke(a);
583      }
584  
# Line 619 | Line 588 | public class RecursiveActionTest extends
588       */
589      public void testSetRawResult() {
590          RecursiveAction a = new RecursiveAction() {
591 <                public void compute() {
592 <                    setRawResult(null);
593 <                }
625 <            };
591 >            public void compute() {
592 >                setRawResult(null);
593 >            }};
594          a.invoke();
595      }
596  
# Line 631 | Line 599 | public class RecursiveActionTest extends
599       */
600      public void testReinitialize() {
601          RecursiveAction a = new RecursiveAction() {
602 <                public void compute() {
603 <                    FibAction f = new FibAction(8);
604 <                    f.invoke();
605 <                    threadAssertTrue(f.result == 21);
606 <                    threadAssertTrue(f.isDone());
607 <                    threadAssertFalse(f.isCancelled());
608 <                    threadAssertFalse(f.isCompletedAbnormally());
609 <                    f.reinitialize();
610 <                    f.invoke();
611 <                    threadAssertTrue(f.result == 21);
612 <                }
645 <            };
602 >            public void compute() {
603 >                FibAction f = new FibAction(8);
604 >                f.invoke();
605 >                threadAssertTrue(f.result == 21);
606 >                threadAssertTrue(f.isDone());
607 >                threadAssertFalse(f.isCancelled());
608 >                threadAssertFalse(f.isCompletedAbnormally());
609 >                f.reinitialize();
610 >                f.invoke();
611 >                threadAssertTrue(f.result == 21);
612 >            }};
613          mainPool.invoke(a);
614      }
615  
# Line 651 | Line 618 | public class RecursiveActionTest extends
618       */
619      public void testCompleteExceptionally() {
620          RecursiveAction a = new RecursiveAction() {
621 <                public void compute() {
622 <                    try {
623 <                        FibAction f = new FibAction(8);
624 <                        f.completeExceptionally(new FJException());
625 <                        f.invoke();
626 <                        shouldThrow();
627 <                    } catch (FJException success) {
661 <                    }
621 >            public void compute() {
622 >                try {
623 >                    FibAction f = new FibAction(8);
624 >                    f.completeExceptionally(new FJException());
625 >                    f.invoke();
626 >                    shouldThrow();
627 >                } catch (FJException success) {
628                  }
629 <            };
629 >            }};
630          mainPool.invoke(a);
631      }
632  
# Line 669 | Line 635 | public class RecursiveActionTest extends
635       */
636      public void testComplete() {
637          RecursiveAction a = new RecursiveAction() {
638 <                public void compute() {
639 <                    FibAction f = new FibAction(8);
640 <                    f.complete(null);
641 <                    f.invoke();
642 <                    threadAssertTrue(f.isDone());
643 <                    threadAssertTrue(f.result == 0);
644 <                }
679 <            };
638 >            public void compute() {
639 >                FibAction f = new FibAction(8);
640 >                f.complete(null);
641 >                f.invoke();
642 >                threadAssertTrue(f.isDone());
643 >                threadAssertTrue(f.result == 0);
644 >            }};
645          mainPool.invoke(a);
646      }
647  
# Line 685 | Line 650 | public class RecursiveActionTest extends
650       */
651      public void testInvokeAll2() {
652          RecursiveAction a = new RecursiveAction() {
653 <                public void compute() {
654 <                    FibAction f = new FibAction(8);
655 <                    FibAction g = new FibAction(9);
656 <                    invokeAll(f, g);
657 <                    threadAssertTrue(f.isDone());
658 <                    threadAssertTrue(f.result == 21);
659 <                    threadAssertTrue(g.isDone());
660 <                    threadAssertTrue(g.result == 34);
661 <                }
697 <            };
653 >            public void compute() {
654 >                FibAction f = new FibAction(8);
655 >                FibAction g = new FibAction(9);
656 >                invokeAll(f, g);
657 >                threadAssertTrue(f.isDone());
658 >                threadAssertTrue(f.result == 21);
659 >                threadAssertTrue(g.isDone());
660 >                threadAssertTrue(g.result == 34);
661 >            }};
662          mainPool.invoke(a);
663      }
664  
# Line 703 | Line 667 | public class RecursiveActionTest extends
667       */
668      public void testInvokeAll1() {
669          RecursiveAction a = new RecursiveAction() {
670 <                public void compute() {
671 <                    FibAction f = new FibAction(8);
672 <                    invokeAll(f);
673 <                    threadAssertTrue(f.isDone());
674 <                    threadAssertTrue(f.result == 21);
675 <                }
712 <            };
670 >            public void compute() {
671 >                FibAction f = new FibAction(8);
672 >                invokeAll(f);
673 >                threadAssertTrue(f.isDone());
674 >                threadAssertTrue(f.result == 21);
675 >            }};
676          mainPool.invoke(a);
677      }
678  
# Line 718 | Line 681 | public class RecursiveActionTest extends
681       */
682      public void testInvokeAll3() {
683          RecursiveAction a = new RecursiveAction() {
684 <                public void compute() {
685 <                    FibAction f = new FibAction(8);
686 <                    FibAction g = new FibAction(9);
687 <                    FibAction h = new FibAction(7);
688 <                    invokeAll(f, g, h);
689 <                    threadAssertTrue(f.isDone());
690 <                    threadAssertTrue(f.result == 21);
691 <                    threadAssertTrue(g.isDone());
692 <                    threadAssertTrue(g.result == 34);
693 <                    threadAssertTrue(h.isDone());
694 <                    threadAssertTrue(h.result == 13);
695 <                }
733 <            };
684 >            public void compute() {
685 >                FibAction f = new FibAction(8);
686 >                FibAction g = new FibAction(9);
687 >                FibAction h = new FibAction(7);
688 >                invokeAll(f, g, h);
689 >                threadAssertTrue(f.isDone());
690 >                threadAssertTrue(f.result == 21);
691 >                threadAssertTrue(g.isDone());
692 >                threadAssertTrue(g.result == 34);
693 >                threadAssertTrue(h.isDone());
694 >                threadAssertTrue(h.result == 13);
695 >            }};
696          mainPool.invoke(a);
697      }
698  
# Line 739 | Line 701 | public class RecursiveActionTest extends
701       */
702      public void testInvokeAllCollection() {
703          RecursiveAction a = new RecursiveAction() {
704 <                public void compute() {
705 <                    FibAction f = new FibAction(8);
706 <                    FibAction g = new FibAction(9);
707 <                    FibAction h = new FibAction(7);
708 <                    HashSet set = new HashSet();
709 <                    set.add(f);
710 <                    set.add(g);
711 <                    set.add(h);
712 <                    invokeAll(set);
713 <                    threadAssertTrue(f.isDone());
714 <                    threadAssertTrue(f.result == 21);
715 <                    threadAssertTrue(g.isDone());
716 <                    threadAssertTrue(g.result == 34);
717 <                    threadAssertTrue(h.isDone());
718 <                    threadAssertTrue(h.result == 13);
719 <                }
758 <            };
704 >            public void compute() {
705 >                FibAction f = new FibAction(8);
706 >                FibAction g = new FibAction(9);
707 >                FibAction h = new FibAction(7);
708 >                HashSet set = new HashSet();
709 >                set.add(f);
710 >                set.add(g);
711 >                set.add(h);
712 >                invokeAll(set);
713 >                threadAssertTrue(f.isDone());
714 >                threadAssertTrue(f.result == 21);
715 >                threadAssertTrue(g.isDone());
716 >                threadAssertTrue(g.result == 34);
717 >                threadAssertTrue(h.isDone());
718 >                threadAssertTrue(h.result == 13);
719 >            }};
720          mainPool.invoke(a);
721      }
722  
# Line 765 | Line 726 | public class RecursiveActionTest extends
726       */
727      public void testInvokeAllNPE() {
728          RecursiveAction a = new RecursiveAction() {
729 <                public void compute() {
730 <                    try {
731 <                        FibAction f = new FibAction(8);
732 <                        FibAction g = new FibAction(9);
733 <                        FibAction h = null;
734 <                        invokeAll(f, g, h);
735 <                        shouldThrow();
736 <                    } catch (NullPointerException success) {
776 <                    }
729 >            public void compute() {
730 >                try {
731 >                    FibAction f = new FibAction(8);
732 >                    FibAction g = new FibAction(9);
733 >                    FibAction h = null;
734 >                    invokeAll(f, g, h);
735 >                    shouldThrow();
736 >                } catch (NullPointerException success) {
737                  }
738 <            };
738 >            }};
739          mainPool.invoke(a);
740      }
741  
# Line 784 | Line 744 | public class RecursiveActionTest extends
744       */
745      public void testAbnormalInvokeAll2() {
746          RecursiveAction a = new RecursiveAction() {
747 <                public void compute() {
748 <                    try {
749 <                        FibAction f = new FibAction(8);
750 <                        FailingFibAction g = new FailingFibAction(9);
751 <                        invokeAll(f, g);
752 <                        shouldThrow();
753 <                    } catch (FJException success) {
794 <                    }
747 >            public void compute() {
748 >                try {
749 >                    FibAction f = new FibAction(8);
750 >                    FailingFibAction g = new FailingFibAction(9);
751 >                    invokeAll(f, g);
752 >                    shouldThrow();
753 >                } catch (FJException success) {
754                  }
755 <            };
755 >            }};
756          mainPool.invoke(a);
757      }
758  
# Line 802 | Line 761 | public class RecursiveActionTest extends
761       */
762      public void testAbnormalInvokeAll1() {
763          RecursiveAction a = new RecursiveAction() {
764 <                public void compute() {
765 <                    try {
766 <                        FailingFibAction g = new FailingFibAction(9);
767 <                        invokeAll(g);
768 <                        shouldThrow();
769 <                    } catch (FJException success) {
811 <                    }
764 >            public void compute() {
765 >                try {
766 >                    FailingFibAction g = new FailingFibAction(9);
767 >                    invokeAll(g);
768 >                    shouldThrow();
769 >                } catch (FJException success) {
770                  }
771 <            };
771 >            }};
772          mainPool.invoke(a);
773      }
774  
# Line 819 | Line 777 | public class RecursiveActionTest extends
777       */
778      public void testAbnormalInvokeAll3() {
779          RecursiveAction a = new RecursiveAction() {
780 <                public void compute() {
781 <                    try {
782 <                        FibAction f = new FibAction(8);
783 <                        FailingFibAction g = new FailingFibAction(9);
784 <                        FibAction h = new FibAction(7);
785 <                        invokeAll(f, g, h);
786 <                        shouldThrow();
787 <                    } catch (FJException success) {
830 <                    }
780 >            public void compute() {
781 >                try {
782 >                    FibAction f = new FibAction(8);
783 >                    FailingFibAction g = new FailingFibAction(9);
784 >                    FibAction h = new FibAction(7);
785 >                    invokeAll(f, g, h);
786 >                    shouldThrow();
787 >                } catch (FJException success) {
788                  }
789 <            };
789 >            }};
790          mainPool.invoke(a);
791      }
792  
# Line 838 | Line 795 | public class RecursiveActionTest extends
795       */
796      public void testAbnormalInvokeAllCollection() {
797          RecursiveAction a = new RecursiveAction() {
798 <                public void compute() {
799 <                    try {
800 <                        FailingFibAction f = new FailingFibAction(8);
801 <                        FibAction g = new FibAction(9);
802 <                        FibAction h = new FibAction(7);
803 <                        HashSet set = new HashSet();
804 <                        set.add(f);
805 <                        set.add(g);
806 <                        set.add(h);
807 <                        invokeAll(set);
808 <                        shouldThrow();
809 <                    } catch (FJException success) {
853 <                    }
798 >            public void compute() {
799 >                try {
800 >                    FailingFibAction f = new FailingFibAction(8);
801 >                    FibAction g = new FibAction(9);
802 >                    FibAction h = new FibAction(7);
803 >                    HashSet set = new HashSet();
804 >                    set.add(f);
805 >                    set.add(g);
806 >                    set.add(h);
807 >                    invokeAll(set);
808 >                    shouldThrow();
809 >                } catch (FJException success) {
810                  }
811 <            };
811 >            }};
812          mainPool.invoke(a);
813      }
814  
# Line 862 | Line 818 | public class RecursiveActionTest extends
818       */
819      public void testTryUnfork() {
820          RecursiveAction a = new RecursiveAction() {
821 <                public void compute() {
822 <                    FibAction g = new FibAction(9);
823 <                    g.fork();
824 <                    FibAction f = new FibAction(8);
825 <                    f.fork();
826 <                    threadAssertTrue(f.tryUnfork());
827 <                    helpQuiesce();
828 <                    threadAssertFalse(f.isDone());
829 <                    threadAssertTrue(g.isDone());
830 <                }
875 <            };
821 >            public void compute() {
822 >                FibAction g = new FibAction(9);
823 >                g.fork();
824 >                FibAction f = new FibAction(8);
825 >                f.fork();
826 >                threadAssertTrue(f.tryUnfork());
827 >                helpQuiesce();
828 >                threadAssertFalse(f.isDone());
829 >                threadAssertTrue(g.isDone());
830 >            }};
831          singletonPool.invoke(a);
832      }
833  
# Line 882 | Line 837 | public class RecursiveActionTest extends
837       */
838      public void testGetSurplusQueuedTaskCount() {
839          RecursiveAction a = new RecursiveAction() {
840 <                public void compute() {
841 <                    FibAction h = new FibAction(7);
842 <                    h.fork();
843 <                    FibAction g = new FibAction(9);
844 <                    g.fork();
845 <                    FibAction f = new FibAction(8);
846 <                    f.fork();
847 <                    threadAssertTrue(getSurplusQueuedTaskCount() > 0);
848 <                    helpQuiesce();
849 <                }
895 <            };
840 >            public void compute() {
841 >                FibAction h = new FibAction(7);
842 >                h.fork();
843 >                FibAction g = new FibAction(9);
844 >                g.fork();
845 >                FibAction f = new FibAction(8);
846 >                f.fork();
847 >                threadAssertTrue(getSurplusQueuedTaskCount() > 0);
848 >                helpQuiesce();
849 >            }};
850          singletonPool.invoke(a);
851      }
852  
# Line 901 | Line 855 | public class RecursiveActionTest extends
855       */
856      public void testPeekNextLocalTask() {
857          RecursiveAction a = new RecursiveAction() {
858 <                public void compute() {
859 <                    FibAction g = new FibAction(9);
860 <                    g.fork();
861 <                    FibAction f = new FibAction(8);
862 <                    f.fork();
863 <                    threadAssertTrue(peekNextLocalTask() == f);
864 <                    f.join();
865 <                    threadAssertTrue(f.isDone());
866 <                    helpQuiesce();
867 <                }
914 <            };
858 >            public void compute() {
859 >                FibAction g = new FibAction(9);
860 >                g.fork();
861 >                FibAction f = new FibAction(8);
862 >                f.fork();
863 >                threadAssertTrue(peekNextLocalTask() == f);
864 >                f.join();
865 >                threadAssertTrue(f.isDone());
866 >                helpQuiesce();
867 >            }};
868          singletonPool.invoke(a);
869      }
870  
# Line 921 | Line 874 | public class RecursiveActionTest extends
874       */
875      public void testPollNextLocalTask() {
876          RecursiveAction a = new RecursiveAction() {
877 <                public void compute() {
878 <                    FibAction g = new FibAction(9);
879 <                    g.fork();
880 <                    FibAction f = new FibAction(8);
881 <                    f.fork();
882 <                    threadAssertTrue(pollNextLocalTask() == f);
883 <                    helpQuiesce();
884 <                    threadAssertFalse(f.isDone());
885 <                }
933 <            };
877 >            public void compute() {
878 >                FibAction g = new FibAction(9);
879 >                g.fork();
880 >                FibAction f = new FibAction(8);
881 >                f.fork();
882 >                threadAssertTrue(pollNextLocalTask() == f);
883 >                helpQuiesce();
884 >                threadAssertFalse(f.isDone());
885 >            }};
886          singletonPool.invoke(a);
887      }
888  
# Line 940 | Line 892 | public class RecursiveActionTest extends
892       */
893      public void testPollTask() {
894          RecursiveAction a = new RecursiveAction() {
895 <                public void compute() {
896 <                    FibAction g = new FibAction(9);
897 <                    g.fork();
898 <                    FibAction f = new FibAction(8);
899 <                    f.fork();
900 <                    threadAssertTrue(pollTask() == f);
901 <                    helpQuiesce();
902 <                    threadAssertFalse(f.isDone());
903 <                    threadAssertTrue(g.isDone());
904 <                }
953 <            };
895 >            public void compute() {
896 >                FibAction g = new FibAction(9);
897 >                g.fork();
898 >                FibAction f = new FibAction(8);
899 >                f.fork();
900 >                threadAssertTrue(pollTask() == f);
901 >                helpQuiesce();
902 >                threadAssertFalse(f.isDone());
903 >                threadAssertTrue(g.isDone());
904 >            }};
905          singletonPool.invoke(a);
906      }
907  
# Line 959 | Line 910 | public class RecursiveActionTest extends
910       */
911      public void testPeekNextLocalTaskAsync() {
912          RecursiveAction a = new RecursiveAction() {
913 <                public void compute() {
914 <                    FibAction g = new FibAction(9);
915 <                    g.fork();
916 <                    FibAction f = new FibAction(8);
917 <                    f.fork();
918 <                    threadAssertTrue(peekNextLocalTask() == g);
919 <                    f.join();
920 <                    helpQuiesce();
921 <                    threadAssertTrue(f.isDone());
922 <                }
972 <            };
913 >            public void compute() {
914 >                FibAction g = new FibAction(9);
915 >                g.fork();
916 >                FibAction f = new FibAction(8);
917 >                f.fork();
918 >                threadAssertTrue(peekNextLocalTask() == g);
919 >                f.join();
920 >                helpQuiesce();
921 >                threadAssertTrue(f.isDone());
922 >            }};
923          asyncSingletonPool.invoke(a);
924      }
925  
# Line 979 | Line 929 | public class RecursiveActionTest extends
929       */
930      public void testPollNextLocalTaskAsync() {
931          RecursiveAction a = new RecursiveAction() {
932 <                public void compute() {
933 <                    FibAction g = new FibAction(9);
934 <                    g.fork();
935 <                    FibAction f = new FibAction(8);
936 <                    f.fork();
937 <                    threadAssertTrue(pollNextLocalTask() == g);
938 <                    helpQuiesce();
939 <                    threadAssertTrue(f.isDone());
940 <                    threadAssertFalse(g.isDone());
941 <                }
992 <            };
932 >            public void compute() {
933 >                FibAction g = new FibAction(9);
934 >                g.fork();
935 >                FibAction f = new FibAction(8);
936 >                f.fork();
937 >                threadAssertTrue(pollNextLocalTask() == g);
938 >                helpQuiesce();
939 >                threadAssertTrue(f.isDone());
940 >                threadAssertFalse(g.isDone());
941 >            }};
942          asyncSingletonPool.invoke(a);
943      }
944  
# Line 999 | Line 948 | public class RecursiveActionTest extends
948       */
949      public void testPollTaskAsync() {
950          RecursiveAction a = new RecursiveAction() {
951 <                public void compute() {
952 <                    FibAction g = new FibAction(9);
953 <                    g.fork();
954 <                    FibAction f = new FibAction(8);
955 <                    f.fork();
956 <                    threadAssertTrue(pollTask() == g);
957 <                    helpQuiesce();
958 <                    threadAssertTrue(f.isDone());
959 <                    threadAssertFalse(g.isDone());
960 <                }
1012 <            };
951 >            public void compute() {
952 >                FibAction g = new FibAction(9);
953 >                g.fork();
954 >                FibAction f = new FibAction(8);
955 >                f.fork();
956 >                threadAssertTrue(pollTask() == g);
957 >                helpQuiesce();
958 >                threadAssertTrue(f.isDone());
959 >                threadAssertFalse(g.isDone());
960 >            }};
961          asyncSingletonPool.invoke(a);
962      }
963  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines