205 |
|
} |
206 |
|
|
207 |
|
/** |
208 |
< |
* Record exception and set exceptional completion |
208 |
> |
* Records exception and sets exceptional completion. |
209 |
> |
* |
210 |
|
* @return status on exit |
211 |
|
*/ |
212 |
|
private void setExceptionalCompletion(Throwable rex) { |
215 |
|
} |
216 |
|
|
217 |
|
/** |
218 |
< |
* Blocks a worker thread until completion. Called only by pool. |
218 |
> |
* Blocks a worker thread until completion. Called only by |
219 |
> |
* pool. Currently unused -- pool-based waits use timeout |
220 |
> |
* version below. |
221 |
|
*/ |
222 |
|
final void internalAwaitDone() { |
223 |
|
int s; // the odd construction reduces lock bias effects |
234 |
|
} |
235 |
|
|
236 |
|
/** |
237 |
+ |
* Blocks a worker thread until completed or timed out. Called |
238 |
+ |
* only by pool. |
239 |
+ |
* |
240 |
+ |
* @return status on exit |
241 |
+ |
*/ |
242 |
+ |
final int internalAwaitDone(long millis) { |
243 |
+ |
int s; |
244 |
+ |
if ((s = status) >= 0) { |
245 |
+ |
try { |
246 |
+ |
synchronized(this) { |
247 |
+ |
if (UNSAFE.compareAndSwapInt(this, statusOffset, s,SIGNAL)) |
248 |
+ |
wait(millis, 0); |
249 |
+ |
} |
250 |
+ |
} catch (InterruptedException ie) { |
251 |
+ |
cancelIfTerminating(); |
252 |
+ |
} |
253 |
+ |
s = status; |
254 |
+ |
} |
255 |
+ |
return s; |
256 |
+ |
} |
257 |
+ |
|
258 |
+ |
/** |
259 |
|
* Blocks a non-worker-thread until completion. |
260 |
|
*/ |
261 |
|
private void externalAwaitDone() { |
339 |
|
|
340 |
|
/** |
341 |
|
* Commences performing this task, awaits its completion if |
342 |
< |
* necessary, and return its result, or throws an (unchecked) |
342 |
> |
* necessary, and returns its result, or throws an (unchecked) |
343 |
|
* exception if the underlying computation did so. |
344 |
|
* |
345 |
|
* @return the computed result |
535 |
|
} |
536 |
|
|
537 |
|
/** |
538 |
< |
* Cancels ignoring exceptions if worker is terminating |
538 |
> |
* Cancels if current thread is a terminating worker thread, |
539 |
> |
* ignoring any exceptions thrown by cancel. |
540 |
|
*/ |
541 |
|
final void cancelIfTerminating() { |
542 |
|
Thread t = Thread.currentThread(); |
1095 |
|
private static final long serialVersionUID = -7721805057305804111L; |
1096 |
|
|
1097 |
|
/** |
1098 |
< |
* Saves the state to a stream. |
1098 |
> |
* Saves the state to a stream (that is, serializes it). |
1099 |
|
* |
1100 |
|
* @serialData the current run status and the exception thrown |
1101 |
|
* during execution, or {@code null} if none |
1108 |
|
} |
1109 |
|
|
1110 |
|
/** |
1111 |
< |
* Reconstitutes the instance from a stream. |
1111 |
> |
* Reconstitutes the instance from a stream (that is, deserializes it). |
1112 |
|
* |
1113 |
|
* @param s the stream |
1114 |
|
*/ |