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 |
|
|
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 |
|
|
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 |
|
|
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(); |
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 |
|
|
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(); |
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 |
|
|
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(); |
173 |
> |
unexpectedException(ex); |
174 |
|
} |
175 |
|
} |
176 |
|
}; |
182 |
|
*/ |
183 |
|
public void testForkHelpJoin() { |
184 |
|
RecursiveAction a = new RecursiveAction() { |
185 |
< |
public void compute() { |
186 |
< |
FibAction f = new FibAction(8); |
187 |
< |
f.fork(); |
188 |
< |
f.helpJoin(); |
189 |
< |
threadAssertTrue(f.result == 21); |
190 |
< |
threadAssertTrue(f.isDone()); |
191 |
< |
} |
196 |
< |
}; |
185 |
> |
public void compute() { |
186 |
> |
FibAction f = new FibAction(8); |
187 |
> |
f.fork(); |
188 |
> |
f.helpJoin(); |
189 |
> |
threadAssertTrue(f.result == 21); |
190 |
> |
threadAssertTrue(f.isDone()); |
191 |
> |
}}; |
192 |
|
mainPool.invoke(a); |
193 |
|
} |
194 |
|
|
197 |
|
*/ |
198 |
|
public void testForkQuietlyJoin() { |
199 |
|
RecursiveAction a = new RecursiveAction() { |
200 |
< |
public void compute() { |
201 |
< |
FibAction f = new FibAction(8); |
202 |
< |
f.fork(); |
203 |
< |
f.quietlyJoin(); |
204 |
< |
threadAssertTrue(f.result == 21); |
205 |
< |
threadAssertTrue(f.isDone()); |
206 |
< |
} |
212 |
< |
}; |
200 |
> |
public void compute() { |
201 |
> |
FibAction f = new FibAction(8); |
202 |
> |
f.fork(); |
203 |
> |
f.quietlyJoin(); |
204 |
> |
threadAssertTrue(f.result == 21); |
205 |
> |
threadAssertTrue(f.isDone()); |
206 |
> |
}}; |
207 |
|
mainPool.invoke(a); |
208 |
|
} |
209 |
|
|
213 |
|
*/ |
214 |
|
public void testForkQuietlyHelpJoin() { |
215 |
|
RecursiveAction a = new RecursiveAction() { |
216 |
< |
public void compute() { |
217 |
< |
FibAction f = new FibAction(8); |
218 |
< |
f.fork(); |
219 |
< |
f.quietlyHelpJoin(); |
220 |
< |
threadAssertTrue(f.result == 21); |
221 |
< |
threadAssertTrue(f.isDone()); |
222 |
< |
} |
229 |
< |
}; |
216 |
> |
public void compute() { |
217 |
> |
FibAction f = new FibAction(8); |
218 |
> |
f.fork(); |
219 |
> |
f.quietlyHelpJoin(); |
220 |
> |
threadAssertTrue(f.result == 21); |
221 |
> |
threadAssertTrue(f.isDone()); |
222 |
> |
}}; |
223 |
|
mainPool.invoke(a); |
224 |
|
} |
225 |
|
|
230 |
|
*/ |
231 |
|
public void testForkHelpQuiesce() { |
232 |
|
RecursiveAction a = new RecursiveAction() { |
233 |
< |
public void compute() { |
234 |
< |
FibAction f = new FibAction(8); |
235 |
< |
f.fork(); |
236 |
< |
f.helpQuiesce(); |
237 |
< |
threadAssertTrue(f.result == 21); |
238 |
< |
threadAssertTrue(f.isDone()); |
239 |
< |
threadAssertTrue(getQueuedTaskCount() == 0); |
240 |
< |
} |
248 |
< |
}; |
233 |
> |
public void compute() { |
234 |
> |
FibAction f = new FibAction(8); |
235 |
> |
f.fork(); |
236 |
> |
f.helpQuiesce(); |
237 |
> |
threadAssertTrue(f.result == 21); |
238 |
> |
threadAssertTrue(f.isDone()); |
239 |
> |
threadAssertTrue(getQueuedTaskCount() == 0); |
240 |
> |
}}; |
241 |
|
mainPool.invoke(a); |
242 |
|
} |
243 |
|
|
247 |
|
*/ |
248 |
|
public void testAbnormalInvoke() { |
249 |
|
RecursiveAction a = new RecursiveAction() { |
250 |
< |
public void compute() { |
251 |
< |
try { |
252 |
< |
FailingFibAction f = new FailingFibAction(8); |
253 |
< |
f.invoke(); |
254 |
< |
shouldThrow(); |
255 |
< |
} catch (FJException success) { |
264 |
< |
} |
250 |
> |
public void compute() { |
251 |
> |
try { |
252 |
> |
FailingFibAction f = new FailingFibAction(8); |
253 |
> |
f.invoke(); |
254 |
> |
shouldThrow(); |
255 |
> |
} catch (FJException success) { |
256 |
|
} |
257 |
< |
}; |
257 |
> |
}}; |
258 |
|
mainPool.invoke(a); |
259 |
|
} |
260 |
|
|
261 |
|
/** |
262 |
< |
* quietelyInvoke task returns when task completes abnormally |
262 |
> |
* quietlyInvoke task returns when task completes abnormally |
263 |
|
*/ |
264 |
|
public void testAbnormalQuietlyInvoke() { |
265 |
|
RecursiveAction a = new RecursiveAction() { |
266 |
< |
public void compute() { |
267 |
< |
FailingFibAction f = new FailingFibAction(8); |
268 |
< |
f.quietlyInvoke(); |
269 |
< |
threadAssertTrue(f.isDone()); |
270 |
< |
} |
280 |
< |
}; |
266 |
> |
public void compute() { |
267 |
> |
FailingFibAction f = new FailingFibAction(8); |
268 |
> |
f.quietlyInvoke(); |
269 |
> |
threadAssertTrue(f.isDone()); |
270 |
> |
}}; |
271 |
|
mainPool.invoke(a); |
272 |
|
} |
273 |
|
|
276 |
|
*/ |
277 |
|
public void testAbnormalForkJoin() { |
278 |
|
RecursiveAction a = new RecursiveAction() { |
279 |
< |
public void compute() { |
280 |
< |
try { |
281 |
< |
FailingFibAction f = new FailingFibAction(8); |
282 |
< |
f.fork(); |
283 |
< |
f.join(); |
284 |
< |
shouldThrow(); |
285 |
< |
} catch (FJException success) { |
296 |
< |
} |
279 |
> |
public void compute() { |
280 |
> |
try { |
281 |
> |
FailingFibAction f = new FailingFibAction(8); |
282 |
> |
f.fork(); |
283 |
> |
f.join(); |
284 |
> |
shouldThrow(); |
285 |
> |
} catch (FJException success) { |
286 |
|
} |
287 |
< |
}; |
287 |
> |
}}; |
288 |
|
mainPool.invoke(a); |
289 |
|
} |
290 |
|
|
293 |
|
*/ |
294 |
|
public void testAbnormalForkGet() { |
295 |
|
RecursiveAction a = new RecursiveAction() { |
296 |
< |
public void compute() { |
297 |
< |
try { |
298 |
< |
FailingFibAction f = new FailingFibAction(8); |
299 |
< |
f.fork(); |
300 |
< |
f.get(); |
301 |
< |
shouldThrow(); |
302 |
< |
} catch (Exception success) { |
303 |
< |
} |
296 |
> |
public void compute() { |
297 |
> |
try { |
298 |
> |
FailingFibAction f = new FailingFibAction(8); |
299 |
> |
f.fork(); |
300 |
> |
f.get(); |
301 |
> |
shouldThrow(); |
302 |
> |
} catch (ExecutionException success) { |
303 |
> |
} catch (Exception ex) { |
304 |
> |
unexpectedException(ex); |
305 |
|
} |
306 |
< |
}; |
306 |
> |
}}; |
307 |
|
mainPool.invoke(a); |
308 |
|
} |
309 |
|
|
312 |
|
*/ |
313 |
|
public void testAbnormalForkTimedGet() { |
314 |
|
RecursiveAction a = new RecursiveAction() { |
315 |
< |
public void compute() { |
316 |
< |
try { |
317 |
< |
FailingFibAction f = new FailingFibAction(8); |
318 |
< |
f.fork(); |
319 |
< |
f.get(5L, TimeUnit.SECONDS); |
320 |
< |
shouldThrow(); |
321 |
< |
} catch (Exception success) { |
322 |
< |
} |
315 |
> |
public void compute() { |
316 |
> |
try { |
317 |
> |
FailingFibAction f = new FailingFibAction(8); |
318 |
> |
f.fork(); |
319 |
> |
f.get(5L, TimeUnit.SECONDS); |
320 |
> |
shouldThrow(); |
321 |
> |
} catch (ExecutionException success) { |
322 |
> |
} catch (Exception ex) { |
323 |
> |
unexpectedException(ex); |
324 |
|
} |
325 |
< |
}; |
325 |
> |
}}; |
326 |
|
mainPool.invoke(a); |
327 |
|
} |
328 |
|
|
331 |
|
*/ |
332 |
|
public void testAbnormalForkHelpJoin() { |
333 |
|
RecursiveAction a = new RecursiveAction() { |
334 |
< |
public void compute() { |
335 |
< |
try { |
336 |
< |
FailingFibAction f = new FailingFibAction(8); |
337 |
< |
f.fork(); |
338 |
< |
f.helpJoin(); |
339 |
< |
shouldThrow(); |
340 |
< |
} catch (FJException success) { |
350 |
< |
} |
334 |
> |
public void compute() { |
335 |
> |
try { |
336 |
> |
FailingFibAction f = new FailingFibAction(8); |
337 |
> |
f.fork(); |
338 |
> |
f.helpJoin(); |
339 |
> |
shouldThrow(); |
340 |
> |
} catch (FJException success) { |
341 |
|
} |
342 |
< |
}; |
342 |
> |
}}; |
343 |
|
mainPool.invoke(a); |
344 |
|
} |
345 |
|
|
351 |
|
*/ |
352 |
|
public void testAbnormalForkQuietlyHelpJoin() { |
353 |
|
RecursiveAction a = new RecursiveAction() { |
354 |
< |
public void compute() { |
355 |
< |
FailingFibAction f = new FailingFibAction(8); |
356 |
< |
f.fork(); |
357 |
< |
f.quietlyHelpJoin(); |
358 |
< |
threadAssertTrue(f.isDone()); |
359 |
< |
threadAssertTrue(f.isCompletedAbnormally()); |
360 |
< |
threadAssertFalse(f.isCancelled()); |
361 |
< |
threadAssertTrue(f.getException() instanceof FJException); |
362 |
< |
} |
373 |
< |
}; |
354 |
> |
public void compute() { |
355 |
> |
FailingFibAction f = new FailingFibAction(8); |
356 |
> |
f.fork(); |
357 |
> |
f.quietlyHelpJoin(); |
358 |
> |
threadAssertTrue(f.isDone()); |
359 |
> |
threadAssertTrue(f.isCompletedAbnormally()); |
360 |
> |
threadAssertFalse(f.isCancelled()); |
361 |
> |
threadAssertTrue(f.getException() instanceof FJException); |
362 |
> |
}}; |
363 |
|
mainPool.invoke(a); |
364 |
|
} |
365 |
|
|
368 |
|
*/ |
369 |
|
public void testAbnormalForkQuietlyJoin() { |
370 |
|
RecursiveAction a = new RecursiveAction() { |
371 |
< |
public void compute() { |
372 |
< |
FailingFibAction f = new FailingFibAction(8); |
373 |
< |
f.fork(); |
374 |
< |
f.quietlyJoin(); |
375 |
< |
threadAssertTrue(f.isDone()); |
376 |
< |
threadAssertTrue(f.isCompletedAbnormally()); |
377 |
< |
threadAssertTrue(f.getException() instanceof FJException); |
378 |
< |
} |
390 |
< |
}; |
371 |
> |
public void compute() { |
372 |
> |
FailingFibAction f = new FailingFibAction(8); |
373 |
> |
f.fork(); |
374 |
> |
f.quietlyJoin(); |
375 |
> |
threadAssertTrue(f.isDone()); |
376 |
> |
threadAssertTrue(f.isCompletedAbnormally()); |
377 |
> |
threadAssertTrue(f.getException() instanceof FJException); |
378 |
> |
}}; |
379 |
|
mainPool.invoke(a); |
380 |
|
} |
381 |
|
|
384 |
|
*/ |
385 |
|
public void testCancelledInvoke() { |
386 |
|
RecursiveAction a = new RecursiveAction() { |
387 |
< |
public void compute() { |
388 |
< |
try { |
389 |
< |
FibAction f = new FibAction(8); |
390 |
< |
f.cancel(true); |
391 |
< |
f.invoke(); |
392 |
< |
shouldThrow(); |
393 |
< |
} catch (CancellationException success) { |
406 |
< |
} |
387 |
> |
public void compute() { |
388 |
> |
try { |
389 |
> |
FibAction f = new FibAction(8); |
390 |
> |
f.cancel(true); |
391 |
> |
f.invoke(); |
392 |
> |
shouldThrow(); |
393 |
> |
} catch (CancellationException success) { |
394 |
|
} |
395 |
< |
}; |
395 |
> |
}}; |
396 |
|
mainPool.invoke(a); |
397 |
|
} |
398 |
|
|
401 |
|
*/ |
402 |
|
public void testCancelledForkJoin() { |
403 |
|
RecursiveAction a = new RecursiveAction() { |
404 |
< |
public void compute() { |
405 |
< |
try { |
406 |
< |
FibAction f = new FibAction(8); |
407 |
< |
f.cancel(true); |
408 |
< |
f.fork(); |
409 |
< |
f.join(); |
410 |
< |
shouldThrow(); |
411 |
< |
} catch (CancellationException success) { |
425 |
< |
} |
404 |
> |
public void compute() { |
405 |
> |
try { |
406 |
> |
FibAction f = new FibAction(8); |
407 |
> |
f.cancel(true); |
408 |
> |
f.fork(); |
409 |
> |
f.join(); |
410 |
> |
shouldThrow(); |
411 |
> |
} catch (CancellationException success) { |
412 |
|
} |
413 |
< |
}; |
413 |
> |
}}; |
414 |
|
mainPool.invoke(a); |
415 |
|
} |
416 |
|
|
419 |
|
*/ |
420 |
|
public void testCancelledForkGet() { |
421 |
|
RecursiveAction a = new RecursiveAction() { |
422 |
< |
public void compute() { |
423 |
< |
try { |
424 |
< |
FibAction f = new FibAction(8); |
425 |
< |
f.cancel(true); |
426 |
< |
f.fork(); |
427 |
< |
f.get(); |
428 |
< |
shouldThrow(); |
429 |
< |
} catch (Exception success) { |
430 |
< |
} |
422 |
> |
public void compute() { |
423 |
> |
try { |
424 |
> |
FibAction f = new FibAction(8); |
425 |
> |
f.cancel(true); |
426 |
> |
f.fork(); |
427 |
> |
f.get(); |
428 |
> |
shouldThrow(); |
429 |
> |
} catch (CancellationException success) { |
430 |
> |
} catch (Exception ex) { |
431 |
> |
unexpectedException(ex); |
432 |
|
} |
433 |
< |
}; |
433 |
> |
}}; |
434 |
|
mainPool.invoke(a); |
435 |
|
} |
436 |
|
|
439 |
|
*/ |
440 |
|
public void testCancelledForkTimedGet() { |
441 |
|
RecursiveAction a = new RecursiveAction() { |
442 |
< |
public void compute() { |
443 |
< |
try { |
444 |
< |
FibAction f = new FibAction(8); |
445 |
< |
f.cancel(true); |
446 |
< |
f.fork(); |
447 |
< |
f.get(5L, TimeUnit.SECONDS); |
448 |
< |
shouldThrow(); |
449 |
< |
} catch (Exception success) { |
450 |
< |
} |
442 |
> |
public void compute() { |
443 |
> |
try { |
444 |
> |
FibAction f = new FibAction(8); |
445 |
> |
f.cancel(true); |
446 |
> |
f.fork(); |
447 |
> |
f.get(5L, TimeUnit.SECONDS); |
448 |
> |
shouldThrow(); |
449 |
> |
} catch (CancellationException success) { |
450 |
> |
} catch (Exception ex) { |
451 |
> |
unexpectedException(ex); |
452 |
|
} |
453 |
< |
}; |
453 |
> |
}}; |
454 |
|
mainPool.invoke(a); |
455 |
|
} |
456 |
|
|
459 |
|
*/ |
460 |
|
public void testCancelledForkHelpJoin() { |
461 |
|
RecursiveAction a = new RecursiveAction() { |
462 |
< |
public void compute() { |
463 |
< |
try { |
464 |
< |
FibAction f = new FibAction(8); |
465 |
< |
f.cancel(true); |
466 |
< |
f.fork(); |
467 |
< |
f.helpJoin(); |
468 |
< |
shouldThrow(); |
469 |
< |
} catch (CancellationException success) { |
482 |
< |
} |
462 |
> |
public void compute() { |
463 |
> |
try { |
464 |
> |
FibAction f = new FibAction(8); |
465 |
> |
f.cancel(true); |
466 |
> |
f.fork(); |
467 |
> |
f.helpJoin(); |
468 |
> |
shouldThrow(); |
469 |
> |
} catch (CancellationException success) { |
470 |
|
} |
471 |
< |
}; |
471 |
> |
}}; |
472 |
|
mainPool.invoke(a); |
473 |
|
} |
474 |
|
|
480 |
|
*/ |
481 |
|
public void testCancelledForkQuietlyHelpJoin() { |
482 |
|
RecursiveAction a = new RecursiveAction() { |
483 |
< |
public void compute() { |
484 |
< |
FibAction f = new FibAction(8); |
485 |
< |
f.cancel(true); |
486 |
< |
f.fork(); |
487 |
< |
f.quietlyHelpJoin(); |
488 |
< |
threadAssertTrue(f.isDone()); |
489 |
< |
threadAssertTrue(f.isCompletedAbnormally()); |
490 |
< |
threadAssertTrue(f.isCancelled()); |
491 |
< |
threadAssertTrue(f.getException() instanceof CancellationException); |
492 |
< |
} |
506 |
< |
}; |
483 |
> |
public void compute() { |
484 |
> |
FibAction f = new FibAction(8); |
485 |
> |
f.cancel(true); |
486 |
> |
f.fork(); |
487 |
> |
f.quietlyHelpJoin(); |
488 |
> |
threadAssertTrue(f.isDone()); |
489 |
> |
threadAssertTrue(f.isCompletedAbnormally()); |
490 |
> |
threadAssertTrue(f.isCancelled()); |
491 |
> |
threadAssertTrue(f.getException() instanceof CancellationException); |
492 |
> |
}}; |
493 |
|
mainPool.invoke(a); |
494 |
|
} |
495 |
|
|
498 |
|
*/ |
499 |
|
public void testCancelledForkQuietlyJoin() { |
500 |
|
RecursiveAction a = new RecursiveAction() { |
501 |
< |
public void compute() { |
502 |
< |
FibAction f = new FibAction(8); |
503 |
< |
f.cancel(true); |
504 |
< |
f.fork(); |
505 |
< |
f.quietlyJoin(); |
506 |
< |
threadAssertTrue(f.isDone()); |
507 |
< |
threadAssertTrue(f.isCompletedAbnormally()); |
508 |
< |
threadAssertTrue(f.getException() instanceof CancellationException); |
509 |
< |
} |
524 |
< |
}; |
501 |
> |
public void compute() { |
502 |
> |
FibAction f = new FibAction(8); |
503 |
> |
f.cancel(true); |
504 |
> |
f.fork(); |
505 |
> |
f.quietlyJoin(); |
506 |
> |
threadAssertTrue(f.isDone()); |
507 |
> |
threadAssertTrue(f.isCompletedAbnormally()); |
508 |
> |
threadAssertTrue(f.getException() instanceof CancellationException); |
509 |
> |
}}; |
510 |
|
mainPool.invoke(a); |
511 |
|
} |
512 |
|
|
515 |
|
*/ |
516 |
|
public void testGetPool() { |
517 |
|
RecursiveAction a = new RecursiveAction() { |
518 |
< |
public void compute() { |
519 |
< |
threadAssertTrue(getPool() == mainPool); |
520 |
< |
} |
536 |
< |
}; |
518 |
> |
public void compute() { |
519 |
> |
threadAssertTrue(getPool() == mainPool); |
520 |
> |
}}; |
521 |
|
mainPool.invoke(a); |
522 |
|
} |
523 |
|
|
526 |
|
*/ |
527 |
|
public void testGetPool2() { |
528 |
|
RecursiveAction a = new RecursiveAction() { |
529 |
< |
public void compute() { |
530 |
< |
threadAssertTrue(getPool() == null); |
531 |
< |
} |
548 |
< |
}; |
529 |
> |
public void compute() { |
530 |
> |
threadAssertTrue(getPool() == null); |
531 |
> |
}}; |
532 |
|
a.invoke(); |
533 |
|
} |
534 |
|
|
537 |
|
*/ |
538 |
|
public void testInForkJoinPool() { |
539 |
|
RecursiveAction a = new RecursiveAction() { |
540 |
< |
public void compute() { |
541 |
< |
threadAssertTrue(inForkJoinPool()); |
542 |
< |
} |
560 |
< |
}; |
540 |
> |
public void compute() { |
541 |
> |
threadAssertTrue(inForkJoinPool()); |
542 |
> |
}}; |
543 |
|
mainPool.invoke(a); |
544 |
|
} |
545 |
|
|
548 |
|
*/ |
549 |
|
public void testInForkJoinPool2() { |
550 |
|
RecursiveAction a = new RecursiveAction() { |
551 |
< |
public void compute() { |
552 |
< |
threadAssertTrue(!inForkJoinPool()); |
553 |
< |
} |
572 |
< |
}; |
551 |
> |
public void compute() { |
552 |
> |
threadAssertTrue(!inForkJoinPool()); |
553 |
> |
}}; |
554 |
|
a.invoke(); |
555 |
|
} |
556 |
|
|
559 |
|
*/ |
560 |
|
public void testWorkerGetPool() { |
561 |
|
RecursiveAction a = new RecursiveAction() { |
562 |
< |
public void compute() { |
563 |
< |
ForkJoinWorkerThread w = |
564 |
< |
(ForkJoinWorkerThread)(Thread.currentThread()); |
565 |
< |
threadAssertTrue(w.getPool() == mainPool); |
566 |
< |
} |
586 |
< |
}; |
562 |
> |
public void compute() { |
563 |
> |
ForkJoinWorkerThread w = |
564 |
> |
(ForkJoinWorkerThread)(Thread.currentThread()); |
565 |
> |
threadAssertTrue(w.getPool() == mainPool); |
566 |
> |
}}; |
567 |
|
mainPool.invoke(a); |
568 |
|
} |
569 |
|
|
573 |
|
*/ |
574 |
|
public void testWorkerGetPoolIndex() { |
575 |
|
RecursiveAction a = new RecursiveAction() { |
576 |
< |
public void compute() { |
577 |
< |
ForkJoinWorkerThread w = |
578 |
< |
(ForkJoinWorkerThread)(Thread.currentThread()); |
579 |
< |
int idx = w.getPoolIndex(); |
580 |
< |
threadAssertTrue(idx >= 0); |
581 |
< |
threadAssertTrue(idx < mainPool.getPoolSize()); |
582 |
< |
} |
603 |
< |
}; |
576 |
> |
public void compute() { |
577 |
> |
ForkJoinWorkerThread w = |
578 |
> |
(ForkJoinWorkerThread)(Thread.currentThread()); |
579 |
> |
int idx = w.getPoolIndex(); |
580 |
> |
threadAssertTrue(idx >= 0); |
581 |
> |
threadAssertTrue(idx < mainPool.getPoolSize()); |
582 |
> |
}}; |
583 |
|
mainPool.invoke(a); |
584 |
|
} |
585 |
|
|
589 |
|
*/ |
590 |
|
public void testSetRawResult() { |
591 |
|
RecursiveAction a = new RecursiveAction() { |
592 |
< |
public void compute() { |
593 |
< |
setRawResult(null); |
594 |
< |
} |
616 |
< |
}; |
592 |
> |
public void compute() { |
593 |
> |
setRawResult(null); |
594 |
> |
}}; |
595 |
|
a.invoke(); |
596 |
|
} |
597 |
|
|
600 |
|
*/ |
601 |
|
public void testReinitialize() { |
602 |
|
RecursiveAction a = new RecursiveAction() { |
603 |
< |
public void compute() { |
604 |
< |
FibAction f = new FibAction(8); |
605 |
< |
f.invoke(); |
606 |
< |
threadAssertTrue(f.result == 21); |
607 |
< |
threadAssertTrue(f.isDone()); |
608 |
< |
threadAssertFalse(f.isCancelled()); |
609 |
< |
threadAssertFalse(f.isCompletedAbnormally()); |
610 |
< |
f.reinitialize(); |
611 |
< |
f.invoke(); |
612 |
< |
threadAssertTrue(f.result == 21); |
613 |
< |
} |
636 |
< |
}; |
603 |
> |
public void compute() { |
604 |
> |
FibAction f = new FibAction(8); |
605 |
> |
f.invoke(); |
606 |
> |
threadAssertTrue(f.result == 21); |
607 |
> |
threadAssertTrue(f.isDone()); |
608 |
> |
threadAssertFalse(f.isCancelled()); |
609 |
> |
threadAssertFalse(f.isCompletedAbnormally()); |
610 |
> |
f.reinitialize(); |
611 |
> |
f.invoke(); |
612 |
> |
threadAssertTrue(f.result == 21); |
613 |
> |
}}; |
614 |
|
mainPool.invoke(a); |
615 |
|
} |
616 |
|
|
619 |
|
*/ |
620 |
|
public void testCompleteExceptionally() { |
621 |
|
RecursiveAction a = new RecursiveAction() { |
622 |
< |
public void compute() { |
623 |
< |
try { |
624 |
< |
FibAction f = new FibAction(8); |
625 |
< |
f.completeExceptionally(new FJException()); |
626 |
< |
f.invoke(); |
627 |
< |
shouldThrow(); |
628 |
< |
} catch (FJException success) { |
652 |
< |
} |
622 |
> |
public void compute() { |
623 |
> |
try { |
624 |
> |
FibAction f = new FibAction(8); |
625 |
> |
f.completeExceptionally(new FJException()); |
626 |
> |
f.invoke(); |
627 |
> |
shouldThrow(); |
628 |
> |
} catch (FJException success) { |
629 |
|
} |
630 |
< |
}; |
630 |
> |
}}; |
631 |
|
mainPool.invoke(a); |
632 |
|
} |
633 |
|
|
636 |
|
*/ |
637 |
|
public void testComplete() { |
638 |
|
RecursiveAction a = new RecursiveAction() { |
639 |
< |
public void compute() { |
640 |
< |
FibAction f = new FibAction(8); |
641 |
< |
f.complete(null); |
642 |
< |
f.invoke(); |
643 |
< |
threadAssertTrue(f.isDone()); |
644 |
< |
threadAssertTrue(f.result == 0); |
645 |
< |
} |
670 |
< |
}; |
639 |
> |
public void compute() { |
640 |
> |
FibAction f = new FibAction(8); |
641 |
> |
f.complete(null); |
642 |
> |
f.invoke(); |
643 |
> |
threadAssertTrue(f.isDone()); |
644 |
> |
threadAssertTrue(f.result == 0); |
645 |
> |
}}; |
646 |
|
mainPool.invoke(a); |
647 |
|
} |
648 |
|
|
651 |
|
*/ |
652 |
|
public void testInvokeAll2() { |
653 |
|
RecursiveAction a = new RecursiveAction() { |
654 |
< |
public void compute() { |
655 |
< |
FibAction f = new FibAction(8); |
656 |
< |
FibAction g = new FibAction(9); |
657 |
< |
invokeAll(f, g); |
658 |
< |
threadAssertTrue(f.isDone()); |
659 |
< |
threadAssertTrue(f.result == 21); |
660 |
< |
threadAssertTrue(g.isDone()); |
661 |
< |
threadAssertTrue(g.result == 34); |
662 |
< |
} |
688 |
< |
}; |
654 |
> |
public void compute() { |
655 |
> |
FibAction f = new FibAction(8); |
656 |
> |
FibAction g = new FibAction(9); |
657 |
> |
invokeAll(f, g); |
658 |
> |
threadAssertTrue(f.isDone()); |
659 |
> |
threadAssertTrue(f.result == 21); |
660 |
> |
threadAssertTrue(g.isDone()); |
661 |
> |
threadAssertTrue(g.result == 34); |
662 |
> |
}}; |
663 |
|
mainPool.invoke(a); |
664 |
|
} |
665 |
|
|
668 |
|
*/ |
669 |
|
public void testInvokeAll1() { |
670 |
|
RecursiveAction a = new RecursiveAction() { |
671 |
< |
public void compute() { |
672 |
< |
FibAction f = new FibAction(8); |
673 |
< |
invokeAll(f); |
674 |
< |
threadAssertTrue(f.isDone()); |
675 |
< |
threadAssertTrue(f.result == 21); |
676 |
< |
} |
703 |
< |
}; |
671 |
> |
public void compute() { |
672 |
> |
FibAction f = new FibAction(8); |
673 |
> |
invokeAll(f); |
674 |
> |
threadAssertTrue(f.isDone()); |
675 |
> |
threadAssertTrue(f.result == 21); |
676 |
> |
}}; |
677 |
|
mainPool.invoke(a); |
678 |
|
} |
679 |
|
|
682 |
|
*/ |
683 |
|
public void testInvokeAll3() { |
684 |
|
RecursiveAction a = new RecursiveAction() { |
685 |
< |
public void compute() { |
686 |
< |
FibAction f = new FibAction(8); |
687 |
< |
FibAction g = new FibAction(9); |
688 |
< |
FibAction h = new FibAction(7); |
689 |
< |
invokeAll(f, g, h); |
690 |
< |
threadAssertTrue(f.isDone()); |
691 |
< |
threadAssertTrue(f.result == 21); |
692 |
< |
threadAssertTrue(g.isDone()); |
693 |
< |
threadAssertTrue(g.result == 34); |
694 |
< |
threadAssertTrue(h.isDone()); |
695 |
< |
threadAssertTrue(h.result == 13); |
696 |
< |
} |
724 |
< |
}; |
685 |
> |
public void compute() { |
686 |
> |
FibAction f = new FibAction(8); |
687 |
> |
FibAction g = new FibAction(9); |
688 |
> |
FibAction h = new FibAction(7); |
689 |
> |
invokeAll(f, g, h); |
690 |
> |
threadAssertTrue(f.isDone()); |
691 |
> |
threadAssertTrue(f.result == 21); |
692 |
> |
threadAssertTrue(g.isDone()); |
693 |
> |
threadAssertTrue(g.result == 34); |
694 |
> |
threadAssertTrue(h.isDone()); |
695 |
> |
threadAssertTrue(h.result == 13); |
696 |
> |
}}; |
697 |
|
mainPool.invoke(a); |
698 |
|
} |
699 |
|
|
702 |
|
*/ |
703 |
|
public void testInvokeAllCollection() { |
704 |
|
RecursiveAction a = new RecursiveAction() { |
705 |
< |
public void compute() { |
706 |
< |
FibAction f = new FibAction(8); |
707 |
< |
FibAction g = new FibAction(9); |
708 |
< |
FibAction h = new FibAction(7); |
709 |
< |
HashSet set = new HashSet(); |
710 |
< |
set.add(f); |
711 |
< |
set.add(g); |
712 |
< |
set.add(h); |
713 |
< |
invokeAll(set); |
714 |
< |
threadAssertTrue(f.isDone()); |
715 |
< |
threadAssertTrue(f.result == 21); |
716 |
< |
threadAssertTrue(g.isDone()); |
717 |
< |
threadAssertTrue(g.result == 34); |
718 |
< |
threadAssertTrue(h.isDone()); |
719 |
< |
threadAssertTrue(h.result == 13); |
720 |
< |
} |
749 |
< |
}; |
705 |
> |
public void compute() { |
706 |
> |
FibAction f = new FibAction(8); |
707 |
> |
FibAction g = new FibAction(9); |
708 |
> |
FibAction h = new FibAction(7); |
709 |
> |
HashSet set = new HashSet(); |
710 |
> |
set.add(f); |
711 |
> |
set.add(g); |
712 |
> |
set.add(h); |
713 |
> |
invokeAll(set); |
714 |
> |
threadAssertTrue(f.isDone()); |
715 |
> |
threadAssertTrue(f.result == 21); |
716 |
> |
threadAssertTrue(g.isDone()); |
717 |
> |
threadAssertTrue(g.result == 34); |
718 |
> |
threadAssertTrue(h.isDone()); |
719 |
> |
threadAssertTrue(h.result == 13); |
720 |
> |
}}; |
721 |
|
mainPool.invoke(a); |
722 |
|
} |
723 |
|
|
727 |
|
*/ |
728 |
|
public void testInvokeAllNPE() { |
729 |
|
RecursiveAction a = new RecursiveAction() { |
730 |
< |
public void compute() { |
731 |
< |
try { |
732 |
< |
FibAction f = new FibAction(8); |
733 |
< |
FibAction g = new FibAction(9); |
734 |
< |
FibAction h = null; |
735 |
< |
invokeAll(f, g, h); |
736 |
< |
shouldThrow(); |
737 |
< |
} catch (NullPointerException success) { |
767 |
< |
} |
730 |
> |
public void compute() { |
731 |
> |
try { |
732 |
> |
FibAction f = new FibAction(8); |
733 |
> |
FibAction g = new FibAction(9); |
734 |
> |
FibAction h = null; |
735 |
> |
invokeAll(f, g, h); |
736 |
> |
shouldThrow(); |
737 |
> |
} catch (NullPointerException success) { |
738 |
|
} |
739 |
< |
}; |
739 |
> |
}}; |
740 |
|
mainPool.invoke(a); |
741 |
|
} |
742 |
|
|
745 |
|
*/ |
746 |
|
public void testAbnormalInvokeAll2() { |
747 |
|
RecursiveAction a = new RecursiveAction() { |
748 |
< |
public void compute() { |
749 |
< |
try { |
750 |
< |
FibAction f = new FibAction(8); |
751 |
< |
FailingFibAction g = new FailingFibAction(9); |
752 |
< |
invokeAll(f, g); |
753 |
< |
shouldThrow(); |
754 |
< |
} catch (FJException success) { |
785 |
< |
} |
748 |
> |
public void compute() { |
749 |
> |
try { |
750 |
> |
FibAction f = new FibAction(8); |
751 |
> |
FailingFibAction g = new FailingFibAction(9); |
752 |
> |
invokeAll(f, g); |
753 |
> |
shouldThrow(); |
754 |
> |
} catch (FJException success) { |
755 |
|
} |
756 |
< |
}; |
756 |
> |
}}; |
757 |
|
mainPool.invoke(a); |
758 |
|
} |
759 |
|
|
762 |
|
*/ |
763 |
|
public void testAbnormalInvokeAll1() { |
764 |
|
RecursiveAction a = new RecursiveAction() { |
765 |
< |
public void compute() { |
766 |
< |
try { |
767 |
< |
FailingFibAction g = new FailingFibAction(9); |
768 |
< |
invokeAll(g); |
769 |
< |
shouldThrow(); |
770 |
< |
} catch (FJException success) { |
802 |
< |
} |
765 |
> |
public void compute() { |
766 |
> |
try { |
767 |
> |
FailingFibAction g = new FailingFibAction(9); |
768 |
> |
invokeAll(g); |
769 |
> |
shouldThrow(); |
770 |
> |
} catch (FJException success) { |
771 |
|
} |
772 |
< |
}; |
772 |
> |
}}; |
773 |
|
mainPool.invoke(a); |
774 |
|
} |
775 |
|
|
778 |
|
*/ |
779 |
|
public void testAbnormalInvokeAll3() { |
780 |
|
RecursiveAction a = new RecursiveAction() { |
781 |
< |
public void compute() { |
782 |
< |
try { |
783 |
< |
FibAction f = new FibAction(8); |
784 |
< |
FailingFibAction g = new FailingFibAction(9); |
785 |
< |
FibAction h = new FibAction(7); |
786 |
< |
invokeAll(f, g, h); |
787 |
< |
shouldThrow(); |
788 |
< |
} catch (FJException success) { |
821 |
< |
} |
781 |
> |
public void compute() { |
782 |
> |
try { |
783 |
> |
FibAction f = new FibAction(8); |
784 |
> |
FailingFibAction g = new FailingFibAction(9); |
785 |
> |
FibAction h = new FibAction(7); |
786 |
> |
invokeAll(f, g, h); |
787 |
> |
shouldThrow(); |
788 |
> |
} catch (FJException success) { |
789 |
|
} |
790 |
< |
}; |
790 |
> |
}}; |
791 |
|
mainPool.invoke(a); |
792 |
|
} |
793 |
|
|
796 |
|
*/ |
797 |
|
public void testAbnormalInvokeAllCollection() { |
798 |
|
RecursiveAction a = new RecursiveAction() { |
799 |
< |
public void compute() { |
800 |
< |
try { |
801 |
< |
FailingFibAction f = new FailingFibAction(8); |
802 |
< |
FibAction g = new FibAction(9); |
803 |
< |
FibAction h = new FibAction(7); |
804 |
< |
HashSet set = new HashSet(); |
805 |
< |
set.add(f); |
806 |
< |
set.add(g); |
807 |
< |
set.add(h); |
808 |
< |
invokeAll(set); |
809 |
< |
shouldThrow(); |
810 |
< |
} catch (FJException success) { |
844 |
< |
} |
799 |
> |
public void compute() { |
800 |
> |
try { |
801 |
> |
FailingFibAction f = new FailingFibAction(8); |
802 |
> |
FibAction g = new FibAction(9); |
803 |
> |
FibAction h = new FibAction(7); |
804 |
> |
HashSet set = new HashSet(); |
805 |
> |
set.add(f); |
806 |
> |
set.add(g); |
807 |
> |
set.add(h); |
808 |
> |
invokeAll(set); |
809 |
> |
shouldThrow(); |
810 |
> |
} catch (FJException success) { |
811 |
|
} |
812 |
< |
}; |
812 |
> |
}}; |
813 |
|
mainPool.invoke(a); |
814 |
|
} |
815 |
|
|
819 |
|
*/ |
820 |
|
public void testTryUnfork() { |
821 |
|
RecursiveAction a = new RecursiveAction() { |
822 |
< |
public void compute() { |
823 |
< |
FibAction g = new FibAction(9); |
824 |
< |
g.fork(); |
825 |
< |
FibAction f = new FibAction(8); |
826 |
< |
f.fork(); |
827 |
< |
threadAssertTrue(f.tryUnfork()); |
828 |
< |
helpQuiesce(); |
829 |
< |
threadAssertFalse(f.isDone()); |
830 |
< |
threadAssertTrue(g.isDone()); |
831 |
< |
} |
866 |
< |
}; |
822 |
> |
public void compute() { |
823 |
> |
FibAction g = new FibAction(9); |
824 |
> |
g.fork(); |
825 |
> |
FibAction f = new FibAction(8); |
826 |
> |
f.fork(); |
827 |
> |
threadAssertTrue(f.tryUnfork()); |
828 |
> |
helpQuiesce(); |
829 |
> |
threadAssertFalse(f.isDone()); |
830 |
> |
threadAssertTrue(g.isDone()); |
831 |
> |
}}; |
832 |
|
singletonPool.invoke(a); |
833 |
|
} |
834 |
|
|
838 |
|
*/ |
839 |
|
public void testGetSurplusQueuedTaskCount() { |
840 |
|
RecursiveAction a = new RecursiveAction() { |
841 |
< |
public void compute() { |
842 |
< |
FibAction h = new FibAction(7); |
843 |
< |
h.fork(); |
844 |
< |
FibAction g = new FibAction(9); |
845 |
< |
g.fork(); |
846 |
< |
FibAction f = new FibAction(8); |
847 |
< |
f.fork(); |
848 |
< |
threadAssertTrue(getSurplusQueuedTaskCount() > 0); |
849 |
< |
helpQuiesce(); |
850 |
< |
} |
886 |
< |
}; |
841 |
> |
public void compute() { |
842 |
> |
FibAction h = new FibAction(7); |
843 |
> |
h.fork(); |
844 |
> |
FibAction g = new FibAction(9); |
845 |
> |
g.fork(); |
846 |
> |
FibAction f = new FibAction(8); |
847 |
> |
f.fork(); |
848 |
> |
threadAssertTrue(getSurplusQueuedTaskCount() > 0); |
849 |
> |
helpQuiesce(); |
850 |
> |
}}; |
851 |
|
singletonPool.invoke(a); |
852 |
|
} |
853 |
|
|
856 |
|
*/ |
857 |
|
public void testPeekNextLocalTask() { |
858 |
|
RecursiveAction a = new RecursiveAction() { |
859 |
< |
public void compute() { |
860 |
< |
FibAction g = new FibAction(9); |
861 |
< |
g.fork(); |
862 |
< |
FibAction f = new FibAction(8); |
863 |
< |
f.fork(); |
864 |
< |
threadAssertTrue(peekNextLocalTask() == f); |
865 |
< |
f.join(); |
866 |
< |
threadAssertTrue(f.isDone()); |
867 |
< |
helpQuiesce(); |
868 |
< |
} |
905 |
< |
}; |
859 |
> |
public void compute() { |
860 |
> |
FibAction g = new FibAction(9); |
861 |
> |
g.fork(); |
862 |
> |
FibAction f = new FibAction(8); |
863 |
> |
f.fork(); |
864 |
> |
threadAssertTrue(peekNextLocalTask() == f); |
865 |
> |
f.join(); |
866 |
> |
threadAssertTrue(f.isDone()); |
867 |
> |
helpQuiesce(); |
868 |
> |
}}; |
869 |
|
singletonPool.invoke(a); |
870 |
|
} |
871 |
|
|
875 |
|
*/ |
876 |
|
public void testPollNextLocalTask() { |
877 |
|
RecursiveAction a = new RecursiveAction() { |
878 |
< |
public void compute() { |
879 |
< |
FibAction g = new FibAction(9); |
880 |
< |
g.fork(); |
881 |
< |
FibAction f = new FibAction(8); |
882 |
< |
f.fork(); |
883 |
< |
threadAssertTrue(pollNextLocalTask() == f); |
884 |
< |
helpQuiesce(); |
885 |
< |
threadAssertFalse(f.isDone()); |
886 |
< |
} |
924 |
< |
}; |
878 |
> |
public void compute() { |
879 |
> |
FibAction g = new FibAction(9); |
880 |
> |
g.fork(); |
881 |
> |
FibAction f = new FibAction(8); |
882 |
> |
f.fork(); |
883 |
> |
threadAssertTrue(pollNextLocalTask() == f); |
884 |
> |
helpQuiesce(); |
885 |
> |
threadAssertFalse(f.isDone()); |
886 |
> |
}}; |
887 |
|
singletonPool.invoke(a); |
888 |
|
} |
889 |
|
|
893 |
|
*/ |
894 |
|
public void testPollTask() { |
895 |
|
RecursiveAction a = new RecursiveAction() { |
896 |
< |
public void compute() { |
897 |
< |
FibAction g = new FibAction(9); |
898 |
< |
g.fork(); |
899 |
< |
FibAction f = new FibAction(8); |
900 |
< |
f.fork(); |
901 |
< |
threadAssertTrue(pollTask() == f); |
902 |
< |
helpQuiesce(); |
903 |
< |
threadAssertFalse(f.isDone()); |
904 |
< |
threadAssertTrue(g.isDone()); |
905 |
< |
} |
944 |
< |
}; |
896 |
> |
public void compute() { |
897 |
> |
FibAction g = new FibAction(9); |
898 |
> |
g.fork(); |
899 |
> |
FibAction f = new FibAction(8); |
900 |
> |
f.fork(); |
901 |
> |
threadAssertTrue(pollTask() == f); |
902 |
> |
helpQuiesce(); |
903 |
> |
threadAssertFalse(f.isDone()); |
904 |
> |
threadAssertTrue(g.isDone()); |
905 |
> |
}}; |
906 |
|
singletonPool.invoke(a); |
907 |
|
} |
908 |
|
|
911 |
|
*/ |
912 |
|
public void testPeekNextLocalTaskAsync() { |
913 |
|
RecursiveAction a = new RecursiveAction() { |
914 |
< |
public void compute() { |
915 |
< |
FibAction g = new FibAction(9); |
916 |
< |
g.fork(); |
917 |
< |
FibAction f = new FibAction(8); |
918 |
< |
f.fork(); |
919 |
< |
threadAssertTrue(peekNextLocalTask() == g); |
920 |
< |
f.join(); |
921 |
< |
helpQuiesce(); |
922 |
< |
threadAssertTrue(f.isDone()); |
923 |
< |
} |
963 |
< |
}; |
914 |
> |
public void compute() { |
915 |
> |
FibAction g = new FibAction(9); |
916 |
> |
g.fork(); |
917 |
> |
FibAction f = new FibAction(8); |
918 |
> |
f.fork(); |
919 |
> |
threadAssertTrue(peekNextLocalTask() == g); |
920 |
> |
f.join(); |
921 |
> |
helpQuiesce(); |
922 |
> |
threadAssertTrue(f.isDone()); |
923 |
> |
}}; |
924 |
|
asyncSingletonPool.invoke(a); |
925 |
|
} |
926 |
|
|
930 |
|
*/ |
931 |
|
public void testPollNextLocalTaskAsync() { |
932 |
|
RecursiveAction a = new RecursiveAction() { |
933 |
< |
public void compute() { |
934 |
< |
FibAction g = new FibAction(9); |
935 |
< |
g.fork(); |
936 |
< |
FibAction f = new FibAction(8); |
937 |
< |
f.fork(); |
938 |
< |
threadAssertTrue(pollNextLocalTask() == g); |
939 |
< |
helpQuiesce(); |
940 |
< |
threadAssertTrue(f.isDone()); |
941 |
< |
threadAssertFalse(g.isDone()); |
942 |
< |
} |
983 |
< |
}; |
933 |
> |
public void compute() { |
934 |
> |
FibAction g = new FibAction(9); |
935 |
> |
g.fork(); |
936 |
> |
FibAction f = new FibAction(8); |
937 |
> |
f.fork(); |
938 |
> |
threadAssertTrue(pollNextLocalTask() == g); |
939 |
> |
helpQuiesce(); |
940 |
> |
threadAssertTrue(f.isDone()); |
941 |
> |
threadAssertFalse(g.isDone()); |
942 |
> |
}}; |
943 |
|
asyncSingletonPool.invoke(a); |
944 |
|
} |
945 |
|
|
949 |
|
*/ |
950 |
|
public void testPollTaskAsync() { |
951 |
|
RecursiveAction a = new RecursiveAction() { |
952 |
< |
public void compute() { |
953 |
< |
FibAction g = new FibAction(9); |
954 |
< |
g.fork(); |
955 |
< |
FibAction f = new FibAction(8); |
956 |
< |
f.fork(); |
957 |
< |
threadAssertTrue(pollTask() == g); |
958 |
< |
helpQuiesce(); |
959 |
< |
threadAssertTrue(f.isDone()); |
960 |
< |
threadAssertFalse(g.isDone()); |
961 |
< |
} |
1003 |
< |
}; |
952 |
> |
public void compute() { |
953 |
> |
FibAction g = new FibAction(9); |
954 |
> |
g.fork(); |
955 |
> |
FibAction f = new FibAction(8); |
956 |
> |
f.fork(); |
957 |
> |
threadAssertTrue(pollTask() == g); |
958 |
> |
helpQuiesce(); |
959 |
> |
threadAssertTrue(f.isDone()); |
960 |
> |
threadAssertFalse(g.isDone()); |
961 |
> |
}}; |
962 |
|
asyncSingletonPool.invoke(a); |
963 |
|
} |
964 |
|
|