1 |
|
/* |
2 |
|
* Written by Doug Lea with assistance from members of JCP JSR-166 |
3 |
|
* Expert Group and released to the public domain, as explained at |
4 |
< |
* http://creativecommons.org/licenses/publicdomain |
4 |
> |
* http://creativecommons.org/publicdomain/zero/1.0/ |
5 |
|
*/ |
6 |
– |
import junit.framework.*; |
7 |
– |
import java.util.concurrent.*; |
8 |
– |
import java.util.*; |
6 |
|
|
7 |
+ |
import junit.framework.*; |
8 |
+ |
import java.util.concurrent.CancellationException; |
9 |
+ |
import java.util.concurrent.ExecutionException; |
10 |
+ |
import java.util.concurrent.ForkJoinPool; |
11 |
+ |
import java.util.concurrent.ForkJoinTask; |
12 |
+ |
import java.util.concurrent.RecursiveTask; |
13 |
+ |
import java.util.concurrent.TimeoutException; |
14 |
+ |
import static java.util.concurrent.TimeUnit.SECONDS; |
15 |
+ |
import java.util.HashSet; |
16 |
|
|
17 |
|
public class RecursiveTaskTest extends JSR166TestCase { |
18 |
|
|
19 |
|
public static void main(String[] args) { |
20 |
< |
junit.textui.TestRunner.run (suite()); |
20 |
> |
junit.textui.TestRunner.run(suite()); |
21 |
|
} |
22 |
|
public static Test suite() { |
23 |
< |
return new TestSuite(RecursiveTaskTest.class); |
23 |
> |
return new TestSuite(RecursiveTaskTest.class); |
24 |
> |
} |
25 |
> |
|
26 |
> |
private static ForkJoinPool mainPool() { |
27 |
> |
return new ForkJoinPool(); |
28 |
|
} |
29 |
|
|
30 |
< |
static final ForkJoinPool mainPool = new ForkJoinPool(); |
31 |
< |
static final ForkJoinPool singletonPool = new ForkJoinPool(1); |
22 |
< |
static final ForkJoinPool asyncSingletonPool = new ForkJoinPool(1); |
23 |
< |
static { |
24 |
< |
asyncSingletonPool.setAsyncMode(true); |
30 |
> |
private static ForkJoinPool singletonPool() { |
31 |
> |
return new ForkJoinPool(1); |
32 |
|
} |
33 |
|
|
34 |
< |
static final class FJException extends RuntimeException { |
35 |
< |
FJException() { super(); } |
34 |
> |
private static ForkJoinPool asyncSingletonPool() { |
35 |
> |
return new ForkJoinPool(1, |
36 |
> |
ForkJoinPool.defaultForkJoinWorkerThreadFactory, |
37 |
> |
null, true); |
38 |
> |
} |
39 |
> |
|
40 |
> |
private <T> T testInvokeOnPool(ForkJoinPool pool, RecursiveTask<T> a) { |
41 |
> |
try { |
42 |
> |
checkNotDone(a); |
43 |
> |
|
44 |
> |
T result = pool.invoke(a); |
45 |
> |
|
46 |
> |
checkCompletedNormally(a, result); |
47 |
> |
return result; |
48 |
> |
} finally { |
49 |
> |
joinPool(pool); |
50 |
> |
} |
51 |
> |
} |
52 |
> |
|
53 |
> |
void checkNotDone(RecursiveTask a) { |
54 |
> |
assertFalse(a.isDone()); |
55 |
> |
assertFalse(a.isCompletedNormally()); |
56 |
> |
assertFalse(a.isCompletedAbnormally()); |
57 |
> |
assertFalse(a.isCancelled()); |
58 |
> |
assertNull(a.getException()); |
59 |
> |
assertNull(a.getRawResult()); |
60 |
> |
|
61 |
> |
if (! ForkJoinTask.inForkJoinPool()) { |
62 |
> |
Thread.currentThread().interrupt(); |
63 |
> |
try { |
64 |
> |
a.get(); |
65 |
> |
shouldThrow(); |
66 |
> |
} catch (InterruptedException success) { |
67 |
> |
} catch (Throwable fail) { threadUnexpectedException(fail); } |
68 |
> |
|
69 |
> |
Thread.currentThread().interrupt(); |
70 |
> |
try { |
71 |
> |
a.get(5L, SECONDS); |
72 |
> |
shouldThrow(); |
73 |
> |
} catch (InterruptedException success) { |
74 |
> |
} catch (Throwable fail) { threadUnexpectedException(fail); } |
75 |
> |
} |
76 |
> |
|
77 |
> |
try { |
78 |
> |
a.get(0L, SECONDS); |
79 |
> |
shouldThrow(); |
80 |
> |
} catch (TimeoutException success) { |
81 |
> |
} catch (Throwable fail) { threadUnexpectedException(fail); } |
82 |
> |
} |
83 |
> |
|
84 |
> |
<T> void checkCompletedNormally(RecursiveTask<T> a, T expected) { |
85 |
> |
assertTrue(a.isDone()); |
86 |
> |
assertFalse(a.isCancelled()); |
87 |
> |
assertTrue(a.isCompletedNormally()); |
88 |
> |
assertFalse(a.isCompletedAbnormally()); |
89 |
> |
assertNull(a.getException()); |
90 |
> |
assertSame(expected, a.getRawResult()); |
91 |
> |
assertSame(expected, a.join()); |
92 |
> |
assertFalse(a.cancel(false)); |
93 |
> |
assertFalse(a.cancel(true)); |
94 |
> |
try { |
95 |
> |
assertSame(expected, a.get()); |
96 |
> |
} catch (Throwable fail) { threadUnexpectedException(fail); } |
97 |
> |
try { |
98 |
> |
assertSame(expected, a.get(5L, SECONDS)); |
99 |
> |
} catch (Throwable fail) { threadUnexpectedException(fail); } |
100 |
> |
} |
101 |
> |
|
102 |
> |
/** |
103 |
> |
* Waits for the task to complete, and checks that when it does, |
104 |
> |
* it will have an Integer result equals to the given int. |
105 |
> |
*/ |
106 |
> |
void checkCompletesNormally(RecursiveTask<Integer> a, int expected) { |
107 |
> |
Integer r = a.join(); |
108 |
> |
assertEquals(expected, (int) r); |
109 |
> |
checkCompletedNormally(a, r); |
110 |
> |
} |
111 |
> |
|
112 |
> |
/** |
113 |
> |
* Like checkCompletesNormally, but verifies that the task has |
114 |
> |
* already completed. |
115 |
> |
*/ |
116 |
> |
void checkCompletedNormally(RecursiveTask<Integer> a, int expected) { |
117 |
> |
Integer r = a.getRawResult(); |
118 |
> |
assertEquals(expected, (int) r); |
119 |
> |
checkCompletedNormally(a, r); |
120 |
> |
} |
121 |
> |
|
122 |
> |
void checkCancelled(RecursiveTask a) { |
123 |
> |
assertTrue(a.isDone()); |
124 |
> |
assertTrue(a.isCancelled()); |
125 |
> |
assertFalse(a.isCompletedNormally()); |
126 |
> |
assertTrue(a.isCompletedAbnormally()); |
127 |
> |
assertTrue(a.getException() instanceof CancellationException); |
128 |
> |
assertNull(a.getRawResult()); |
129 |
> |
|
130 |
> |
try { |
131 |
> |
a.join(); |
132 |
> |
shouldThrow(); |
133 |
> |
} catch (CancellationException success) { |
134 |
> |
} catch (Throwable fail) { threadUnexpectedException(fail); } |
135 |
> |
|
136 |
> |
try { |
137 |
> |
a.get(); |
138 |
> |
shouldThrow(); |
139 |
> |
} catch (CancellationException success) { |
140 |
> |
} catch (Throwable fail) { threadUnexpectedException(fail); } |
141 |
> |
|
142 |
> |
try { |
143 |
> |
a.get(5L, SECONDS); |
144 |
> |
shouldThrow(); |
145 |
> |
} catch (CancellationException success) { |
146 |
> |
} catch (Throwable fail) { threadUnexpectedException(fail); } |
147 |
> |
} |
148 |
> |
|
149 |
> |
void checkCompletedAbnormally(RecursiveTask a, Throwable t) { |
150 |
> |
assertTrue(a.isDone()); |
151 |
> |
assertFalse(a.isCancelled()); |
152 |
> |
assertFalse(a.isCompletedNormally()); |
153 |
> |
assertTrue(a.isCompletedAbnormally()); |
154 |
> |
assertSame(t.getClass(), a.getException().getClass()); |
155 |
> |
assertNull(a.getRawResult()); |
156 |
> |
assertFalse(a.cancel(false)); |
157 |
> |
assertFalse(a.cancel(true)); |
158 |
> |
|
159 |
> |
try { |
160 |
> |
a.join(); |
161 |
> |
shouldThrow(); |
162 |
> |
} catch (Throwable expected) { |
163 |
> |
assertSame(t.getClass(), expected.getClass()); |
164 |
> |
} |
165 |
> |
|
166 |
> |
try { |
167 |
> |
a.get(); |
168 |
> |
shouldThrow(); |
169 |
> |
} catch (ExecutionException success) { |
170 |
> |
assertSame(t.getClass(), success.getCause().getClass()); |
171 |
> |
} catch (Throwable fail) { threadUnexpectedException(fail); } |
172 |
> |
|
173 |
> |
try { |
174 |
> |
a.get(5L, SECONDS); |
175 |
> |
shouldThrow(); |
176 |
> |
} catch (ExecutionException success) { |
177 |
> |
assertSame(t.getClass(), success.getCause().getClass()); |
178 |
> |
} catch (Throwable fail) { threadUnexpectedException(fail); } |
179 |
> |
} |
180 |
> |
|
181 |
> |
public static final class FJException extends RuntimeException { |
182 |
> |
public FJException() { super(); } |
183 |
|
} |
184 |
|
|
185 |
|
// An invalid return value for Fib |
186 |
|
static final Integer NoResult = Integer.valueOf(-17); |
187 |
|
|
188 |
|
// A simple recursive task for testing |
189 |
< |
static final class FibTask extends RecursiveTask<Integer> { |
189 |
> |
final class FibTask extends CheckedRecursiveTask<Integer> { |
190 |
|
final int number; |
191 |
|
FibTask(int n) { number = n; } |
192 |
< |
public Integer compute() { |
192 |
> |
public Integer realCompute() { |
193 |
|
int n = number; |
194 |
|
if (n <= 1) |
195 |
|
return n; |
197 |
|
f1.fork(); |
198 |
|
return (new FibTask(n - 2)).compute() + f1.join(); |
199 |
|
} |
200 |
+ |
|
201 |
+ |
public void publicSetRawResult(Integer result) { |
202 |
+ |
setRawResult(result); |
203 |
+ |
} |
204 |
|
} |
205 |
|
|
206 |
|
// A recursive action failing in base case |
207 |
< |
static final class FailingFibTask extends RecursiveTask<Integer> { |
207 |
> |
final class FailingFibTask extends RecursiveTask<Integer> { |
208 |
|
final int number; |
209 |
|
int result; |
210 |
|
FailingFibTask(int n) { number = n; } |
223 |
|
* isCompletedAbnormally and isCancelled return false for normally |
224 |
|
* completed tasks. getRawResult of a completed non-null task |
225 |
|
* returns value; |
68 |
– |
* |
226 |
|
*/ |
227 |
|
public void testInvoke() { |
228 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
229 |
< |
public Integer compute() { |
228 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
229 |
> |
public Integer realCompute() { |
230 |
|
FibTask f = new FibTask(8); |
231 |
|
Integer r = f.invoke(); |
232 |
< |
threadAssertTrue(r == 21); |
233 |
< |
threadAssertTrue(f.isDone()); |
77 |
< |
threadAssertFalse(f.isCancelled()); |
78 |
< |
threadAssertFalse(f.isCompletedAbnormally()); |
79 |
< |
threadAssertTrue(f.getRawResult() == 21); |
232 |
> |
assertEquals(21, (int) r); |
233 |
> |
checkCompletedNormally(f, r); |
234 |
|
return r; |
235 |
< |
} |
236 |
< |
}; |
83 |
< |
assertTrue(mainPool.invoke(a) == 21); |
235 |
> |
}}; |
236 |
> |
assertEquals(21, (int) testInvokeOnPool(mainPool(), a)); |
237 |
|
} |
238 |
|
|
239 |
|
/** |
242 |
|
* completed tasks |
243 |
|
*/ |
244 |
|
public void testQuietlyInvoke() { |
245 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
246 |
< |
public Integer compute() { |
245 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
246 |
> |
public Integer realCompute() { |
247 |
|
FibTask f = new FibTask(8); |
248 |
|
f.quietlyInvoke(); |
249 |
< |
Integer r = f.getRawResult(); |
250 |
< |
threadAssertTrue(r == 21); |
251 |
< |
threadAssertTrue(f.isDone()); |
252 |
< |
threadAssertFalse(f.isCancelled()); |
100 |
< |
threadAssertFalse(f.isCompletedAbnormally()); |
101 |
< |
return r; |
102 |
< |
} |
103 |
< |
}; |
104 |
< |
assertTrue(mainPool.invoke(a) == 21); |
249 |
> |
checkCompletedNormally(f, 21); |
250 |
> |
return NoResult; |
251 |
> |
}}; |
252 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
253 |
|
} |
254 |
|
|
255 |
|
/** |
256 |
|
* join of a forked task returns when task completes |
257 |
|
*/ |
258 |
|
public void testForkJoin() { |
259 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
260 |
< |
public Integer compute() { |
259 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
260 |
> |
public Integer realCompute() { |
261 |
|
FibTask f = new FibTask(8); |
262 |
< |
f.fork(); |
262 |
> |
assertSame(f, f.fork()); |
263 |
|
Integer r = f.join(); |
264 |
< |
threadAssertTrue(r == 21); |
265 |
< |
threadAssertTrue(f.isDone()); |
264 |
> |
assertEquals(21, (int) r); |
265 |
> |
checkCompletedNormally(f, r); |
266 |
|
return r; |
267 |
< |
} |
268 |
< |
}; |
121 |
< |
assertTrue(mainPool.invoke(a) == 21); |
267 |
> |
}}; |
268 |
> |
assertEquals(21, (int) testInvokeOnPool(mainPool(), a)); |
269 |
|
} |
270 |
|
|
271 |
|
/** |
272 |
|
* get of a forked task returns when task completes |
273 |
|
*/ |
274 |
|
public void testForkGet() { |
275 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
276 |
< |
public Integer compute() { |
277 |
< |
try { |
278 |
< |
FibTask f = new FibTask(8); |
279 |
< |
f.fork(); |
280 |
< |
Integer r = f.get(); |
281 |
< |
threadAssertTrue(r == 21); |
282 |
< |
threadAssertTrue(f.isDone()); |
283 |
< |
return r; |
284 |
< |
} catch (Exception ex) { |
138 |
< |
unexpectedException(ex); |
139 |
< |
} |
140 |
< |
return NoResult; |
141 |
< |
} |
142 |
< |
}; |
143 |
< |
assertTrue(mainPool.invoke(a) == 21); |
275 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
276 |
> |
public Integer realCompute() throws Exception { |
277 |
> |
FibTask f = new FibTask(8); |
278 |
> |
assertSame(f, f.fork()); |
279 |
> |
Integer r = f.get(); |
280 |
> |
assertEquals(21, (int) r); |
281 |
> |
checkCompletedNormally(f, r); |
282 |
> |
return r; |
283 |
> |
}}; |
284 |
> |
assertEquals(21, (int) testInvokeOnPool(mainPool(), a)); |
285 |
|
} |
286 |
|
|
287 |
|
/** |
288 |
|
* timed get of a forked task returns when task completes |
289 |
|
*/ |
290 |
|
public void testForkTimedGet() { |
291 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
292 |
< |
public Integer compute() { |
152 |
< |
try { |
153 |
< |
FibTask f = new FibTask(8); |
154 |
< |
f.fork(); |
155 |
< |
Integer r = f.get(5L, TimeUnit.SECONDS); |
156 |
< |
threadAssertTrue(r == 21); |
157 |
< |
threadAssertTrue(f.isDone()); |
158 |
< |
return r; |
159 |
< |
} catch (Exception ex) { |
160 |
< |
unexpectedException(ex); |
161 |
< |
} |
162 |
< |
return NoResult; |
163 |
< |
} |
164 |
< |
}; |
165 |
< |
assertTrue(mainPool.invoke(a) == 21); |
166 |
< |
} |
167 |
< |
|
168 |
< |
/** |
169 |
< |
* helpJoin of a forked task returns when task completes |
170 |
< |
*/ |
171 |
< |
public void testForkHelpJoin() { |
172 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
173 |
< |
public Integer compute() { |
291 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
292 |
> |
public Integer realCompute() throws Exception { |
293 |
|
FibTask f = new FibTask(8); |
294 |
< |
f.fork(); |
295 |
< |
Integer r = f.helpJoin(); |
296 |
< |
threadAssertTrue(r == 21); |
297 |
< |
threadAssertTrue(f.isDone()); |
294 |
> |
assertSame(f, f.fork()); |
295 |
> |
Integer r = f.get(5L, SECONDS); |
296 |
> |
assertEquals(21, (int) r); |
297 |
> |
checkCompletedNormally(f, r); |
298 |
|
return r; |
299 |
< |
} |
300 |
< |
}; |
182 |
< |
assertTrue(mainPool.invoke(a) == 21); |
299 |
> |
}}; |
300 |
> |
assertEquals(21, (int) testInvokeOnPool(mainPool(), a)); |
301 |
|
} |
302 |
|
|
303 |
|
/** |
304 |
|
* quietlyJoin of a forked task returns when task completes |
305 |
|
*/ |
306 |
|
public void testForkQuietlyJoin() { |
307 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
308 |
< |
public Integer compute() { |
307 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
308 |
> |
public Integer realCompute() { |
309 |
|
FibTask f = new FibTask(8); |
310 |
< |
f.fork(); |
310 |
> |
assertSame(f, f.fork()); |
311 |
|
f.quietlyJoin(); |
312 |
|
Integer r = f.getRawResult(); |
313 |
< |
threadAssertTrue(r == 21); |
314 |
< |
threadAssertTrue(f.isDone()); |
313 |
> |
assertEquals(21, (int) r); |
314 |
> |
checkCompletedNormally(f, r); |
315 |
|
return r; |
316 |
< |
} |
317 |
< |
}; |
200 |
< |
assertTrue(mainPool.invoke(a) == 21); |
316 |
> |
}}; |
317 |
> |
assertEquals(21, (int) testInvokeOnPool(mainPool(), a)); |
318 |
|
} |
319 |
|
|
203 |
– |
|
204 |
– |
/** |
205 |
– |
* quietlyHelpJoin of a forked task returns when task completes |
206 |
– |
*/ |
207 |
– |
public void testForkQuietlyHelpJoin() { |
208 |
– |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
209 |
– |
public Integer compute() { |
210 |
– |
FibTask f = new FibTask(8); |
211 |
– |
f.fork(); |
212 |
– |
f.quietlyHelpJoin(); |
213 |
– |
Integer r = f.getRawResult(); |
214 |
– |
threadAssertTrue(r == 21); |
215 |
– |
threadAssertTrue(f.isDone()); |
216 |
– |
return r; |
217 |
– |
} |
218 |
– |
}; |
219 |
– |
assertTrue(mainPool.invoke(a) == 21); |
220 |
– |
} |
221 |
– |
|
222 |
– |
|
320 |
|
/** |
321 |
|
* helpQuiesce returns when tasks are complete. |
322 |
|
* getQueuedTaskCount returns 0 when quiescent |
323 |
|
*/ |
324 |
|
public void testForkHelpQuiesce() { |
325 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
326 |
< |
public Integer compute() { |
325 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
326 |
> |
public Integer realCompute() { |
327 |
|
FibTask f = new FibTask(8); |
328 |
< |
f.fork(); |
329 |
< |
f.helpQuiesce(); |
330 |
< |
Integer r = f.getRawResult(); |
331 |
< |
threadAssertTrue(r == 21); |
332 |
< |
threadAssertTrue(f.isDone()); |
333 |
< |
threadAssertTrue(getQueuedTaskCount() == 0); |
334 |
< |
return r; |
238 |
< |
} |
239 |
< |
}; |
240 |
< |
assertTrue(mainPool.invoke(a) == 21); |
328 |
> |
assertSame(f, f.fork()); |
329 |
> |
helpQuiesce(); |
330 |
> |
assertEquals(0, getQueuedTaskCount()); |
331 |
> |
checkCompletedNormally(f, 21); |
332 |
> |
return NoResult; |
333 |
> |
}}; |
334 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
335 |
|
} |
336 |
|
|
243 |
– |
|
337 |
|
/** |
338 |
|
* invoke task throws exception when task completes abnormally |
339 |
|
*/ |
340 |
|
public void testAbnormalInvoke() { |
341 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
342 |
< |
public Integer compute() { |
341 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
342 |
> |
public Integer realCompute() { |
343 |
> |
FailingFibTask f = new FailingFibTask(8); |
344 |
|
try { |
251 |
– |
FailingFibTask f = new FailingFibTask(8); |
345 |
|
f.invoke(); |
346 |
|
shouldThrow(); |
254 |
– |
return NoResult; |
347 |
|
} catch (FJException success) { |
348 |
+ |
checkCompletedAbnormally(f, success); |
349 |
|
} |
350 |
|
return NoResult; |
351 |
< |
} |
352 |
< |
}; |
260 |
< |
mainPool.invoke(a); |
351 |
> |
}}; |
352 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
353 |
|
} |
354 |
|
|
355 |
|
/** |
356 |
|
* quietlyInvoke task returns when task completes abnormally |
357 |
|
*/ |
358 |
|
public void testAbnormalQuietlyInvoke() { |
359 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
360 |
< |
public Integer compute() { |
359 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
360 |
> |
public Integer realCompute() { |
361 |
|
FailingFibTask f = new FailingFibTask(8); |
362 |
|
f.quietlyInvoke(); |
363 |
< |
threadAssertTrue(f.isDone()); |
363 |
> |
assertTrue(f.getException() instanceof FJException); |
364 |
> |
checkCompletedAbnormally(f, f.getException()); |
365 |
|
return NoResult; |
366 |
< |
} |
367 |
< |
}; |
275 |
< |
mainPool.invoke(a); |
366 |
> |
}}; |
367 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
368 |
|
} |
369 |
|
|
370 |
|
/** |
371 |
|
* join of a forked task throws exception when task completes abnormally |
372 |
|
*/ |
373 |
|
public void testAbnormalForkJoin() { |
374 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
375 |
< |
public Integer compute() { |
374 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
375 |
> |
public Integer realCompute() { |
376 |
> |
FailingFibTask f = new FailingFibTask(8); |
377 |
> |
assertSame(f, f.fork()); |
378 |
|
try { |
285 |
– |
FailingFibTask f = new FailingFibTask(8); |
286 |
– |
f.fork(); |
379 |
|
Integer r = f.join(); |
380 |
|
shouldThrow(); |
289 |
– |
return r; |
381 |
|
} catch (FJException success) { |
382 |
+ |
checkCompletedAbnormally(f, success); |
383 |
|
} |
384 |
|
return NoResult; |
385 |
< |
} |
386 |
< |
}; |
295 |
< |
mainPool.invoke(a); |
385 |
> |
}}; |
386 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
387 |
|
} |
388 |
|
|
389 |
|
/** |
390 |
|
* get of a forked task throws exception when task completes abnormally |
391 |
|
*/ |
392 |
|
public void testAbnormalForkGet() { |
393 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
394 |
< |
public Integer compute() { |
393 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
394 |
> |
public Integer realCompute() throws Exception { |
395 |
> |
FailingFibTask f = new FailingFibTask(8); |
396 |
> |
assertSame(f, f.fork()); |
397 |
|
try { |
305 |
– |
FailingFibTask f = new FailingFibTask(8); |
306 |
– |
f.fork(); |
398 |
|
Integer r = f.get(); |
399 |
|
shouldThrow(); |
309 |
– |
return r; |
400 |
|
} catch (ExecutionException success) { |
401 |
< |
} catch (Exception ex) { |
402 |
< |
unexpectedException(ex); |
401 |
> |
Throwable cause = success.getCause(); |
402 |
> |
assertTrue(cause instanceof FJException); |
403 |
> |
checkCompletedAbnormally(f, cause); |
404 |
|
} |
405 |
|
return NoResult; |
406 |
< |
} |
407 |
< |
}; |
317 |
< |
mainPool.invoke(a); |
406 |
> |
}}; |
407 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
408 |
|
} |
409 |
|
|
410 |
|
/** |
411 |
|
* timed get of a forked task throws exception when task completes abnormally |
412 |
|
*/ |
413 |
|
public void testAbnormalForkTimedGet() { |
414 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
415 |
< |
public Integer compute() { |
414 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
415 |
> |
public Integer realCompute() throws Exception { |
416 |
> |
FailingFibTask f = new FailingFibTask(8); |
417 |
> |
assertSame(f, f.fork()); |
418 |
|
try { |
419 |
< |
FailingFibTask f = new FailingFibTask(8); |
328 |
< |
f.fork(); |
329 |
< |
Integer r = f.get(5L, TimeUnit.SECONDS); |
419 |
> |
Integer r = f.get(5L, SECONDS); |
420 |
|
shouldThrow(); |
331 |
– |
return r; |
421 |
|
} catch (ExecutionException success) { |
422 |
< |
} catch (Exception ex) { |
423 |
< |
unexpectedException(ex); |
422 |
> |
Throwable cause = success.getCause(); |
423 |
> |
assertTrue(cause instanceof FJException); |
424 |
> |
checkCompletedAbnormally(f, cause); |
425 |
|
} |
426 |
|
return NoResult; |
427 |
< |
} |
428 |
< |
}; |
339 |
< |
mainPool.invoke(a); |
340 |
< |
} |
341 |
< |
|
342 |
< |
/** |
343 |
< |
* join of a forked task throws exception when task completes abnormally |
344 |
< |
*/ |
345 |
< |
public void testAbnormalForkHelpJoin() { |
346 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
347 |
< |
public Integer compute() { |
348 |
< |
try { |
349 |
< |
FailingFibTask f = new FailingFibTask(8); |
350 |
< |
f.fork(); |
351 |
< |
Integer r = f.helpJoin(); |
352 |
< |
shouldThrow(); |
353 |
< |
return r; |
354 |
< |
} catch (FJException success) { |
355 |
< |
} |
356 |
< |
return NoResult; |
357 |
< |
} |
358 |
< |
}; |
359 |
< |
mainPool.invoke(a); |
360 |
< |
} |
361 |
< |
|
362 |
< |
/** |
363 |
< |
* quietlyHelpJoin of a forked task returns when task completes abnormally. |
364 |
< |
* getException of failed task returns its exception. |
365 |
< |
* isCompletedAbnormally of a failed task returns true. |
366 |
< |
* isCancelled of a failed uncancelled task returns false |
367 |
< |
*/ |
368 |
< |
public void testAbnormalForkQuietlyHelpJoin() { |
369 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
370 |
< |
public Integer compute() { |
371 |
< |
FailingFibTask f = new FailingFibTask(8); |
372 |
< |
f.fork(); |
373 |
< |
f.quietlyHelpJoin(); |
374 |
< |
threadAssertTrue(f.isDone()); |
375 |
< |
threadAssertTrue(f.isCompletedAbnormally()); |
376 |
< |
threadAssertFalse(f.isCancelled()); |
377 |
< |
threadAssertTrue(f.getException() instanceof FJException); |
378 |
< |
return NoResult; |
379 |
< |
} |
380 |
< |
}; |
381 |
< |
mainPool.invoke(a); |
427 |
> |
}}; |
428 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
429 |
|
} |
430 |
|
|
431 |
|
/** |
432 |
|
* quietlyJoin of a forked task returns when task completes abnormally |
433 |
|
*/ |
434 |
|
public void testAbnormalForkQuietlyJoin() { |
435 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
436 |
< |
public Integer compute() { |
435 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
436 |
> |
public Integer realCompute() { |
437 |
|
FailingFibTask f = new FailingFibTask(8); |
438 |
< |
f.fork(); |
438 |
> |
assertSame(f, f.fork()); |
439 |
|
f.quietlyJoin(); |
440 |
< |
threadAssertTrue(f.isDone()); |
441 |
< |
threadAssertTrue(f.isCompletedAbnormally()); |
395 |
< |
threadAssertTrue(f.getException() instanceof FJException); |
440 |
> |
assertTrue(f.getException() instanceof FJException); |
441 |
> |
checkCompletedAbnormally(f, f.getException()); |
442 |
|
return NoResult; |
443 |
< |
} |
444 |
< |
}; |
399 |
< |
mainPool.invoke(a); |
443 |
> |
}}; |
444 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
445 |
|
} |
446 |
|
|
447 |
|
/** |
448 |
|
* invoke task throws exception when task cancelled |
449 |
|
*/ |
450 |
|
public void testCancelledInvoke() { |
451 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
452 |
< |
public Integer compute() { |
451 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
452 |
> |
public Integer realCompute() { |
453 |
> |
FibTask f = new FibTask(8); |
454 |
> |
assertTrue(f.cancel(true)); |
455 |
|
try { |
409 |
– |
FibTask f = new FibTask(8); |
410 |
– |
f.cancel(true); |
456 |
|
Integer r = f.invoke(); |
457 |
|
shouldThrow(); |
413 |
– |
return r; |
458 |
|
} catch (CancellationException success) { |
459 |
+ |
checkCancelled(f); |
460 |
|
} |
461 |
|
return NoResult; |
462 |
< |
} |
463 |
< |
}; |
419 |
< |
mainPool.invoke(a); |
462 |
> |
}}; |
463 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
464 |
|
} |
465 |
|
|
466 |
|
/** |
467 |
|
* join of a forked task throws exception when task cancelled |
468 |
|
*/ |
469 |
|
public void testCancelledForkJoin() { |
470 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
471 |
< |
public Integer compute() { |
470 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
471 |
> |
public Integer realCompute() { |
472 |
> |
FibTask f = new FibTask(8); |
473 |
> |
assertTrue(f.cancel(true)); |
474 |
> |
assertSame(f, f.fork()); |
475 |
|
try { |
429 |
– |
FibTask f = new FibTask(8); |
430 |
– |
f.cancel(true); |
431 |
– |
f.fork(); |
476 |
|
Integer r = f.join(); |
477 |
|
shouldThrow(); |
434 |
– |
return r; |
478 |
|
} catch (CancellationException success) { |
479 |
+ |
checkCancelled(f); |
480 |
|
} |
481 |
|
return NoResult; |
482 |
< |
} |
483 |
< |
}; |
440 |
< |
mainPool.invoke(a); |
482 |
> |
}}; |
483 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
484 |
|
} |
485 |
|
|
486 |
|
/** |
487 |
|
* get of a forked task throws exception when task cancelled |
488 |
|
*/ |
489 |
|
public void testCancelledForkGet() { |
490 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
491 |
< |
public Integer compute() { |
490 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
491 |
> |
public Integer realCompute() throws Exception { |
492 |
> |
FibTask f = new FibTask(8); |
493 |
> |
assertTrue(f.cancel(true)); |
494 |
> |
assertSame(f, f.fork()); |
495 |
|
try { |
450 |
– |
FibTask f = new FibTask(8); |
451 |
– |
f.cancel(true); |
452 |
– |
f.fork(); |
496 |
|
Integer r = f.get(); |
497 |
|
shouldThrow(); |
455 |
– |
return r; |
498 |
|
} catch (CancellationException success) { |
499 |
< |
} catch (Exception ex) { |
458 |
< |
unexpectedException(ex); |
499 |
> |
checkCancelled(f); |
500 |
|
} |
501 |
|
return NoResult; |
502 |
< |
} |
503 |
< |
}; |
463 |
< |
mainPool.invoke(a); |
502 |
> |
}}; |
503 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
504 |
|
} |
505 |
|
|
506 |
|
/** |
507 |
|
* timed get of a forked task throws exception when task cancelled |
508 |
|
*/ |
509 |
|
public void testCancelledForkTimedGet() { |
510 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
511 |
< |
public Integer compute() { |
510 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
511 |
> |
public Integer realCompute() throws Exception { |
512 |
> |
FibTask f = new FibTask(8); |
513 |
> |
assertTrue(f.cancel(true)); |
514 |
> |
assertSame(f, f.fork()); |
515 |
|
try { |
516 |
< |
FibTask f = new FibTask(8); |
474 |
< |
f.cancel(true); |
475 |
< |
f.fork(); |
476 |
< |
Integer r = f.get(5L, TimeUnit.SECONDS); |
516 |
> |
Integer r = f.get(5L, SECONDS); |
517 |
|
shouldThrow(); |
478 |
– |
return r; |
518 |
|
} catch (CancellationException success) { |
519 |
< |
} catch (Exception ex) { |
481 |
< |
unexpectedException(ex); |
519 |
> |
checkCancelled(f); |
520 |
|
} |
521 |
|
return NoResult; |
522 |
< |
} |
523 |
< |
}; |
486 |
< |
mainPool.invoke(a); |
487 |
< |
} |
488 |
< |
|
489 |
< |
/** |
490 |
< |
* join of a forked task throws exception when task cancelled |
491 |
< |
*/ |
492 |
< |
public void testCancelledForkHelpJoin() { |
493 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
494 |
< |
public Integer compute() { |
495 |
< |
try { |
496 |
< |
FibTask f = new FibTask(8); |
497 |
< |
f.cancel(true); |
498 |
< |
f.fork(); |
499 |
< |
Integer r = f.helpJoin(); |
500 |
< |
shouldThrow(); |
501 |
< |
return r; |
502 |
< |
} catch (CancellationException success) { |
503 |
< |
} |
504 |
< |
return NoResult; |
505 |
< |
} |
506 |
< |
}; |
507 |
< |
mainPool.invoke(a); |
508 |
< |
} |
509 |
< |
|
510 |
< |
/** |
511 |
< |
* quietlyHelpJoin of a forked task returns when task cancelled. |
512 |
< |
* getException of cancelled task returns its exception |
513 |
< |
* isCompletedAbnormally of a cancelled task returns true. |
514 |
< |
* isCancelled of a cancelled task returns true |
515 |
< |
*/ |
516 |
< |
public void testCancelledForkQuietlyHelpJoin() { |
517 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
518 |
< |
public Integer compute() { |
519 |
< |
FibTask f = new FibTask(8); |
520 |
< |
f.cancel(true); |
521 |
< |
f.fork(); |
522 |
< |
f.quietlyHelpJoin(); |
523 |
< |
threadAssertTrue(f.isDone()); |
524 |
< |
threadAssertTrue(f.isCompletedAbnormally()); |
525 |
< |
threadAssertTrue(f.isCancelled()); |
526 |
< |
threadAssertTrue(f.getException() instanceof CancellationException); |
527 |
< |
return NoResult; |
528 |
< |
} |
529 |
< |
}; |
530 |
< |
mainPool.invoke(a); |
522 |
> |
}}; |
523 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
524 |
|
} |
525 |
|
|
526 |
|
/** |
527 |
|
* quietlyJoin of a forked task returns when task cancelled |
528 |
|
*/ |
529 |
|
public void testCancelledForkQuietlyJoin() { |
530 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
531 |
< |
public Integer compute() { |
530 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
531 |
> |
public Integer realCompute() { |
532 |
|
FibTask f = new FibTask(8); |
533 |
< |
f.cancel(true); |
534 |
< |
f.fork(); |
533 |
> |
assertTrue(f.cancel(true)); |
534 |
> |
assertSame(f, f.fork()); |
535 |
|
f.quietlyJoin(); |
536 |
< |
threadAssertTrue(f.isDone()); |
544 |
< |
threadAssertTrue(f.isCompletedAbnormally()); |
545 |
< |
threadAssertTrue(f.getException() instanceof CancellationException); |
536 |
> |
checkCancelled(f); |
537 |
|
return NoResult; |
538 |
< |
} |
539 |
< |
}; |
549 |
< |
mainPool.invoke(a); |
538 |
> |
}}; |
539 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
540 |
|
} |
541 |
|
|
542 |
|
/** |
543 |
|
* getPool of executing task returns its pool |
544 |
|
*/ |
545 |
|
public void testGetPool() { |
546 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
547 |
< |
public Integer compute() { |
548 |
< |
threadAssertTrue(getPool() == mainPool); |
546 |
> |
final ForkJoinPool mainPool = mainPool(); |
547 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
548 |
> |
public Integer realCompute() { |
549 |
> |
assertSame(mainPool, getPool()); |
550 |
|
return NoResult; |
551 |
< |
} |
552 |
< |
}; |
562 |
< |
mainPool.invoke(a); |
551 |
> |
}}; |
552 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool, a)); |
553 |
|
} |
554 |
|
|
555 |
|
/** |
556 |
|
* getPool of non-FJ task returns null |
557 |
|
*/ |
558 |
|
public void testGetPool2() { |
559 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
560 |
< |
public Integer compute() { |
561 |
< |
threadAssertTrue(getPool() == null); |
559 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
560 |
> |
public Integer realCompute() { |
561 |
> |
assertNull(getPool()); |
562 |
|
return NoResult; |
563 |
< |
} |
564 |
< |
}; |
575 |
< |
a.invoke(); |
563 |
> |
}}; |
564 |
> |
assertSame(NoResult, a.invoke()); |
565 |
|
} |
566 |
|
|
567 |
|
/** |
568 |
|
* inForkJoinPool of executing task returns true |
569 |
|
*/ |
570 |
|
public void testInForkJoinPool() { |
571 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
572 |
< |
public Integer compute() { |
573 |
< |
threadAssertTrue(inForkJoinPool()); |
571 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
572 |
> |
public Integer realCompute() { |
573 |
> |
assertTrue(inForkJoinPool()); |
574 |
|
return NoResult; |
575 |
< |
} |
576 |
< |
}; |
588 |
< |
mainPool.invoke(a); |
575 |
> |
}}; |
576 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
577 |
|
} |
578 |
|
|
579 |
|
/** |
580 |
|
* inForkJoinPool of non-FJ task returns false |
581 |
|
*/ |
582 |
|
public void testInForkJoinPool2() { |
583 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
584 |
< |
public Integer compute() { |
585 |
< |
threadAssertTrue(!inForkJoinPool()); |
583 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
584 |
> |
public Integer realCompute() { |
585 |
> |
assertFalse(inForkJoinPool()); |
586 |
|
return NoResult; |
587 |
< |
} |
588 |
< |
}; |
601 |
< |
a.invoke(); |
587 |
> |
}}; |
588 |
> |
assertSame(NoResult, a.invoke()); |
589 |
|
} |
590 |
|
|
591 |
|
/** |
592 |
< |
* setRawResult(null) succeeds |
592 |
> |
* The value set by setRawResult is returned by getRawResult |
593 |
|
*/ |
594 |
|
public void testSetRawResult() { |
595 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
596 |
< |
public Integer compute() { |
595 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
596 |
> |
public Integer realCompute() { |
597 |
|
setRawResult(NoResult); |
598 |
+ |
assertSame(NoResult, getRawResult()); |
599 |
|
return NoResult; |
600 |
|
} |
601 |
|
}; |
602 |
< |
assertEquals(a.invoke(), NoResult); |
602 |
> |
assertSame(NoResult, a.invoke()); |
603 |
|
} |
604 |
|
|
605 |
|
/** |
606 |
< |
* A reinitialized task may be re-invoked |
606 |
> |
* A reinitialized normally completed task may be re-invoked |
607 |
|
*/ |
608 |
|
public void testReinitialize() { |
609 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
610 |
< |
public Integer compute() { |
609 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
610 |
> |
public Integer realCompute() { |
611 |
|
FibTask f = new FibTask(8); |
612 |
< |
Integer r = f.invoke(); |
613 |
< |
threadAssertTrue(r == 21); |
614 |
< |
threadAssertTrue(f.isDone()); |
615 |
< |
threadAssertFalse(f.isCancelled()); |
616 |
< |
threadAssertFalse(f.isCompletedAbnormally()); |
617 |
< |
f.reinitialize(); |
618 |
< |
r = f.invoke(); |
619 |
< |
threadAssertTrue(r == 21); |
612 |
> |
checkNotDone(f); |
613 |
> |
|
614 |
> |
for (int i = 0; i < 3; i++) { |
615 |
> |
Integer r = f.invoke(); |
616 |
> |
assertEquals(21, (int) r); |
617 |
> |
checkCompletedNormally(f, r); |
618 |
> |
f.reinitialize(); |
619 |
> |
f.publicSetRawResult(null); |
620 |
> |
checkNotDone(f); |
621 |
> |
} |
622 |
|
return NoResult; |
623 |
< |
} |
624 |
< |
}; |
625 |
< |
mainPool.invoke(a); |
623 |
> |
}}; |
624 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
625 |
> |
} |
626 |
> |
|
627 |
> |
/** |
628 |
> |
* A reinitialized abnormally completed task may be re-invoked |
629 |
> |
*/ |
630 |
> |
public void testReinitializeAbnormal() { |
631 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
632 |
> |
public Integer realCompute() { |
633 |
> |
FailingFibTask f = new FailingFibTask(8); |
634 |
> |
checkNotDone(f); |
635 |
> |
|
636 |
> |
for (int i = 0; i < 3; i++) { |
637 |
> |
try { |
638 |
> |
f.invoke(); |
639 |
> |
shouldThrow(); |
640 |
> |
} catch (FJException success) { |
641 |
> |
checkCompletedAbnormally(f, success); |
642 |
> |
} |
643 |
> |
f.reinitialize(); |
644 |
> |
checkNotDone(f); |
645 |
> |
} |
646 |
> |
return NoResult; |
647 |
> |
}}; |
648 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
649 |
|
} |
650 |
|
|
651 |
|
/** |
652 |
|
* invoke task throws exception after invoking completeExceptionally |
653 |
|
*/ |
654 |
|
public void testCompleteExceptionally() { |
655 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
656 |
< |
public Integer compute() { |
655 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
656 |
> |
public Integer realCompute() { |
657 |
> |
FibTask f = new FibTask(8); |
658 |
> |
f.completeExceptionally(new FJException()); |
659 |
|
try { |
645 |
– |
FibTask f = new FibTask(8); |
646 |
– |
f.completeExceptionally(new FJException()); |
660 |
|
Integer r = f.invoke(); |
661 |
|
shouldThrow(); |
649 |
– |
return r; |
662 |
|
} catch (FJException success) { |
663 |
+ |
checkCompletedAbnormally(f, success); |
664 |
|
} |
665 |
|
return NoResult; |
666 |
< |
} |
667 |
< |
}; |
655 |
< |
mainPool.invoke(a); |
666 |
> |
}}; |
667 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
668 |
|
} |
669 |
|
|
670 |
|
/** |
671 |
|
* invoke task suppresses execution invoking complete |
672 |
|
*/ |
673 |
|
public void testComplete() { |
674 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
675 |
< |
public Integer compute() { |
674 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
675 |
> |
public Integer realCompute() { |
676 |
|
FibTask f = new FibTask(8); |
677 |
|
f.complete(NoResult); |
678 |
|
Integer r = f.invoke(); |
679 |
< |
threadAssertTrue(f.isDone()); |
680 |
< |
threadAssertTrue(r == NoResult); |
679 |
> |
assertSame(NoResult, r); |
680 |
> |
checkCompletedNormally(f, NoResult); |
681 |
|
return r; |
682 |
< |
} |
683 |
< |
}; |
672 |
< |
mainPool.invoke(a); |
682 |
> |
}}; |
683 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
684 |
|
} |
685 |
|
|
686 |
|
/** |
687 |
|
* invokeAll(t1, t2) invokes all task arguments |
688 |
|
*/ |
689 |
|
public void testInvokeAll2() { |
690 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
691 |
< |
public Integer compute() { |
690 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
691 |
> |
public Integer realCompute() { |
692 |
|
FibTask f = new FibTask(8); |
693 |
|
FibTask g = new FibTask(9); |
694 |
|
invokeAll(f, g); |
695 |
< |
threadAssertTrue(f.isDone()); |
696 |
< |
threadAssertTrue(f.join() == 21); |
686 |
< |
threadAssertTrue(g.isDone()); |
687 |
< |
threadAssertTrue(g.join() == 34); |
695 |
> |
checkCompletedNormally(f, 21); |
696 |
> |
checkCompletedNormally(g, 34); |
697 |
|
return NoResult; |
698 |
< |
} |
699 |
< |
}; |
691 |
< |
mainPool.invoke(a); |
698 |
> |
}}; |
699 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
700 |
|
} |
701 |
|
|
702 |
|
/** |
703 |
|
* invokeAll(tasks) with 1 argument invokes task |
704 |
|
*/ |
705 |
|
public void testInvokeAll1() { |
706 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
707 |
< |
public Integer compute() { |
706 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
707 |
> |
public Integer realCompute() { |
708 |
|
FibTask f = new FibTask(8); |
709 |
|
invokeAll(f); |
710 |
< |
threadAssertTrue(f.isDone()); |
703 |
< |
threadAssertTrue(f.join() == 21); |
710 |
> |
checkCompletedNormally(f, 21); |
711 |
|
return NoResult; |
712 |
< |
} |
713 |
< |
}; |
707 |
< |
mainPool.invoke(a); |
712 |
> |
}}; |
713 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
714 |
|
} |
715 |
|
|
716 |
|
/** |
717 |
|
* invokeAll(tasks) with > 2 argument invokes tasks |
718 |
|
*/ |
719 |
|
public void testInvokeAll3() { |
720 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
721 |
< |
public Integer compute() { |
720 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
721 |
> |
public Integer realCompute() { |
722 |
|
FibTask f = new FibTask(8); |
723 |
|
FibTask g = new FibTask(9); |
724 |
|
FibTask h = new FibTask(7); |
725 |
|
invokeAll(f, g, h); |
726 |
< |
threadAssertTrue(f.isDone()); |
727 |
< |
threadAssertTrue(f.join() == 21); |
728 |
< |
threadAssertTrue(g.isDone()); |
729 |
< |
threadAssertTrue(g.join() == 34); |
730 |
< |
threadAssertTrue(h.isDone()); |
731 |
< |
threadAssertTrue(h.join() == 13); |
726 |
> |
assertTrue(f.isDone()); |
727 |
> |
assertTrue(g.isDone()); |
728 |
> |
assertTrue(h.isDone()); |
729 |
> |
checkCompletedNormally(f, 21); |
730 |
> |
checkCompletedNormally(g, 34); |
731 |
> |
checkCompletedNormally(h, 13); |
732 |
|
return NoResult; |
733 |
< |
} |
734 |
< |
}; |
729 |
< |
mainPool.invoke(a); |
733 |
> |
}}; |
734 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
735 |
|
} |
736 |
|
|
737 |
|
/** |
738 |
|
* invokeAll(collection) invokes all tasks in the collection |
739 |
|
*/ |
740 |
|
public void testInvokeAllCollection() { |
741 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
742 |
< |
public Integer compute() { |
741 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
742 |
> |
public Integer realCompute() { |
743 |
|
FibTask f = new FibTask(8); |
744 |
|
FibTask g = new FibTask(9); |
745 |
|
FibTask h = new FibTask(7); |
748 |
|
set.add(g); |
749 |
|
set.add(h); |
750 |
|
invokeAll(set); |
751 |
< |
threadAssertTrue(f.isDone()); |
752 |
< |
threadAssertTrue(f.join() == 21); |
753 |
< |
threadAssertTrue(g.isDone()); |
754 |
< |
threadAssertTrue(g.join() == 34); |
755 |
< |
threadAssertTrue(h.isDone()); |
756 |
< |
threadAssertTrue(h.join() == 13); |
751 |
> |
assertTrue(f.isDone()); |
752 |
> |
assertTrue(g.isDone()); |
753 |
> |
assertTrue(h.isDone()); |
754 |
> |
checkCompletedNormally(f, 21); |
755 |
> |
checkCompletedNormally(g, 34); |
756 |
> |
checkCompletedNormally(h, 13); |
757 |
|
return NoResult; |
758 |
< |
} |
759 |
< |
}; |
755 |
< |
mainPool.invoke(a); |
758 |
> |
}}; |
759 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
760 |
|
} |
761 |
|
|
762 |
+ |
/** |
763 |
+ |
* invokeAll(tasks) with any null task throws NPE |
764 |
+ |
*/ |
765 |
+ |
public void testInvokeAllNPE() { |
766 |
+ |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
767 |
+ |
public Integer realCompute() { |
768 |
+ |
FibTask f = new FibTask(8); |
769 |
+ |
FibTask g = new FibTask(9); |
770 |
+ |
FibTask h = null; |
771 |
+ |
try { |
772 |
+ |
invokeAll(f, g, h); |
773 |
+ |
shouldThrow(); |
774 |
+ |
} catch (NullPointerException success) {} |
775 |
+ |
return NoResult; |
776 |
+ |
}}; |
777 |
+ |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
778 |
+ |
} |
779 |
|
|
780 |
|
/** |
781 |
|
* invokeAll(t1, t2) throw exception if any task does |
782 |
|
*/ |
783 |
|
public void testAbnormalInvokeAll2() { |
784 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
785 |
< |
public Integer compute() { |
784 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
785 |
> |
public Integer realCompute() { |
786 |
> |
FibTask f = new FibTask(8); |
787 |
> |
FailingFibTask g = new FailingFibTask(9); |
788 |
|
try { |
766 |
– |
FibTask f = new FibTask(8); |
767 |
– |
FailingFibTask g = new FailingFibTask(9); |
789 |
|
invokeAll(f, g); |
790 |
|
shouldThrow(); |
770 |
– |
return NoResult; |
791 |
|
} catch (FJException success) { |
792 |
+ |
checkCompletedAbnormally(g, success); |
793 |
|
} |
794 |
|
return NoResult; |
795 |
< |
} |
796 |
< |
}; |
776 |
< |
mainPool.invoke(a); |
795 |
> |
}}; |
796 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
797 |
|
} |
798 |
|
|
799 |
|
/** |
800 |
|
* invokeAll(tasks) with 1 argument throws exception if task does |
801 |
|
*/ |
802 |
|
public void testAbnormalInvokeAll1() { |
803 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
804 |
< |
public Integer compute() { |
803 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
804 |
> |
public Integer realCompute() { |
805 |
> |
FailingFibTask g = new FailingFibTask(9); |
806 |
|
try { |
786 |
– |
FailingFibTask g = new FailingFibTask(9); |
807 |
|
invokeAll(g); |
808 |
|
shouldThrow(); |
789 |
– |
return NoResult; |
809 |
|
} catch (FJException success) { |
810 |
+ |
checkCompletedAbnormally(g, success); |
811 |
|
} |
812 |
|
return NoResult; |
813 |
< |
} |
814 |
< |
}; |
795 |
< |
mainPool.invoke(a); |
813 |
> |
}}; |
814 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
815 |
|
} |
816 |
|
|
817 |
|
/** |
818 |
|
* invokeAll(tasks) with > 2 argument throws exception if any task does |
819 |
|
*/ |
820 |
|
public void testAbnormalInvokeAll3() { |
821 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
822 |
< |
public Integer compute() { |
821 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
822 |
> |
public Integer realCompute() { |
823 |
> |
FibTask f = new FibTask(8); |
824 |
> |
FailingFibTask g = new FailingFibTask(9); |
825 |
> |
FibTask h = new FibTask(7); |
826 |
|
try { |
805 |
– |
FibTask f = new FibTask(8); |
806 |
– |
FailingFibTask g = new FailingFibTask(9); |
807 |
– |
FibTask h = new FibTask(7); |
827 |
|
invokeAll(f, g, h); |
828 |
|
shouldThrow(); |
810 |
– |
return NoResult; |
829 |
|
} catch (FJException success) { |
830 |
+ |
checkCompletedAbnormally(g, success); |
831 |
|
} |
832 |
|
return NoResult; |
833 |
< |
} |
834 |
< |
}; |
816 |
< |
mainPool.invoke(a); |
833 |
> |
}}; |
834 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
835 |
|
} |
836 |
|
|
837 |
|
/** |
838 |
|
* invokeAll(collection) throws exception if any task does |
839 |
|
*/ |
840 |
|
public void testAbnormalInvokeAllCollection() { |
841 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
842 |
< |
public Integer compute() { |
841 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
842 |
> |
public Integer realCompute() { |
843 |
> |
FailingFibTask f = new FailingFibTask(8); |
844 |
> |
FibTask g = new FibTask(9); |
845 |
> |
FibTask h = new FibTask(7); |
846 |
> |
HashSet set = new HashSet(); |
847 |
> |
set.add(f); |
848 |
> |
set.add(g); |
849 |
> |
set.add(h); |
850 |
|
try { |
826 |
– |
FailingFibTask f = new FailingFibTask(8); |
827 |
– |
FibTask g = new FibTask(9); |
828 |
– |
FibTask h = new FibTask(7); |
829 |
– |
HashSet set = new HashSet(); |
830 |
– |
set.add(f); |
831 |
– |
set.add(g); |
832 |
– |
set.add(h); |
851 |
|
invokeAll(set); |
852 |
|
shouldThrow(); |
835 |
– |
return NoResult; |
853 |
|
} catch (FJException success) { |
854 |
+ |
checkCompletedAbnormally(f, success); |
855 |
|
} |
856 |
|
return NoResult; |
857 |
< |
} |
858 |
< |
}; |
841 |
< |
mainPool.invoke(a); |
857 |
> |
}}; |
858 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
859 |
|
} |
860 |
|
|
861 |
|
/** |
863 |
|
* and suppresses execution |
864 |
|
*/ |
865 |
|
public void testTryUnfork() { |
866 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
867 |
< |
public Integer compute() { |
866 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
867 |
> |
public Integer realCompute() { |
868 |
|
FibTask g = new FibTask(9); |
869 |
< |
g.fork(); |
869 |
> |
assertSame(g, g.fork()); |
870 |
|
FibTask f = new FibTask(8); |
871 |
< |
f.fork(); |
872 |
< |
threadAssertTrue(f.tryUnfork()); |
871 |
> |
assertSame(f, f.fork()); |
872 |
> |
assertTrue(f.tryUnfork()); |
873 |
|
helpQuiesce(); |
874 |
< |
threadAssertFalse(f.isDone()); |
875 |
< |
threadAssertTrue(g.isDone()); |
874 |
> |
checkNotDone(f); |
875 |
> |
checkCompletedNormally(g, 34); |
876 |
|
return NoResult; |
877 |
< |
} |
878 |
< |
}; |
862 |
< |
singletonPool.invoke(a); |
877 |
> |
}}; |
878 |
> |
assertSame(NoResult, testInvokeOnPool(singletonPool(), a)); |
879 |
|
} |
880 |
|
|
881 |
|
/** |
883 |
|
* there are more tasks than threads |
884 |
|
*/ |
885 |
|
public void testGetSurplusQueuedTaskCount() { |
886 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
887 |
< |
public Integer compute() { |
886 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
887 |
> |
public Integer realCompute() { |
888 |
|
FibTask h = new FibTask(7); |
889 |
< |
h.fork(); |
889 |
> |
assertSame(h, h.fork()); |
890 |
|
FibTask g = new FibTask(9); |
891 |
< |
g.fork(); |
891 |
> |
assertSame(g, g.fork()); |
892 |
|
FibTask f = new FibTask(8); |
893 |
< |
f.fork(); |
894 |
< |
threadAssertTrue(getSurplusQueuedTaskCount() > 0); |
893 |
> |
assertSame(f, f.fork()); |
894 |
> |
assertTrue(getSurplusQueuedTaskCount() > 0); |
895 |
|
helpQuiesce(); |
896 |
+ |
assertEquals(0, getSurplusQueuedTaskCount()); |
897 |
+ |
checkCompletedNormally(f, 21); |
898 |
+ |
checkCompletedNormally(g, 34); |
899 |
+ |
checkCompletedNormally(h, 13); |
900 |
|
return NoResult; |
901 |
< |
} |
902 |
< |
}; |
883 |
< |
singletonPool.invoke(a); |
901 |
> |
}}; |
902 |
> |
assertSame(NoResult, testInvokeOnPool(singletonPool(), a)); |
903 |
|
} |
904 |
|
|
905 |
|
/** |
906 |
|
* peekNextLocalTask returns most recent unexecuted task. |
907 |
|
*/ |
908 |
|
public void testPeekNextLocalTask() { |
909 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
910 |
< |
public Integer compute() { |
909 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
910 |
> |
public Integer realCompute() { |
911 |
|
FibTask g = new FibTask(9); |
912 |
< |
g.fork(); |
912 |
> |
assertSame(g, g.fork()); |
913 |
|
FibTask f = new FibTask(8); |
914 |
< |
f.fork(); |
915 |
< |
threadAssertTrue(peekNextLocalTask() == f); |
916 |
< |
f.join(); |
898 |
< |
threadAssertTrue(f.isDone()); |
914 |
> |
assertSame(f, f.fork()); |
915 |
> |
assertSame(f, peekNextLocalTask()); |
916 |
> |
checkCompletesNormally(f, 21); |
917 |
|
helpQuiesce(); |
918 |
+ |
checkCompletedNormally(g, 34); |
919 |
|
return NoResult; |
920 |
< |
} |
921 |
< |
}; |
903 |
< |
singletonPool.invoke(a); |
920 |
> |
}}; |
921 |
> |
assertSame(NoResult, testInvokeOnPool(singletonPool(), a)); |
922 |
|
} |
923 |
|
|
924 |
|
/** |
926 |
|
* without executing it |
927 |
|
*/ |
928 |
|
public void testPollNextLocalTask() { |
929 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
930 |
< |
public Integer compute() { |
929 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
930 |
> |
public Integer realCompute() { |
931 |
|
FibTask g = new FibTask(9); |
932 |
< |
g.fork(); |
932 |
> |
assertSame(g, g.fork()); |
933 |
|
FibTask f = new FibTask(8); |
934 |
< |
f.fork(); |
935 |
< |
threadAssertTrue(pollNextLocalTask() == f); |
934 |
> |
assertSame(f, f.fork()); |
935 |
> |
assertSame(f, pollNextLocalTask()); |
936 |
|
helpQuiesce(); |
937 |
< |
threadAssertFalse(f.isDone()); |
937 |
> |
checkNotDone(f); |
938 |
> |
checkCompletedNormally(g, 34); |
939 |
|
return NoResult; |
940 |
< |
} |
941 |
< |
}; |
923 |
< |
singletonPool.invoke(a); |
940 |
> |
}}; |
941 |
> |
assertSame(NoResult, testInvokeOnPool(singletonPool(), a)); |
942 |
|
} |
943 |
|
|
944 |
|
/** |
945 |
< |
* pollTask returns an unexecuted task |
928 |
< |
* without executing it |
945 |
> |
* pollTask returns an unexecuted task without executing it |
946 |
|
*/ |
947 |
|
public void testPollTask() { |
948 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
949 |
< |
public Integer compute() { |
948 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
949 |
> |
public Integer realCompute() { |
950 |
|
FibTask g = new FibTask(9); |
951 |
< |
g.fork(); |
951 |
> |
assertSame(g, g.fork()); |
952 |
|
FibTask f = new FibTask(8); |
953 |
< |
f.fork(); |
954 |
< |
threadAssertTrue(pollTask() == f); |
953 |
> |
assertSame(f, f.fork()); |
954 |
> |
assertSame(f, pollTask()); |
955 |
|
helpQuiesce(); |
956 |
< |
threadAssertFalse(f.isDone()); |
957 |
< |
threadAssertTrue(g.isDone()); |
956 |
> |
checkNotDone(f); |
957 |
> |
checkCompletedNormally(g, 34); |
958 |
|
return NoResult; |
959 |
< |
} |
960 |
< |
}; |
944 |
< |
singletonPool.invoke(a); |
959 |
> |
}}; |
960 |
> |
assertSame(NoResult, testInvokeOnPool(singletonPool(), a)); |
961 |
|
} |
962 |
|
|
963 |
|
/** |
964 |
|
* peekNextLocalTask returns least recent unexecuted task in async mode |
965 |
|
*/ |
966 |
|
public void testPeekNextLocalTaskAsync() { |
967 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
968 |
< |
public Integer compute() { |
967 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
968 |
> |
public Integer realCompute() { |
969 |
|
FibTask g = new FibTask(9); |
970 |
< |
g.fork(); |
970 |
> |
assertSame(g, g.fork()); |
971 |
|
FibTask f = new FibTask(8); |
972 |
< |
f.fork(); |
973 |
< |
threadAssertTrue(peekNextLocalTask() == g); |
974 |
< |
f.join(); |
972 |
> |
assertSame(f, f.fork()); |
973 |
> |
assertSame(g, peekNextLocalTask()); |
974 |
> |
assertEquals(21, (int) f.join()); |
975 |
|
helpQuiesce(); |
976 |
< |
threadAssertTrue(f.isDone()); |
976 |
> |
checkCompletedNormally(f, 21); |
977 |
> |
checkCompletedNormally(g, 34); |
978 |
|
return NoResult; |
979 |
< |
} |
980 |
< |
}; |
964 |
< |
asyncSingletonPool.invoke(a); |
979 |
> |
}}; |
980 |
> |
assertSame(NoResult, testInvokeOnPool(asyncSingletonPool(), a)); |
981 |
|
} |
982 |
|
|
983 |
|
/** |
984 |
< |
* pollNextLocalTask returns least recent unexecuted task |
985 |
< |
* without executing it, in async mode |
984 |
> |
* pollNextLocalTask returns least recent unexecuted task without |
985 |
> |
* executing it, in async mode |
986 |
|
*/ |
987 |
|
public void testPollNextLocalTaskAsync() { |
988 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
989 |
< |
public Integer compute() { |
988 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
989 |
> |
public Integer realCompute() { |
990 |
|
FibTask g = new FibTask(9); |
991 |
< |
g.fork(); |
991 |
> |
assertSame(g, g.fork()); |
992 |
|
FibTask f = new FibTask(8); |
993 |
< |
f.fork(); |
994 |
< |
threadAssertTrue(pollNextLocalTask() == g); |
993 |
> |
assertSame(f, f.fork()); |
994 |
> |
assertSame(g, pollNextLocalTask()); |
995 |
|
helpQuiesce(); |
996 |
< |
threadAssertTrue(f.isDone()); |
997 |
< |
threadAssertFalse(g.isDone()); |
996 |
> |
checkCompletedNormally(f, 21); |
997 |
> |
checkNotDone(g); |
998 |
|
return NoResult; |
999 |
< |
} |
1000 |
< |
}; |
985 |
< |
asyncSingletonPool.invoke(a); |
999 |
> |
}}; |
1000 |
> |
assertSame(NoResult, testInvokeOnPool(asyncSingletonPool(), a)); |
1001 |
|
} |
1002 |
|
|
1003 |
|
/** |
1004 |
< |
* pollTask returns an unexecuted task |
1005 |
< |
* without executing it, in async mode |
1004 |
> |
* pollTask returns an unexecuted task without executing it, in |
1005 |
> |
* async mode |
1006 |
|
*/ |
1007 |
|
public void testPollTaskAsync() { |
1008 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
1009 |
< |
public Integer compute() { |
1008 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
1009 |
> |
public Integer realCompute() { |
1010 |
|
FibTask g = new FibTask(9); |
1011 |
< |
g.fork(); |
1011 |
> |
assertSame(g, g.fork()); |
1012 |
|
FibTask f = new FibTask(8); |
1013 |
< |
f.fork(); |
1014 |
< |
threadAssertTrue(pollTask() == g); |
1013 |
> |
assertSame(f, f.fork()); |
1014 |
> |
assertSame(g, pollTask()); |
1015 |
|
helpQuiesce(); |
1016 |
< |
threadAssertTrue(f.isDone()); |
1017 |
< |
threadAssertFalse(g.isDone()); |
1016 |
> |
checkCompletedNormally(f, 21); |
1017 |
> |
checkNotDone(g); |
1018 |
|
return NoResult; |
1019 |
< |
} |
1020 |
< |
}; |
1006 |
< |
asyncSingletonPool.invoke(a); |
1019 |
> |
}}; |
1020 |
> |
assertSame(NoResult, testInvokeOnPool(asyncSingletonPool(), a)); |
1021 |
|
} |
1022 |
|
|
1023 |
|
} |