42 |
|
* this, you would create a GraphVisitor for the root node with null |
43 |
|
* parent, and <tt>invoke</tt> in a ForkJoinPool. Upon return, all |
44 |
|
* reachable nodes will have been visited. |
45 |
< |
* |
45 |
> |
* |
46 |
|
* <pre> |
47 |
|
* class GraphVisitor extends LinkedAsyncAction { |
48 |
|
* final Node node; |
93 |
|
*/ |
94 |
|
protected LinkedAsyncAction(LinkedAsyncAction parent) { |
95 |
|
this.parent = parent; |
96 |
< |
if (parent != null) |
96 |
> |
if (parent != null) |
97 |
|
pendingCountUpdater.incrementAndGet(parent); |
98 |
|
} |
99 |
|
|
109 |
|
*/ |
110 |
|
protected LinkedAsyncAction(LinkedAsyncAction parent, boolean register) { |
111 |
|
this.parent = parent; |
112 |
< |
if (parent != null && register) |
112 |
> |
if (parent != null && register) |
113 |
|
pendingCountUpdater.incrementAndGet(parent); |
114 |
|
} |
115 |
|
|
127 |
|
* to complete before it completes |
128 |
|
* @param pending the pending join count |
129 |
|
*/ |
130 |
< |
protected LinkedAsyncAction(LinkedAsyncAction parent, |
130 |
> |
protected LinkedAsyncAction(LinkedAsyncAction parent, |
131 |
|
boolean register, |
132 |
|
int pending) { |
133 |
|
this.parent = parent; |
134 |
|
pendingCount = pending; |
135 |
< |
if (parent != null && register) |
135 |
> |
if (parent != null && register) |
136 |
|
pendingCountUpdater.incrementAndGet(parent); |
137 |
|
} |
138 |
|
|
187 |
|
* exception is encountered in any <tt>onCompletion</tt> |
188 |
|
* invocation, that task and its ancestors |
189 |
|
* <tt>finishExceptionally</tt>. |
190 |
< |
* |
190 |
> |
* |
191 |
|
* @param result must be <tt>null</tt>. |
192 |
|
*/ |
193 |
|
public final void finish(Void result) { |
200 |
|
} catch (Throwable rex) { |
201 |
|
a.finishExceptionally(rex); |
202 |
|
return; |
203 |
< |
} |
203 |
> |
} |
204 |
|
a.setDone(); |
205 |
|
a = a.parent; |
206 |
|
} |
244 |
|
* Returns this task's parent, or null if none. |
245 |
|
* @return this task's parent, or null if none. |
246 |
|
*/ |
247 |
< |
public final LinkedAsyncAction getParent() { |
248 |
< |
return parent; |
247 |
> |
public final LinkedAsyncAction getParent() { |
248 |
> |
return parent; |
249 |
|
} |
250 |
|
|
251 |
|
/** |
252 |
|
* Returns the number of subtasks that have not yet completed. |
253 |
|
* @return the number of subtasks that have not yet completed. |
254 |
|
*/ |
255 |
< |
public final int getPendingSubtaskCount() { |
256 |
< |
return pendingCount; |
255 |
> |
public final int getPendingSubtaskCount() { |
256 |
> |
return pendingCount; |
257 |
|
} |
258 |
|
|
259 |
|
/** |
260 |
|
* Always returns null. |
261 |
|
* @return null |
262 |
|
*/ |
263 |
< |
public final Void rawResult() { |
264 |
< |
return null; |
263 |
> |
public final Void rawResult() { |
264 |
> |
return null; |
265 |
|
} |
266 |
|
|
267 |
|
/** |
295 |
|
if (pendingCount != 0) |
296 |
|
pendingCount = 0; |
297 |
|
this.parent = parent; |
298 |
< |
if (parent != null && register) |
298 |
> |
if (parent != null && register) |
299 |
|
pendingCountUpdater.incrementAndGet(parent); |
300 |
|
} |
301 |
|
|
307 |
|
* to complete before it completes |
308 |
|
* @param pending the pending join count |
309 |
|
*/ |
310 |
< |
public void reinitialize(LinkedAsyncAction parent, |
310 |
> |
public void reinitialize(LinkedAsyncAction parent, |
311 |
|
boolean register, |
312 |
|
int pending) { |
313 |
|
super.reinitialize(); |
314 |
|
pendingCount = pending; |
315 |
|
this.parent = parent; |
316 |
< |
if (parent != null && register) |
316 |
> |
if (parent != null && register) |
317 |
|
pendingCountUpdater.incrementAndGet(parent); |
318 |
|
} |
319 |
|
|