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(); |
21 |
|
static final ForkJoinPool singletonPool = new ForkJoinPool(1); |
22 |
< |
static final ForkJoinPool asyncSingletonPool = new ForkJoinPool(1); |
23 |
< |
static { |
24 |
< |
asyncSingletonPool.setAsyncMode(true); |
25 |
< |
} |
22 |
> |
static final ForkJoinPool asyncSingletonPool = |
23 |
> |
new ForkJoinPool(1, ForkJoinPool.defaultForkJoinWorkerThreadFactory, |
24 |
> |
null, true); |
25 |
|
|
26 |
|
static final class FJException extends RuntimeException { |
27 |
|
FJException() { super(); } |
71 |
|
*/ |
72 |
|
public void testInvoke() { |
73 |
|
RecursiveAction a = new RecursiveAction() { |
74 |
< |
public void compute() { |
75 |
< |
FibAction f = new FibAction(8); |
76 |
< |
f.invoke(); |
77 |
< |
threadAssertTrue(f.result == 21); |
78 |
< |
threadAssertTrue(f.isDone()); |
79 |
< |
threadAssertFalse(f.isCancelled()); |
80 |
< |
threadAssertFalse(f.isCompletedAbnormally()); |
81 |
< |
threadAssertTrue(f.getRawResult() == null); |
82 |
< |
} |
84 |
< |
}; |
74 |
> |
public void compute() { |
75 |
> |
FibAction f = new FibAction(8); |
76 |
> |
f.invoke(); |
77 |
> |
threadAssertTrue(f.result == 21); |
78 |
> |
threadAssertTrue(f.isDone()); |
79 |
> |
threadAssertFalse(f.isCancelled()); |
80 |
> |
threadAssertFalse(f.isCompletedAbnormally()); |
81 |
> |
threadAssertTrue(f.getRawResult() == null); |
82 |
> |
}}; |
83 |
|
mainPool.invoke(a); |
84 |
|
} |
85 |
|
|
90 |
|
*/ |
91 |
|
public void testQuietlyInvoke() { |
92 |
|
RecursiveAction a = new RecursiveAction() { |
93 |
< |
public void compute() { |
94 |
< |
FibAction f = new FibAction(8); |
95 |
< |
f.quietlyInvoke(); |
96 |
< |
threadAssertTrue(f.result == 21); |
97 |
< |
threadAssertTrue(f.isDone()); |
98 |
< |
threadAssertFalse(f.isCancelled()); |
99 |
< |
threadAssertFalse(f.isCompletedAbnormally()); |
100 |
< |
threadAssertTrue(f.getRawResult() == null); |
101 |
< |
} |
104 |
< |
}; |
93 |
> |
public void compute() { |
94 |
> |
FibAction f = new FibAction(8); |
95 |
> |
f.quietlyInvoke(); |
96 |
> |
threadAssertTrue(f.result == 21); |
97 |
> |
threadAssertTrue(f.isDone()); |
98 |
> |
threadAssertFalse(f.isCancelled()); |
99 |
> |
threadAssertFalse(f.isCompletedAbnormally()); |
100 |
> |
threadAssertTrue(f.getRawResult() == null); |
101 |
> |
}}; |
102 |
|
mainPool.invoke(a); |
103 |
|
} |
104 |
|
|
107 |
|
*/ |
108 |
|
public void testForkJoin() { |
109 |
|
RecursiveAction a = new RecursiveAction() { |
110 |
< |
public void compute() { |
111 |
< |
FibAction f = new FibAction(8); |
112 |
< |
f.fork(); |
113 |
< |
f.join(); |
114 |
< |
threadAssertTrue(f.result == 21); |
115 |
< |
threadAssertTrue(f.isDone()); |
116 |
< |
threadAssertTrue(f.getRawResult() == null); |
117 |
< |
} |
121 |
< |
}; |
110 |
> |
public void compute() { |
111 |
> |
FibAction f = new FibAction(8); |
112 |
> |
f.fork(); |
113 |
> |
f.join(); |
114 |
> |
threadAssertTrue(f.result == 21); |
115 |
> |
threadAssertTrue(f.isDone()); |
116 |
> |
threadAssertTrue(f.getRawResult() == null); |
117 |
> |
}}; |
118 |
|
mainPool.invoke(a); |
119 |
|
} |
120 |
|
|
123 |
|
*/ |
124 |
|
public void testForkGet() { |
125 |
|
RecursiveAction a = new RecursiveAction() { |
126 |
< |
public void compute() { |
127 |
< |
try { |
128 |
< |
FibAction f = new FibAction(8); |
129 |
< |
f.fork(); |
130 |
< |
f.get(); |
131 |
< |
threadAssertTrue(f.result == 21); |
132 |
< |
threadAssertTrue(f.isDone()); |
133 |
< |
} catch (Exception ex) { |
134 |
< |
unexpectedException(ex); |
139 |
< |
} |
126 |
> |
public void compute() { |
127 |
> |
try { |
128 |
> |
FibAction f = new FibAction(8); |
129 |
> |
f.fork(); |
130 |
> |
f.get(); |
131 |
> |
threadAssertTrue(f.result == 21); |
132 |
> |
threadAssertTrue(f.isDone()); |
133 |
> |
} catch (Exception ex) { |
134 |
> |
unexpectedException(ex); |
135 |
|
} |
136 |
< |
}; |
136 |
> |
}}; |
137 |
|
mainPool.invoke(a); |
138 |
|
} |
139 |
|
|
142 |
|
*/ |
143 |
|
public void testForkTimedGet() { |
144 |
|
RecursiveAction a = new RecursiveAction() { |
145 |
< |
public void compute() { |
146 |
< |
try { |
152 |
< |
FibAction f = new FibAction(8); |
153 |
< |
f.fork(); |
154 |
< |
f.get(5L, TimeUnit.SECONDS); |
155 |
< |
threadAssertTrue(f.result == 21); |
156 |
< |
threadAssertTrue(f.isDone()); |
157 |
< |
} catch (Exception ex) { |
158 |
< |
unexpectedException(ex); |
159 |
< |
} |
160 |
< |
} |
161 |
< |
}; |
162 |
< |
mainPool.invoke(a); |
163 |
< |
} |
164 |
< |
|
165 |
< |
/** |
166 |
< |
* timed get with null time unit throws NPE |
167 |
< |
*/ |
168 |
< |
public void testForkTimedGetNPE() { |
169 |
< |
RecursiveAction a = new RecursiveAction() { |
170 |
< |
public void compute() { |
171 |
< |
try { |
172 |
< |
FibAction f = new FibAction(8); |
173 |
< |
f.fork(); |
174 |
< |
f.get(5L, null); |
175 |
< |
shouldThrow(); |
176 |
< |
} catch (NullPointerException success) { |
177 |
< |
} catch (Exception ex) { |
178 |
< |
unexpectedException(ex); |
179 |
< |
} |
180 |
< |
} |
181 |
< |
}; |
182 |
< |
mainPool.invoke(a); |
183 |
< |
} |
184 |
< |
|
185 |
< |
/** |
186 |
< |
* helpJoin of a forked task returns when task completes |
187 |
< |
*/ |
188 |
< |
public void testForkHelpJoin() { |
189 |
< |
RecursiveAction a = new RecursiveAction() { |
190 |
< |
public void compute() { |
145 |
> |
public void compute() { |
146 |
> |
try { |
147 |
|
FibAction f = new FibAction(8); |
148 |
|
f.fork(); |
149 |
< |
f.helpJoin(); |
149 |
> |
f.get(5L, TimeUnit.SECONDS); |
150 |
|
threadAssertTrue(f.result == 21); |
151 |
|
threadAssertTrue(f.isDone()); |
152 |
+ |
} catch (Exception ex) { |
153 |
+ |
unexpectedException(ex); |
154 |
|
} |
155 |
< |
}; |
155 |
> |
}}; |
156 |
|
mainPool.invoke(a); |
157 |
|
} |
158 |
|
|
159 |
|
/** |
160 |
< |
* quietlyJoin of a forked task returns when task completes |
160 |
> |
* timed get with null time unit throws NPE |
161 |
|
*/ |
162 |
< |
public void testForkQuietlyJoin() { |
162 |
> |
public void testForkTimedGetNPE() { |
163 |
|
RecursiveAction a = new RecursiveAction() { |
164 |
< |
public void compute() { |
164 |
> |
public void compute() { |
165 |
> |
try { |
166 |
|
FibAction f = new FibAction(8); |
167 |
|
f.fork(); |
168 |
< |
f.quietlyJoin(); |
169 |
< |
threadAssertTrue(f.result == 21); |
170 |
< |
threadAssertTrue(f.isDone()); |
168 |
> |
f.get(5L, null); |
169 |
> |
shouldThrow(); |
170 |
> |
} catch (NullPointerException success) { |
171 |
> |
} catch (Exception ex) { |
172 |
> |
unexpectedException(ex); |
173 |
|
} |
174 |
< |
}; |
174 |
> |
}}; |
175 |
|
mainPool.invoke(a); |
176 |
|
} |
177 |
|
|
217 |
– |
|
178 |
|
/** |
179 |
< |
* quietlyHelpJoin of a forked task returns when task completes |
179 |
> |
* quietlyJoin of a forked task returns when task completes |
180 |
|
*/ |
181 |
< |
public void testForkQuietlyHelpJoin() { |
181 |
> |
public void testForkQuietlyJoin() { |
182 |
|
RecursiveAction a = new RecursiveAction() { |
183 |
< |
public void compute() { |
184 |
< |
FibAction f = new FibAction(8); |
185 |
< |
f.fork(); |
186 |
< |
f.quietlyHelpJoin(); |
187 |
< |
threadAssertTrue(f.result == 21); |
188 |
< |
threadAssertTrue(f.isDone()); |
189 |
< |
} |
230 |
< |
}; |
183 |
> |
public void compute() { |
184 |
> |
FibAction f = new FibAction(8); |
185 |
> |
f.fork(); |
186 |
> |
f.quietlyJoin(); |
187 |
> |
threadAssertTrue(f.result == 21); |
188 |
> |
threadAssertTrue(f.isDone()); |
189 |
> |
}}; |
190 |
|
mainPool.invoke(a); |
191 |
|
} |
192 |
|
|
197 |
|
*/ |
198 |
|
public void testForkHelpQuiesce() { |
199 |
|
RecursiveAction a = new RecursiveAction() { |
200 |
< |
public void compute() { |
201 |
< |
FibAction f = new FibAction(8); |
202 |
< |
f.fork(); |
203 |
< |
f.helpQuiesce(); |
204 |
< |
threadAssertTrue(f.result == 21); |
205 |
< |
threadAssertTrue(f.isDone()); |
206 |
< |
threadAssertTrue(getQueuedTaskCount() == 0); |
207 |
< |
} |
249 |
< |
}; |
200 |
> |
public void compute() { |
201 |
> |
FibAction f = new FibAction(8); |
202 |
> |
f.fork(); |
203 |
> |
f.helpQuiesce(); |
204 |
> |
threadAssertTrue(f.result == 21); |
205 |
> |
threadAssertTrue(f.isDone()); |
206 |
> |
threadAssertTrue(getQueuedTaskCount() == 0); |
207 |
> |
}}; |
208 |
|
mainPool.invoke(a); |
209 |
|
} |
210 |
|
|
214 |
|
*/ |
215 |
|
public void testAbnormalInvoke() { |
216 |
|
RecursiveAction a = new RecursiveAction() { |
217 |
< |
public void compute() { |
218 |
< |
try { |
219 |
< |
FailingFibAction f = new FailingFibAction(8); |
220 |
< |
f.invoke(); |
221 |
< |
shouldThrow(); |
222 |
< |
} catch (FJException success) { |
265 |
< |
} |
217 |
> |
public void compute() { |
218 |
> |
try { |
219 |
> |
FailingFibAction f = new FailingFibAction(8); |
220 |
> |
f.invoke(); |
221 |
> |
shouldThrow(); |
222 |
> |
} catch (FJException success) { |
223 |
|
} |
224 |
< |
}; |
224 |
> |
}}; |
225 |
|
mainPool.invoke(a); |
226 |
|
} |
227 |
|
|
230 |
|
*/ |
231 |
|
public void testAbnormalQuietlyInvoke() { |
232 |
|
RecursiveAction a = new RecursiveAction() { |
233 |
< |
public void compute() { |
234 |
< |
FailingFibAction f = new FailingFibAction(8); |
235 |
< |
f.quietlyInvoke(); |
236 |
< |
threadAssertTrue(f.isDone()); |
237 |
< |
} |
281 |
< |
}; |
233 |
> |
public void compute() { |
234 |
> |
FailingFibAction f = new FailingFibAction(8); |
235 |
> |
f.quietlyInvoke(); |
236 |
> |
threadAssertTrue(f.isDone()); |
237 |
> |
}}; |
238 |
|
mainPool.invoke(a); |
239 |
|
} |
240 |
|
|
243 |
|
*/ |
244 |
|
public void testAbnormalForkJoin() { |
245 |
|
RecursiveAction a = new RecursiveAction() { |
246 |
< |
public void compute() { |
247 |
< |
try { |
248 |
< |
FailingFibAction f = new FailingFibAction(8); |
249 |
< |
f.fork(); |
250 |
< |
f.join(); |
251 |
< |
shouldThrow(); |
252 |
< |
} catch (FJException success) { |
297 |
< |
} |
246 |
> |
public void compute() { |
247 |
> |
try { |
248 |
> |
FailingFibAction f = new FailingFibAction(8); |
249 |
> |
f.fork(); |
250 |
> |
f.join(); |
251 |
> |
shouldThrow(); |
252 |
> |
} catch (FJException success) { |
253 |
|
} |
254 |
< |
}; |
254 |
> |
}}; |
255 |
|
mainPool.invoke(a); |
256 |
|
} |
257 |
|
|
260 |
|
*/ |
261 |
|
public void testAbnormalForkGet() { |
262 |
|
RecursiveAction a = new RecursiveAction() { |
263 |
< |
public void compute() { |
264 |
< |
try { |
265 |
< |
FailingFibAction f = new FailingFibAction(8); |
266 |
< |
f.fork(); |
267 |
< |
f.get(); |
268 |
< |
shouldThrow(); |
269 |
< |
} catch (ExecutionException success) { |
270 |
< |
} catch (Exception ex) { |
271 |
< |
unexpectedException(ex); |
317 |
< |
} |
263 |
> |
public void compute() { |
264 |
> |
try { |
265 |
> |
FailingFibAction f = new FailingFibAction(8); |
266 |
> |
f.fork(); |
267 |
> |
f.get(); |
268 |
> |
shouldThrow(); |
269 |
> |
} catch (ExecutionException success) { |
270 |
> |
} catch (Exception ex) { |
271 |
> |
unexpectedException(ex); |
272 |
|
} |
273 |
< |
}; |
273 |
> |
}}; |
274 |
|
mainPool.invoke(a); |
275 |
|
} |
276 |
|
|
279 |
|
*/ |
280 |
|
public void testAbnormalForkTimedGet() { |
281 |
|
RecursiveAction a = new RecursiveAction() { |
282 |
< |
public void compute() { |
283 |
< |
try { |
330 |
< |
FailingFibAction f = new FailingFibAction(8); |
331 |
< |
f.fork(); |
332 |
< |
f.get(5L, TimeUnit.SECONDS); |
333 |
< |
shouldThrow(); |
334 |
< |
} catch (ExecutionException success) { |
335 |
< |
} catch (Exception ex) { |
336 |
< |
unexpectedException(ex); |
337 |
< |
} |
338 |
< |
} |
339 |
< |
}; |
340 |
< |
mainPool.invoke(a); |
341 |
< |
} |
342 |
< |
|
343 |
< |
/** |
344 |
< |
* join of a forked task throws exception when task completes abnormally |
345 |
< |
*/ |
346 |
< |
public void testAbnormalForkHelpJoin() { |
347 |
< |
RecursiveAction a = new RecursiveAction() { |
348 |
< |
public void compute() { |
349 |
< |
try { |
350 |
< |
FailingFibAction f = new FailingFibAction(8); |
351 |
< |
f.fork(); |
352 |
< |
f.helpJoin(); |
353 |
< |
shouldThrow(); |
354 |
< |
} catch (FJException success) { |
355 |
< |
} |
356 |
< |
} |
357 |
< |
}; |
358 |
< |
mainPool.invoke(a); |
359 |
< |
} |
360 |
< |
|
361 |
< |
/** |
362 |
< |
* quietlyHelpJoin of a forked task returns when task completes abnormally. |
363 |
< |
* getException of failed task returns its exception. |
364 |
< |
* isCompletedAbnormally of a failed task returns true. |
365 |
< |
* isCancelled of a failed uncancelled task returns false |
366 |
< |
*/ |
367 |
< |
public void testAbnormalForkQuietlyHelpJoin() { |
368 |
< |
RecursiveAction a = new RecursiveAction() { |
369 |
< |
public void compute() { |
282 |
> |
public void compute() { |
283 |
> |
try { |
284 |
|
FailingFibAction f = new FailingFibAction(8); |
285 |
|
f.fork(); |
286 |
< |
f.quietlyHelpJoin(); |
287 |
< |
threadAssertTrue(f.isDone()); |
288 |
< |
threadAssertTrue(f.isCompletedAbnormally()); |
289 |
< |
threadAssertFalse(f.isCancelled()); |
290 |
< |
threadAssertTrue(f.getException() instanceof FJException); |
286 |
> |
f.get(5L, TimeUnit.SECONDS); |
287 |
> |
shouldThrow(); |
288 |
> |
} catch (ExecutionException success) { |
289 |
> |
} catch (Exception ex) { |
290 |
> |
unexpectedException(ex); |
291 |
|
} |
292 |
< |
}; |
292 |
> |
}}; |
293 |
|
mainPool.invoke(a); |
294 |
|
} |
295 |
|
|
298 |
|
*/ |
299 |
|
public void testAbnormalForkQuietlyJoin() { |
300 |
|
RecursiveAction a = new RecursiveAction() { |
301 |
< |
public void compute() { |
302 |
< |
FailingFibAction f = new FailingFibAction(8); |
303 |
< |
f.fork(); |
304 |
< |
f.quietlyJoin(); |
305 |
< |
threadAssertTrue(f.isDone()); |
306 |
< |
threadAssertTrue(f.isCompletedAbnormally()); |
307 |
< |
threadAssertTrue(f.getException() instanceof FJException); |
308 |
< |
} |
395 |
< |
}; |
301 |
> |
public void compute() { |
302 |
> |
FailingFibAction f = new FailingFibAction(8); |
303 |
> |
f.fork(); |
304 |
> |
f.quietlyJoin(); |
305 |
> |
threadAssertTrue(f.isDone()); |
306 |
> |
threadAssertTrue(f.isCompletedAbnormally()); |
307 |
> |
threadAssertTrue(f.getException() instanceof FJException); |
308 |
> |
}}; |
309 |
|
mainPool.invoke(a); |
310 |
|
} |
311 |
|
|
314 |
|
*/ |
315 |
|
public void testCancelledInvoke() { |
316 |
|
RecursiveAction a = new RecursiveAction() { |
317 |
< |
public void compute() { |
318 |
< |
try { |
319 |
< |
FibAction f = new FibAction(8); |
320 |
< |
f.cancel(true); |
321 |
< |
f.invoke(); |
322 |
< |
shouldThrow(); |
323 |
< |
} catch (CancellationException success) { |
411 |
< |
} |
317 |
> |
public void compute() { |
318 |
> |
try { |
319 |
> |
FibAction f = new FibAction(8); |
320 |
> |
f.cancel(true); |
321 |
> |
f.invoke(); |
322 |
> |
shouldThrow(); |
323 |
> |
} catch (CancellationException success) { |
324 |
|
} |
325 |
< |
}; |
325 |
> |
}}; |
326 |
|
mainPool.invoke(a); |
327 |
|
} |
328 |
|
|
331 |
|
*/ |
332 |
|
public void testCancelledForkJoin() { |
333 |
|
RecursiveAction a = new RecursiveAction() { |
334 |
< |
public void compute() { |
335 |
< |
try { |
336 |
< |
FibAction f = new FibAction(8); |
337 |
< |
f.cancel(true); |
338 |
< |
f.fork(); |
339 |
< |
f.join(); |
340 |
< |
shouldThrow(); |
341 |
< |
} catch (CancellationException success) { |
430 |
< |
} |
334 |
> |
public void compute() { |
335 |
> |
try { |
336 |
> |
FibAction f = new FibAction(8); |
337 |
> |
f.cancel(true); |
338 |
> |
f.fork(); |
339 |
> |
f.join(); |
340 |
> |
shouldThrow(); |
341 |
> |
} catch (CancellationException success) { |
342 |
|
} |
343 |
< |
}; |
343 |
> |
}}; |
344 |
|
mainPool.invoke(a); |
345 |
|
} |
346 |
|
|
349 |
|
*/ |
350 |
|
public void testCancelledForkGet() { |
351 |
|
RecursiveAction a = new RecursiveAction() { |
352 |
< |
public void compute() { |
353 |
< |
try { |
354 |
< |
FibAction f = new FibAction(8); |
355 |
< |
f.cancel(true); |
356 |
< |
f.fork(); |
357 |
< |
f.get(); |
358 |
< |
shouldThrow(); |
359 |
< |
} catch (CancellationException success) { |
360 |
< |
} catch (Exception ex) { |
361 |
< |
unexpectedException(ex); |
451 |
< |
} |
352 |
> |
public void compute() { |
353 |
> |
try { |
354 |
> |
FibAction f = new FibAction(8); |
355 |
> |
f.cancel(true); |
356 |
> |
f.fork(); |
357 |
> |
f.get(); |
358 |
> |
shouldThrow(); |
359 |
> |
} catch (CancellationException success) { |
360 |
> |
} catch (Exception ex) { |
361 |
> |
unexpectedException(ex); |
362 |
|
} |
363 |
< |
}; |
363 |
> |
}}; |
364 |
|
mainPool.invoke(a); |
365 |
|
} |
366 |
|
|
369 |
|
*/ |
370 |
|
public void testCancelledForkTimedGet() { |
371 |
|
RecursiveAction a = new RecursiveAction() { |
372 |
< |
public void compute() { |
373 |
< |
try { |
464 |
< |
FibAction f = new FibAction(8); |
465 |
< |
f.cancel(true); |
466 |
< |
f.fork(); |
467 |
< |
f.get(5L, TimeUnit.SECONDS); |
468 |
< |
shouldThrow(); |
469 |
< |
} catch (CancellationException success) { |
470 |
< |
} catch (Exception ex) { |
471 |
< |
unexpectedException(ex); |
472 |
< |
} |
473 |
< |
} |
474 |
< |
}; |
475 |
< |
mainPool.invoke(a); |
476 |
< |
} |
477 |
< |
|
478 |
< |
/** |
479 |
< |
* join of a forked task throws exception when task cancelled |
480 |
< |
*/ |
481 |
< |
public void testCancelledForkHelpJoin() { |
482 |
< |
RecursiveAction a = new RecursiveAction() { |
483 |
< |
public void compute() { |
484 |
< |
try { |
485 |
< |
FibAction f = new FibAction(8); |
486 |
< |
f.cancel(true); |
487 |
< |
f.fork(); |
488 |
< |
f.helpJoin(); |
489 |
< |
shouldThrow(); |
490 |
< |
} catch (CancellationException success) { |
491 |
< |
} |
492 |
< |
} |
493 |
< |
}; |
494 |
< |
mainPool.invoke(a); |
495 |
< |
} |
496 |
< |
|
497 |
< |
/** |
498 |
< |
* quietlyHelpJoin of a forked task returns when task cancelled. |
499 |
< |
* getException of cancelled task returns its exception. |
500 |
< |
* isCompletedAbnormally of a cancelled task returns true. |
501 |
< |
* isCancelled of a cancelled task returns true |
502 |
< |
*/ |
503 |
< |
public void testCancelledForkQuietlyHelpJoin() { |
504 |
< |
RecursiveAction a = new RecursiveAction() { |
505 |
< |
public void compute() { |
372 |
> |
public void compute() { |
373 |
> |
try { |
374 |
|
FibAction f = new FibAction(8); |
375 |
|
f.cancel(true); |
376 |
|
f.fork(); |
377 |
< |
f.quietlyHelpJoin(); |
378 |
< |
threadAssertTrue(f.isDone()); |
379 |
< |
threadAssertTrue(f.isCompletedAbnormally()); |
380 |
< |
threadAssertTrue(f.isCancelled()); |
381 |
< |
threadAssertTrue(f.getException() instanceof CancellationException); |
377 |
> |
f.get(5L, TimeUnit.SECONDS); |
378 |
> |
shouldThrow(); |
379 |
> |
} catch (CancellationException success) { |
380 |
> |
} catch (Exception ex) { |
381 |
> |
unexpectedException(ex); |
382 |
|
} |
383 |
< |
}; |
383 |
> |
}}; |
384 |
|
mainPool.invoke(a); |
385 |
|
} |
386 |
|
|
389 |
|
*/ |
390 |
|
public void testCancelledForkQuietlyJoin() { |
391 |
|
RecursiveAction a = new RecursiveAction() { |
392 |
< |
public void compute() { |
393 |
< |
FibAction f = new FibAction(8); |
394 |
< |
f.cancel(true); |
395 |
< |
f.fork(); |
396 |
< |
f.quietlyJoin(); |
397 |
< |
threadAssertTrue(f.isDone()); |
398 |
< |
threadAssertTrue(f.isCompletedAbnormally()); |
399 |
< |
threadAssertTrue(f.getException() instanceof CancellationException); |
400 |
< |
} |
533 |
< |
}; |
392 |
> |
public void compute() { |
393 |
> |
FibAction f = new FibAction(8); |
394 |
> |
f.cancel(true); |
395 |
> |
f.fork(); |
396 |
> |
f.quietlyJoin(); |
397 |
> |
threadAssertTrue(f.isDone()); |
398 |
> |
threadAssertTrue(f.isCompletedAbnormally()); |
399 |
> |
threadAssertTrue(f.getException() instanceof CancellationException); |
400 |
> |
}}; |
401 |
|
mainPool.invoke(a); |
402 |
|
} |
403 |
|
|
406 |
|
*/ |
407 |
|
public void testGetPool() { |
408 |
|
RecursiveAction a = new RecursiveAction() { |
409 |
< |
public void compute() { |
410 |
< |
threadAssertTrue(getPool() == mainPool); |
411 |
< |
} |
545 |
< |
}; |
409 |
> |
public void compute() { |
410 |
> |
threadAssertTrue(getPool() == mainPool); |
411 |
> |
}}; |
412 |
|
mainPool.invoke(a); |
413 |
|
} |
414 |
|
|
417 |
|
*/ |
418 |
|
public void testGetPool2() { |
419 |
|
RecursiveAction a = new RecursiveAction() { |
420 |
< |
public void compute() { |
421 |
< |
threadAssertTrue(getPool() == null); |
422 |
< |
} |
557 |
< |
}; |
420 |
> |
public void compute() { |
421 |
> |
threadAssertTrue(getPool() == null); |
422 |
> |
}}; |
423 |
|
a.invoke(); |
424 |
|
} |
425 |
|
|
428 |
|
*/ |
429 |
|
public void testInForkJoinPool() { |
430 |
|
RecursiveAction a = new RecursiveAction() { |
431 |
< |
public void compute() { |
432 |
< |
threadAssertTrue(inForkJoinPool()); |
433 |
< |
} |
569 |
< |
}; |
431 |
> |
public void compute() { |
432 |
> |
threadAssertTrue(inForkJoinPool()); |
433 |
> |
}}; |
434 |
|
mainPool.invoke(a); |
435 |
|
} |
436 |
|
|
439 |
|
*/ |
440 |
|
public void testInForkJoinPool2() { |
441 |
|
RecursiveAction a = new RecursiveAction() { |
442 |
< |
public void compute() { |
443 |
< |
threadAssertTrue(!inForkJoinPool()); |
444 |
< |
} |
581 |
< |
}; |
442 |
> |
public void compute() { |
443 |
> |
threadAssertTrue(!inForkJoinPool()); |
444 |
> |
}}; |
445 |
|
a.invoke(); |
446 |
|
} |
447 |
|
|
450 |
|
*/ |
451 |
|
public void testWorkerGetPool() { |
452 |
|
RecursiveAction a = new RecursiveAction() { |
453 |
< |
public void compute() { |
454 |
< |
ForkJoinWorkerThread w = |
455 |
< |
(ForkJoinWorkerThread)(Thread.currentThread()); |
456 |
< |
threadAssertTrue(w.getPool() == mainPool); |
457 |
< |
} |
595 |
< |
}; |
453 |
> |
public void compute() { |
454 |
> |
ForkJoinWorkerThread w = |
455 |
> |
(ForkJoinWorkerThread)(Thread.currentThread()); |
456 |
> |
threadAssertTrue(w.getPool() == mainPool); |
457 |
> |
}}; |
458 |
|
mainPool.invoke(a); |
459 |
|
} |
460 |
|
|
464 |
|
*/ |
465 |
|
public void testWorkerGetPoolIndex() { |
466 |
|
RecursiveAction a = new RecursiveAction() { |
467 |
< |
public void compute() { |
468 |
< |
ForkJoinWorkerThread w = |
469 |
< |
(ForkJoinWorkerThread)(Thread.currentThread()); |
470 |
< |
int idx = w.getPoolIndex(); |
471 |
< |
threadAssertTrue(idx >= 0); |
472 |
< |
threadAssertTrue(idx < mainPool.getPoolSize()); |
473 |
< |
} |
612 |
< |
}; |
467 |
> |
public void compute() { |
468 |
> |
ForkJoinWorkerThread w = |
469 |
> |
(ForkJoinWorkerThread)(Thread.currentThread()); |
470 |
> |
int idx = w.getPoolIndex(); |
471 |
> |
threadAssertTrue(idx >= 0); |
472 |
> |
threadAssertTrue(idx < mainPool.getPoolSize()); |
473 |
> |
}}; |
474 |
|
mainPool.invoke(a); |
475 |
|
} |
476 |
|
|
480 |
|
*/ |
481 |
|
public void testSetRawResult() { |
482 |
|
RecursiveAction a = new RecursiveAction() { |
483 |
< |
public void compute() { |
484 |
< |
setRawResult(null); |
485 |
< |
} |
625 |
< |
}; |
483 |
> |
public void compute() { |
484 |
> |
setRawResult(null); |
485 |
> |
}}; |
486 |
|
a.invoke(); |
487 |
|
} |
488 |
|
|
491 |
|
*/ |
492 |
|
public void testReinitialize() { |
493 |
|
RecursiveAction a = new RecursiveAction() { |
494 |
< |
public void compute() { |
495 |
< |
FibAction f = new FibAction(8); |
496 |
< |
f.invoke(); |
497 |
< |
threadAssertTrue(f.result == 21); |
498 |
< |
threadAssertTrue(f.isDone()); |
499 |
< |
threadAssertFalse(f.isCancelled()); |
500 |
< |
threadAssertFalse(f.isCompletedAbnormally()); |
501 |
< |
f.reinitialize(); |
502 |
< |
f.invoke(); |
503 |
< |
threadAssertTrue(f.result == 21); |
504 |
< |
} |
645 |
< |
}; |
494 |
> |
public void compute() { |
495 |
> |
FibAction f = new FibAction(8); |
496 |
> |
f.invoke(); |
497 |
> |
threadAssertTrue(f.result == 21); |
498 |
> |
threadAssertTrue(f.isDone()); |
499 |
> |
threadAssertFalse(f.isCancelled()); |
500 |
> |
threadAssertFalse(f.isCompletedAbnormally()); |
501 |
> |
f.reinitialize(); |
502 |
> |
f.invoke(); |
503 |
> |
threadAssertTrue(f.result == 21); |
504 |
> |
}}; |
505 |
|
mainPool.invoke(a); |
506 |
|
} |
507 |
|
|
510 |
|
*/ |
511 |
|
public void testCompleteExceptionally() { |
512 |
|
RecursiveAction a = new RecursiveAction() { |
513 |
< |
public void compute() { |
514 |
< |
try { |
515 |
< |
FibAction f = new FibAction(8); |
516 |
< |
f.completeExceptionally(new FJException()); |
517 |
< |
f.invoke(); |
518 |
< |
shouldThrow(); |
519 |
< |
} catch (FJException success) { |
661 |
< |
} |
513 |
> |
public void compute() { |
514 |
> |
try { |
515 |
> |
FibAction f = new FibAction(8); |
516 |
> |
f.completeExceptionally(new FJException()); |
517 |
> |
f.invoke(); |
518 |
> |
shouldThrow(); |
519 |
> |
} catch (FJException success) { |
520 |
|
} |
521 |
< |
}; |
521 |
> |
}}; |
522 |
|
mainPool.invoke(a); |
523 |
|
} |
524 |
|
|
527 |
|
*/ |
528 |
|
public void testComplete() { |
529 |
|
RecursiveAction a = new RecursiveAction() { |
530 |
< |
public void compute() { |
531 |
< |
FibAction f = new FibAction(8); |
532 |
< |
f.complete(null); |
533 |
< |
f.invoke(); |
534 |
< |
threadAssertTrue(f.isDone()); |
535 |
< |
threadAssertTrue(f.result == 0); |
536 |
< |
} |
679 |
< |
}; |
530 |
> |
public void compute() { |
531 |
> |
FibAction f = new FibAction(8); |
532 |
> |
f.complete(null); |
533 |
> |
f.invoke(); |
534 |
> |
threadAssertTrue(f.isDone()); |
535 |
> |
threadAssertTrue(f.result == 0); |
536 |
> |
}}; |
537 |
|
mainPool.invoke(a); |
538 |
|
} |
539 |
|
|
542 |
|
*/ |
543 |
|
public void testInvokeAll2() { |
544 |
|
RecursiveAction a = new RecursiveAction() { |
545 |
< |
public void compute() { |
546 |
< |
FibAction f = new FibAction(8); |
547 |
< |
FibAction g = new FibAction(9); |
548 |
< |
invokeAll(f, g); |
549 |
< |
threadAssertTrue(f.isDone()); |
550 |
< |
threadAssertTrue(f.result == 21); |
551 |
< |
threadAssertTrue(g.isDone()); |
552 |
< |
threadAssertTrue(g.result == 34); |
553 |
< |
} |
697 |
< |
}; |
545 |
> |
public void compute() { |
546 |
> |
FibAction f = new FibAction(8); |
547 |
> |
FibAction g = new FibAction(9); |
548 |
> |
invokeAll(f, g); |
549 |
> |
threadAssertTrue(f.isDone()); |
550 |
> |
threadAssertTrue(f.result == 21); |
551 |
> |
threadAssertTrue(g.isDone()); |
552 |
> |
threadAssertTrue(g.result == 34); |
553 |
> |
}}; |
554 |
|
mainPool.invoke(a); |
555 |
|
} |
556 |
|
|
559 |
|
*/ |
560 |
|
public void testInvokeAll1() { |
561 |
|
RecursiveAction a = new RecursiveAction() { |
562 |
< |
public void compute() { |
563 |
< |
FibAction f = new FibAction(8); |
564 |
< |
invokeAll(f); |
565 |
< |
threadAssertTrue(f.isDone()); |
566 |
< |
threadAssertTrue(f.result == 21); |
567 |
< |
} |
712 |
< |
}; |
562 |
> |
public void compute() { |
563 |
> |
FibAction f = new FibAction(8); |
564 |
> |
invokeAll(f); |
565 |
> |
threadAssertTrue(f.isDone()); |
566 |
> |
threadAssertTrue(f.result == 21); |
567 |
> |
}}; |
568 |
|
mainPool.invoke(a); |
569 |
|
} |
570 |
|
|
573 |
|
*/ |
574 |
|
public void testInvokeAll3() { |
575 |
|
RecursiveAction a = new RecursiveAction() { |
576 |
< |
public void compute() { |
577 |
< |
FibAction f = new FibAction(8); |
578 |
< |
FibAction g = new FibAction(9); |
579 |
< |
FibAction h = new FibAction(7); |
580 |
< |
invokeAll(f, g, h); |
581 |
< |
threadAssertTrue(f.isDone()); |
582 |
< |
threadAssertTrue(f.result == 21); |
583 |
< |
threadAssertTrue(g.isDone()); |
584 |
< |
threadAssertTrue(g.result == 34); |
585 |
< |
threadAssertTrue(h.isDone()); |
586 |
< |
threadAssertTrue(h.result == 13); |
587 |
< |
} |
733 |
< |
}; |
576 |
> |
public void compute() { |
577 |
> |
FibAction f = new FibAction(8); |
578 |
> |
FibAction g = new FibAction(9); |
579 |
> |
FibAction h = new FibAction(7); |
580 |
> |
invokeAll(f, g, h); |
581 |
> |
threadAssertTrue(f.isDone()); |
582 |
> |
threadAssertTrue(f.result == 21); |
583 |
> |
threadAssertTrue(g.isDone()); |
584 |
> |
threadAssertTrue(g.result == 34); |
585 |
> |
threadAssertTrue(h.isDone()); |
586 |
> |
threadAssertTrue(h.result == 13); |
587 |
> |
}}; |
588 |
|
mainPool.invoke(a); |
589 |
|
} |
590 |
|
|
593 |
|
*/ |
594 |
|
public void testInvokeAllCollection() { |
595 |
|
RecursiveAction a = new RecursiveAction() { |
596 |
< |
public void compute() { |
597 |
< |
FibAction f = new FibAction(8); |
598 |
< |
FibAction g = new FibAction(9); |
599 |
< |
FibAction h = new FibAction(7); |
600 |
< |
HashSet set = new HashSet(); |
601 |
< |
set.add(f); |
602 |
< |
set.add(g); |
603 |
< |
set.add(h); |
604 |
< |
invokeAll(set); |
605 |
< |
threadAssertTrue(f.isDone()); |
606 |
< |
threadAssertTrue(f.result == 21); |
607 |
< |
threadAssertTrue(g.isDone()); |
608 |
< |
threadAssertTrue(g.result == 34); |
609 |
< |
threadAssertTrue(h.isDone()); |
610 |
< |
threadAssertTrue(h.result == 13); |
611 |
< |
} |
758 |
< |
}; |
596 |
> |
public void compute() { |
597 |
> |
FibAction f = new FibAction(8); |
598 |
> |
FibAction g = new FibAction(9); |
599 |
> |
FibAction h = new FibAction(7); |
600 |
> |
HashSet set = new HashSet(); |
601 |
> |
set.add(f); |
602 |
> |
set.add(g); |
603 |
> |
set.add(h); |
604 |
> |
invokeAll(set); |
605 |
> |
threadAssertTrue(f.isDone()); |
606 |
> |
threadAssertTrue(f.result == 21); |
607 |
> |
threadAssertTrue(g.isDone()); |
608 |
> |
threadAssertTrue(g.result == 34); |
609 |
> |
threadAssertTrue(h.isDone()); |
610 |
> |
threadAssertTrue(h.result == 13); |
611 |
> |
}}; |
612 |
|
mainPool.invoke(a); |
613 |
|
} |
614 |
|
|
618 |
|
*/ |
619 |
|
public void testInvokeAllNPE() { |
620 |
|
RecursiveAction a = new RecursiveAction() { |
621 |
< |
public void compute() { |
622 |
< |
try { |
623 |
< |
FibAction f = new FibAction(8); |
624 |
< |
FibAction g = new FibAction(9); |
625 |
< |
FibAction h = null; |
626 |
< |
invokeAll(f, g, h); |
627 |
< |
shouldThrow(); |
628 |
< |
} catch (NullPointerException success) { |
776 |
< |
} |
621 |
> |
public void compute() { |
622 |
> |
try { |
623 |
> |
FibAction f = new FibAction(8); |
624 |
> |
FibAction g = new FibAction(9); |
625 |
> |
FibAction h = null; |
626 |
> |
invokeAll(f, g, h); |
627 |
> |
shouldThrow(); |
628 |
> |
} catch (NullPointerException success) { |
629 |
|
} |
630 |
< |
}; |
630 |
> |
}}; |
631 |
|
mainPool.invoke(a); |
632 |
|
} |
633 |
|
|
636 |
|
*/ |
637 |
|
public void testAbnormalInvokeAll2() { |
638 |
|
RecursiveAction a = new RecursiveAction() { |
639 |
< |
public void compute() { |
640 |
< |
try { |
641 |
< |
FibAction f = new FibAction(8); |
642 |
< |
FailingFibAction g = new FailingFibAction(9); |
643 |
< |
invokeAll(f, g); |
644 |
< |
shouldThrow(); |
645 |
< |
} catch (FJException success) { |
794 |
< |
} |
639 |
> |
public void compute() { |
640 |
> |
try { |
641 |
> |
FibAction f = new FibAction(8); |
642 |
> |
FailingFibAction g = new FailingFibAction(9); |
643 |
> |
invokeAll(f, g); |
644 |
> |
shouldThrow(); |
645 |
> |
} catch (FJException success) { |
646 |
|
} |
647 |
< |
}; |
647 |
> |
}}; |
648 |
|
mainPool.invoke(a); |
649 |
|
} |
650 |
|
|
653 |
|
*/ |
654 |
|
public void testAbnormalInvokeAll1() { |
655 |
|
RecursiveAction a = new RecursiveAction() { |
656 |
< |
public void compute() { |
657 |
< |
try { |
658 |
< |
FailingFibAction g = new FailingFibAction(9); |
659 |
< |
invokeAll(g); |
660 |
< |
shouldThrow(); |
661 |
< |
} catch (FJException success) { |
811 |
< |
} |
656 |
> |
public void compute() { |
657 |
> |
try { |
658 |
> |
FailingFibAction g = new FailingFibAction(9); |
659 |
> |
invokeAll(g); |
660 |
> |
shouldThrow(); |
661 |
> |
} catch (FJException success) { |
662 |
|
} |
663 |
< |
}; |
663 |
> |
}}; |
664 |
|
mainPool.invoke(a); |
665 |
|
} |
666 |
|
|
669 |
|
*/ |
670 |
|
public void testAbnormalInvokeAll3() { |
671 |
|
RecursiveAction a = new RecursiveAction() { |
672 |
< |
public void compute() { |
673 |
< |
try { |
674 |
< |
FibAction f = new FibAction(8); |
675 |
< |
FailingFibAction g = new FailingFibAction(9); |
676 |
< |
FibAction h = new FibAction(7); |
677 |
< |
invokeAll(f, g, h); |
678 |
< |
shouldThrow(); |
679 |
< |
} catch (FJException success) { |
830 |
< |
} |
672 |
> |
public void compute() { |
673 |
> |
try { |
674 |
> |
FibAction f = new FibAction(8); |
675 |
> |
FailingFibAction g = new FailingFibAction(9); |
676 |
> |
FibAction h = new FibAction(7); |
677 |
> |
invokeAll(f, g, h); |
678 |
> |
shouldThrow(); |
679 |
> |
} catch (FJException success) { |
680 |
|
} |
681 |
< |
}; |
681 |
> |
}}; |
682 |
|
mainPool.invoke(a); |
683 |
|
} |
684 |
|
|
687 |
|
*/ |
688 |
|
public void testAbnormalInvokeAllCollection() { |
689 |
|
RecursiveAction a = new RecursiveAction() { |
690 |
< |
public void compute() { |
691 |
< |
try { |
692 |
< |
FailingFibAction f = new FailingFibAction(8); |
693 |
< |
FibAction g = new FibAction(9); |
694 |
< |
FibAction h = new FibAction(7); |
695 |
< |
HashSet set = new HashSet(); |
696 |
< |
set.add(f); |
697 |
< |
set.add(g); |
698 |
< |
set.add(h); |
699 |
< |
invokeAll(set); |
700 |
< |
shouldThrow(); |
701 |
< |
} catch (FJException success) { |
853 |
< |
} |
690 |
> |
public void compute() { |
691 |
> |
try { |
692 |
> |
FailingFibAction f = new FailingFibAction(8); |
693 |
> |
FibAction g = new FibAction(9); |
694 |
> |
FibAction h = new FibAction(7); |
695 |
> |
HashSet set = new HashSet(); |
696 |
> |
set.add(f); |
697 |
> |
set.add(g); |
698 |
> |
set.add(h); |
699 |
> |
invokeAll(set); |
700 |
> |
shouldThrow(); |
701 |
> |
} catch (FJException success) { |
702 |
|
} |
703 |
< |
}; |
703 |
> |
}}; |
704 |
|
mainPool.invoke(a); |
705 |
|
} |
706 |
|
|
710 |
|
*/ |
711 |
|
public void testTryUnfork() { |
712 |
|
RecursiveAction a = new RecursiveAction() { |
713 |
< |
public void compute() { |
714 |
< |
FibAction g = new FibAction(9); |
715 |
< |
g.fork(); |
716 |
< |
FibAction f = new FibAction(8); |
717 |
< |
f.fork(); |
718 |
< |
threadAssertTrue(f.tryUnfork()); |
719 |
< |
helpQuiesce(); |
720 |
< |
threadAssertFalse(f.isDone()); |
721 |
< |
threadAssertTrue(g.isDone()); |
722 |
< |
} |
875 |
< |
}; |
713 |
> |
public void compute() { |
714 |
> |
FibAction g = new FibAction(9); |
715 |
> |
g.fork(); |
716 |
> |
FibAction f = new FibAction(8); |
717 |
> |
f.fork(); |
718 |
> |
threadAssertTrue(f.tryUnfork()); |
719 |
> |
helpQuiesce(); |
720 |
> |
threadAssertFalse(f.isDone()); |
721 |
> |
threadAssertTrue(g.isDone()); |
722 |
> |
}}; |
723 |
|
singletonPool.invoke(a); |
724 |
|
} |
725 |
|
|
729 |
|
*/ |
730 |
|
public void testGetSurplusQueuedTaskCount() { |
731 |
|
RecursiveAction a = new RecursiveAction() { |
732 |
< |
public void compute() { |
733 |
< |
FibAction h = new FibAction(7); |
734 |
< |
h.fork(); |
735 |
< |
FibAction g = new FibAction(9); |
736 |
< |
g.fork(); |
737 |
< |
FibAction f = new FibAction(8); |
738 |
< |
f.fork(); |
739 |
< |
threadAssertTrue(getSurplusQueuedTaskCount() > 0); |
740 |
< |
helpQuiesce(); |
741 |
< |
} |
895 |
< |
}; |
732 |
> |
public void compute() { |
733 |
> |
FibAction h = new FibAction(7); |
734 |
> |
h.fork(); |
735 |
> |
FibAction g = new FibAction(9); |
736 |
> |
g.fork(); |
737 |
> |
FibAction f = new FibAction(8); |
738 |
> |
f.fork(); |
739 |
> |
threadAssertTrue(getSurplusQueuedTaskCount() > 0); |
740 |
> |
helpQuiesce(); |
741 |
> |
}}; |
742 |
|
singletonPool.invoke(a); |
743 |
|
} |
744 |
|
|
747 |
|
*/ |
748 |
|
public void testPeekNextLocalTask() { |
749 |
|
RecursiveAction a = new RecursiveAction() { |
750 |
< |
public void compute() { |
751 |
< |
FibAction g = new FibAction(9); |
752 |
< |
g.fork(); |
753 |
< |
FibAction f = new FibAction(8); |
754 |
< |
f.fork(); |
755 |
< |
threadAssertTrue(peekNextLocalTask() == f); |
756 |
< |
f.join(); |
757 |
< |
threadAssertTrue(f.isDone()); |
758 |
< |
helpQuiesce(); |
759 |
< |
} |
914 |
< |
}; |
750 |
> |
public void compute() { |
751 |
> |
FibAction g = new FibAction(9); |
752 |
> |
g.fork(); |
753 |
> |
FibAction f = new FibAction(8); |
754 |
> |
f.fork(); |
755 |
> |
threadAssertTrue(peekNextLocalTask() == f); |
756 |
> |
f.join(); |
757 |
> |
threadAssertTrue(f.isDone()); |
758 |
> |
helpQuiesce(); |
759 |
> |
}}; |
760 |
|
singletonPool.invoke(a); |
761 |
|
} |
762 |
|
|
766 |
|
*/ |
767 |
|
public void testPollNextLocalTask() { |
768 |
|
RecursiveAction a = new RecursiveAction() { |
769 |
< |
public void compute() { |
770 |
< |
FibAction g = new FibAction(9); |
771 |
< |
g.fork(); |
772 |
< |
FibAction f = new FibAction(8); |
773 |
< |
f.fork(); |
774 |
< |
threadAssertTrue(pollNextLocalTask() == f); |
775 |
< |
helpQuiesce(); |
776 |
< |
threadAssertFalse(f.isDone()); |
777 |
< |
} |
933 |
< |
}; |
769 |
> |
public void compute() { |
770 |
> |
FibAction g = new FibAction(9); |
771 |
> |
g.fork(); |
772 |
> |
FibAction f = new FibAction(8); |
773 |
> |
f.fork(); |
774 |
> |
threadAssertTrue(pollNextLocalTask() == f); |
775 |
> |
helpQuiesce(); |
776 |
> |
threadAssertFalse(f.isDone()); |
777 |
> |
}}; |
778 |
|
singletonPool.invoke(a); |
779 |
|
} |
780 |
|
|
784 |
|
*/ |
785 |
|
public void testPollTask() { |
786 |
|
RecursiveAction a = new RecursiveAction() { |
787 |
< |
public void compute() { |
788 |
< |
FibAction g = new FibAction(9); |
789 |
< |
g.fork(); |
790 |
< |
FibAction f = new FibAction(8); |
791 |
< |
f.fork(); |
792 |
< |
threadAssertTrue(pollTask() == f); |
793 |
< |
helpQuiesce(); |
794 |
< |
threadAssertFalse(f.isDone()); |
795 |
< |
threadAssertTrue(g.isDone()); |
796 |
< |
} |
953 |
< |
}; |
787 |
> |
public void compute() { |
788 |
> |
FibAction g = new FibAction(9); |
789 |
> |
g.fork(); |
790 |
> |
FibAction f = new FibAction(8); |
791 |
> |
f.fork(); |
792 |
> |
threadAssertTrue(pollTask() == f); |
793 |
> |
helpQuiesce(); |
794 |
> |
threadAssertFalse(f.isDone()); |
795 |
> |
threadAssertTrue(g.isDone()); |
796 |
> |
}}; |
797 |
|
singletonPool.invoke(a); |
798 |
|
} |
799 |
|
|
802 |
|
*/ |
803 |
|
public void testPeekNextLocalTaskAsync() { |
804 |
|
RecursiveAction a = new RecursiveAction() { |
805 |
< |
public void compute() { |
806 |
< |
FibAction g = new FibAction(9); |
807 |
< |
g.fork(); |
808 |
< |
FibAction f = new FibAction(8); |
809 |
< |
f.fork(); |
810 |
< |
threadAssertTrue(peekNextLocalTask() == g); |
811 |
< |
f.join(); |
812 |
< |
helpQuiesce(); |
813 |
< |
threadAssertTrue(f.isDone()); |
814 |
< |
} |
972 |
< |
}; |
805 |
> |
public void compute() { |
806 |
> |
FibAction g = new FibAction(9); |
807 |
> |
g.fork(); |
808 |
> |
FibAction f = new FibAction(8); |
809 |
> |
f.fork(); |
810 |
> |
threadAssertTrue(peekNextLocalTask() == g); |
811 |
> |
f.join(); |
812 |
> |
helpQuiesce(); |
813 |
> |
threadAssertTrue(f.isDone()); |
814 |
> |
}}; |
815 |
|
asyncSingletonPool.invoke(a); |
816 |
|
} |
817 |
|
|
821 |
|
*/ |
822 |
|
public void testPollNextLocalTaskAsync() { |
823 |
|
RecursiveAction a = new RecursiveAction() { |
824 |
< |
public void compute() { |
825 |
< |
FibAction g = new FibAction(9); |
826 |
< |
g.fork(); |
827 |
< |
FibAction f = new FibAction(8); |
828 |
< |
f.fork(); |
829 |
< |
threadAssertTrue(pollNextLocalTask() == g); |
830 |
< |
helpQuiesce(); |
831 |
< |
threadAssertTrue(f.isDone()); |
832 |
< |
threadAssertFalse(g.isDone()); |
833 |
< |
} |
992 |
< |
}; |
824 |
> |
public void compute() { |
825 |
> |
FibAction g = new FibAction(9); |
826 |
> |
g.fork(); |
827 |
> |
FibAction f = new FibAction(8); |
828 |
> |
f.fork(); |
829 |
> |
threadAssertTrue(pollNextLocalTask() == g); |
830 |
> |
helpQuiesce(); |
831 |
> |
threadAssertTrue(f.isDone()); |
832 |
> |
threadAssertFalse(g.isDone()); |
833 |
> |
}}; |
834 |
|
asyncSingletonPool.invoke(a); |
835 |
|
} |
836 |
|
|
840 |
|
*/ |
841 |
|
public void testPollTaskAsync() { |
842 |
|
RecursiveAction a = new RecursiveAction() { |
843 |
< |
public void compute() { |
844 |
< |
FibAction g = new FibAction(9); |
845 |
< |
g.fork(); |
846 |
< |
FibAction f = new FibAction(8); |
847 |
< |
f.fork(); |
848 |
< |
threadAssertTrue(pollTask() == g); |
849 |
< |
helpQuiesce(); |
850 |
< |
threadAssertTrue(f.isDone()); |
851 |
< |
threadAssertFalse(g.isDone()); |
852 |
< |
} |
1012 |
< |
}; |
843 |
> |
public void compute() { |
844 |
> |
FibAction g = new FibAction(9); |
845 |
> |
g.fork(); |
846 |
> |
FibAction f = new FibAction(8); |
847 |
> |
f.fork(); |
848 |
> |
threadAssertTrue(pollTask() == g); |
849 |
> |
helpQuiesce(); |
850 |
> |
threadAssertTrue(f.isDone()); |
851 |
> |
threadAssertFalse(g.isDone()); |
852 |
> |
}}; |
853 |
|
asyncSingletonPool.invoke(a); |
854 |
|
} |
855 |
|
|