7 |
|
package jsr166y; |
8 |
|
|
9 |
|
import java.util.concurrent.*; |
10 |
< |
import java.util.concurrent.atomic.*; |
10 |
> |
|
11 |
> |
import java.util.concurrent.atomic.AtomicReference; |
12 |
|
import java.util.concurrent.locks.LockSupport; |
12 |
– |
import sun.misc.Unsafe; |
13 |
– |
import java.lang.reflect.*; |
13 |
|
|
14 |
|
/** |
15 |
|
* A reusable synchronization barrier, similar in functionality to a |
32 |
|
* zero, and advancing when all parties reach the barrier (wrapping |
33 |
|
* around to zero after reaching {@code Integer.MAX_VALUE}). |
34 |
|
* |
35 |
< |
* <li> Like a CyclicBarrier, a Phaser may be repeatedly awaited. |
36 |
< |
* Method {@code arriveAndAwaitAdvance} has effect analogous to |
37 |
< |
* {@code CyclicBarrier.await}. However, Phasers separate two |
38 |
< |
* aspects of coordination, that may also be invoked independently: |
35 |
> |
* <li> Like a {@code CyclicBarrier}, a phaser may be repeatedly |
36 |
> |
* awaited. Method {@link #arriveAndAwaitAdvance} has effect |
37 |
> |
* analogous to {@link java.util.concurrent.CyclicBarrier#await |
38 |
> |
* CyclicBarrier.await}. However, phasers separate two aspects of |
39 |
> |
* coordination, which may also be invoked independently: |
40 |
|
* |
41 |
|
* <ul> |
42 |
|
* |
43 |
< |
* <li> Arriving at a barrier. Methods {@code arrive} and |
44 |
< |
* {@code arriveAndDeregister} do not block, but return |
43 |
> |
* <li> Arriving at a barrier. Methods {@link #arrive} and |
44 |
> |
* {@link #arriveAndDeregister} do not block, but return |
45 |
|
* the phase value current upon entry to the method. |
46 |
|
* |
47 |
< |
* <li> Awaiting others. Method {@code awaitAdvance} requires an |
47 |
> |
* <li> Awaiting others. Method {@link #awaitAdvance} requires an |
48 |
|
* argument indicating the entry phase, and returns when the |
49 |
|
* barrier advances to a new phase. |
50 |
|
* </ul> |
51 |
|
* |
52 |
|
* |
53 |
|
* <li> Barrier actions, performed by the task triggering a phase |
54 |
< |
* advance while others may be waiting, are arranged by overriding |
55 |
< |
* method {@code onAdvance}, that also controls termination. |
56 |
< |
* Overriding this method may be used to similar but more flexible |
57 |
< |
* effect as providing a barrier action to a CyclicBarrier. |
54 |
> |
* advance, are arranged by overriding method {@link #onAdvance(int, |
55 |
> |
* int)}, which also controls termination. Overriding this method is |
56 |
> |
* similar to, but more flexible than, providing a barrier action to a |
57 |
> |
* {@code CyclicBarrier}. |
58 |
|
* |
59 |
|
* <li> Phasers may enter a <em>termination</em> state in which all |
60 |
< |
* await actions immediately return, indicating (via a negative phase |
61 |
< |
* value) that execution is complete. Termination is triggered by |
62 |
< |
* executing the overridable {@code onAdvance} method that is invoked |
63 |
< |
* each time the barrier is about to be tripped. When a Phaser is |
60 |
> |
* actions immediately return without updating phaser state or waiting |
61 |
> |
* for advance, and indicating (via a negative phase value) that |
62 |
> |
* execution is complete. Termination is triggered when an invocation |
63 |
> |
* of {@code onAdvance} returns {@code true}. When a phaser is |
64 |
|
* controlling an action with a fixed number of iterations, it is |
65 |
|
* often convenient to override this method to cause termination when |
66 |
< |
* the current phase number reaches a threshold. Method |
67 |
< |
* {@code forceTermination} is also available to abruptly release |
68 |
< |
* waiting threads and allow them to terminate. |
66 |
> |
* the current phase number reaches a threshold. Method {@link |
67 |
> |
* #forceTermination} is also available to abruptly release waiting |
68 |
> |
* threads and allow them to terminate. |
69 |
|
* |
70 |
|
* <li> Phasers may be tiered to reduce contention. Phasers with large |
71 |
|
* numbers of parties that would otherwise experience heavy |
75 |
|
* |
76 |
|
* <li> By default, {@code awaitAdvance} continues to wait even if |
77 |
|
* the waiting thread is interrupted. And unlike the case in |
78 |
< |
* CyclicBarriers, exceptions encountered while tasks wait |
78 |
> |
* {@code CyclicBarrier}, exceptions encountered while tasks wait |
79 |
|
* interruptibly or with timeout do not change the state of the |
80 |
|
* barrier. If necessary, you can perform any associated recovery |
81 |
|
* within handlers of those exceptions, often after invoking |
82 |
|
* {@code forceTermination}. |
83 |
|
* |
84 |
+ |
* <li>Phasers may be used to coordinate tasks executing in a {@link |
85 |
+ |
* ForkJoinPool}, which will ensure sufficient parallelism to execute |
86 |
+ |
* tasks when others are blocked waiting for a phase to advance. |
87 |
+ |
* |
88 |
|
* </ul> |
89 |
|
* |
90 |
|
* <p><b>Sample usages:</b> |
91 |
|
* |
92 |
< |
* <p>A Phaser may be used instead of a {@code CountDownLatch} to control |
93 |
< |
* a one-shot action serving a variable number of parties. The typical |
94 |
< |
* idiom is for the method setting this up to first register, then |
95 |
< |
* start the actions, then deregister, as in: |
96 |
< |
* |
97 |
< |
* <pre> |
98 |
< |
* void runTasks(List<Runnable> list) { |
99 |
< |
* final Phaser phaser = new Phaser(1); // "1" to register self |
100 |
< |
* for (Runnable r : list) { |
101 |
< |
* phaser.register(); |
102 |
< |
* new Thread() { |
103 |
< |
* public void run() { |
104 |
< |
* phaser.arriveAndAwaitAdvance(); // await all creation |
105 |
< |
* r.run(); |
106 |
< |
* phaser.arriveAndDeregister(); // signal completion |
107 |
< |
* } |
108 |
< |
* }.start(); |
92 |
> |
* <p>A {@code Phaser} may be used instead of a {@code CountDownLatch} |
93 |
> |
* to control a one-shot action serving a variable number of |
94 |
> |
* parties. The typical idiom is for the method setting this up to |
95 |
> |
* first register, then start the actions, then deregister, as in: |
96 |
> |
* |
97 |
> |
* <pre> {@code |
98 |
> |
* void runTasks(List<Runnable> list) { |
99 |
> |
* final Phaser phaser = new Phaser(1); // "1" to register self |
100 |
> |
* // create and start threads |
101 |
> |
* for (Runnable r : list) { |
102 |
> |
* phaser.register(); |
103 |
> |
* new Thread() { |
104 |
> |
* public void run() { |
105 |
> |
* phaser.arriveAndAwaitAdvance(); // await all creation |
106 |
> |
* r.run(); |
107 |
> |
* } |
108 |
> |
* }.start(); |
109 |
|
* } |
110 |
|
* |
111 |
< |
* doSomethingOnBehalfOfWorkers(); |
112 |
< |
* phaser.arrive(); // allow threads to start |
113 |
< |
* int p = phaser.arriveAndDeregister(); // deregister self ... |
110 |
< |
* p = phaser.awaitAdvance(p); // ... and await arrival |
111 |
< |
* otherActions(); // do other things while tasks execute |
112 |
< |
* phaser.awaitAdvance(p); // await final completion |
113 |
< |
* } |
114 |
< |
* </pre> |
111 |
> |
* // allow threads to start and deregister self |
112 |
> |
* phaser.arriveAndDeregister(); |
113 |
> |
* }}</pre> |
114 |
|
* |
115 |
|
* <p>One way to cause a set of threads to repeatedly perform actions |
116 |
|
* for a given number of iterations is to override {@code onAdvance}: |
117 |
|
* |
118 |
< |
* <pre> |
119 |
< |
* void startTasks(List<Runnable> list, final int iterations) { |
120 |
< |
* final Phaser phaser = new Phaser() { |
121 |
< |
* public boolean onAdvance(int phase, int registeredParties) { |
122 |
< |
* return phase >= iterations || registeredParties == 0; |
118 |
> |
* <pre> {@code |
119 |
> |
* void startTasks(List<Runnable> list, final int iterations) { |
120 |
> |
* final Phaser phaser = new Phaser() { |
121 |
> |
* public boolean onAdvance(int phase, int registeredParties) { |
122 |
> |
* return phase >= iterations || registeredParties == 0; |
123 |
> |
* } |
124 |
> |
* }; |
125 |
> |
* phaser.register(); |
126 |
> |
* for (Runnable r : list) { |
127 |
> |
* phaser.register(); |
128 |
> |
* new Thread() { |
129 |
> |
* public void run() { |
130 |
> |
* do { |
131 |
> |
* r.run(); |
132 |
> |
* phaser.arriveAndAwaitAdvance(); |
133 |
> |
* } while(!phaser.isTerminated(); |
134 |
|
* } |
135 |
< |
* }; |
126 |
< |
* phaser.register(); |
127 |
< |
* for (Runnable r : list) { |
128 |
< |
* phaser.register(); |
129 |
< |
* new Thread() { |
130 |
< |
* public void run() { |
131 |
< |
* do { |
132 |
< |
* r.run(); |
133 |
< |
* phaser.arriveAndAwaitAdvance(); |
134 |
< |
* } while(!phaser.isTerminated(); |
135 |
< |
* } |
136 |
< |
* }.start(); |
135 |
> |
* }.start(); |
136 |
|
* } |
137 |
|
* phaser.arriveAndDeregister(); // deregister self, don't wait |
138 |
< |
* } |
140 |
< |
* </pre> |
138 |
> |
* }}</pre> |
139 |
|
* |
140 |
< |
* <p> To create a set of tasks using a tree of Phasers, |
140 |
> |
* <p>To create a set of tasks using a tree of phasers, |
141 |
|
* you could use code of the following form, assuming a |
142 |
< |
* Task class with a constructor accepting a Phaser that |
142 |
> |
* Task class with a constructor accepting a phaser that |
143 |
|
* it registers for upon construction: |
144 |
< |
* <pre> |
145 |
< |
* void build(Task[] actions, int lo, int hi, Phaser b) { |
146 |
< |
* int step = (hi - lo) / TASKS_PER_PHASER; |
147 |
< |
* if (step > 1) { |
148 |
< |
* int i = lo; |
149 |
< |
* while (i < hi) { |
150 |
< |
* int r = Math.min(i + step, hi); |
151 |
< |
* build(actions, i, r, new Phaser(b)); |
152 |
< |
* i = r; |
153 |
< |
* } |
154 |
< |
* } |
155 |
< |
* else { |
156 |
< |
* for (int i = lo; i < hi; ++i) |
157 |
< |
* actions[i] = new Task(b); |
158 |
< |
* // assumes new Task(b) performs b.register() |
159 |
< |
* } |
160 |
< |
* } |
161 |
< |
* // .. initially called, for n tasks via |
164 |
< |
* build(new Task[n], 0, n, new Phaser()); |
165 |
< |
* </pre> |
144 |
> |
* <pre> {@code |
145 |
> |
* void build(Task[] actions, int lo, int hi, Phaser b) { |
146 |
> |
* int step = (hi - lo) / TASKS_PER_PHASER; |
147 |
> |
* if (step > 1) { |
148 |
> |
* int i = lo; |
149 |
> |
* while (i < hi) { |
150 |
> |
* int r = Math.min(i + step, hi); |
151 |
> |
* build(actions, i, r, new Phaser(b)); |
152 |
> |
* i = r; |
153 |
> |
* } |
154 |
> |
* } else { |
155 |
> |
* for (int i = lo; i < hi; ++i) |
156 |
> |
* actions[i] = new Task(b); |
157 |
> |
* // assumes new Task(b) performs b.register() |
158 |
> |
* } |
159 |
> |
* } |
160 |
> |
* // .. initially called, for n tasks via |
161 |
> |
* build(new Task[n], 0, n, new Phaser());}</pre> |
162 |
|
* |
163 |
|
* The best value of {@code TASKS_PER_PHASER} depends mainly on |
164 |
|
* expected barrier synchronization rates. A value as low as four may |
172 |
|
* parties result in IllegalStateExceptions. However, you can and |
173 |
|
* should create tiered phasers to accommodate arbitrarily large sets |
174 |
|
* of participants. |
175 |
+ |
* |
176 |
+ |
* @since 1.7 |
177 |
+ |
* @author Doug Lea |
178 |
|
*/ |
179 |
|
public class Phaser { |
180 |
|
/* |
199 |
|
* and encoding simple, and keeping race windows short. |
200 |
|
* |
201 |
|
* Note: there are some cheats in arrive() that rely on unarrived |
202 |
< |
* being lowest 16 bits. |
202 |
> |
* count being lowest 16 bits. |
203 |
|
*/ |
204 |
|
private volatile long state; |
205 |
|
|
206 |
|
private static final int ushortBits = 16; |
207 |
< |
private static final int ushortMask = (1 << ushortBits) - 1; |
208 |
< |
private static final int phaseMask = 0x7fffffff; |
207 |
> |
private static final int ushortMask = 0xffff; |
208 |
> |
private static final int phaseMask = 0x7fffffff; |
209 |
|
|
210 |
|
private static int unarrivedOf(long s) { |
211 |
< |
return (int)(s & ushortMask); |
211 |
> |
return (int) (s & ushortMask); |
212 |
|
} |
213 |
|
|
214 |
|
private static int partiesOf(long s) { |
215 |
< |
return (int)(s & (ushortMask << 16)) >>> 16; |
215 |
> |
return ((int) s) >>> 16; |
216 |
|
} |
217 |
|
|
218 |
|
private static int phaseOf(long s) { |
219 |
< |
return (int)(s >>> 32); |
219 |
> |
return (int) (s >>> 32); |
220 |
|
} |
221 |
|
|
222 |
|
private static int arrivedOf(long s) { |
224 |
|
} |
225 |
|
|
226 |
|
private static long stateFor(int phase, int parties, int unarrived) { |
227 |
< |
return (((long)phase) << 32) | ((parties << 16) | unarrived); |
227 |
> |
return ((((long) phase) << 32) | (((long) parties) << 16) | |
228 |
> |
(long) unarrived); |
229 |
|
} |
230 |
|
|
231 |
|
private static long trippedStateFor(int phase, int parties) { |
232 |
< |
return (((long)phase) << 32) | ((parties << 16) | parties); |
232 |
> |
long lp = (long) parties; |
233 |
> |
return (((long) phase) << 32) | (lp << 16) | lp; |
234 |
|
} |
235 |
|
|
236 |
< |
private static IllegalStateException badBounds(int parties, int unarrived) { |
237 |
< |
return new IllegalStateException |
238 |
< |
("Attempt to set " + unarrived + |
239 |
< |
" unarrived of " + parties + " parties"); |
236 |
> |
/** |
237 |
> |
* Returns message string for bad bounds exceptions. |
238 |
> |
*/ |
239 |
> |
private static String badBounds(int parties, int unarrived) { |
240 |
> |
return ("Attempt to set " + unarrived + |
241 |
> |
" unarrived of " + parties + " parties"); |
242 |
|
} |
243 |
|
|
244 |
|
/** |
247 |
|
private final Phaser parent; |
248 |
|
|
249 |
|
/** |
250 |
< |
* The root of Phaser tree. Equals this if not in a tree. Used to |
250 |
> |
* The root of phaser tree. Equals this if not in a tree. Used to |
251 |
|
* support faster state push-down. |
252 |
|
*/ |
253 |
|
private final Phaser root; |
255 |
|
// Wait queues |
256 |
|
|
257 |
|
/** |
258 |
< |
* Heads of Treiber stacks waiting for nonFJ threads. To eliminate |
258 |
> |
* Heads of Treiber stacks for waiting threads. To eliminate |
259 |
|
* contention while releasing some threads while adding others, we |
260 |
|
* use two of them, alternating across even and odd phases. |
261 |
|
*/ |
263 |
|
private final AtomicReference<QNode> oddQ = new AtomicReference<QNode>(); |
264 |
|
|
265 |
|
private AtomicReference<QNode> queueFor(int phase) { |
266 |
< |
return (phase & 1) == 0? evenQ : oddQ; |
266 |
> |
return ((phase & 1) == 0) ? evenQ : oddQ; |
267 |
|
} |
268 |
|
|
269 |
|
/** |
271 |
|
* root if necessary. |
272 |
|
*/ |
273 |
|
private long getReconciledState() { |
274 |
< |
return parent == null? state : reconcileState(); |
274 |
> |
return (parent == null) ? state : reconcileState(); |
275 |
|
} |
276 |
|
|
277 |
|
/** |
298 |
|
} |
299 |
|
|
300 |
|
/** |
301 |
< |
* Creates a new Phaser without any initially registered parties, |
302 |
< |
* initial phase number 0, and no parent. |
301 |
> |
* Creates a new phaser without any initially registered parties, |
302 |
> |
* initial phase number 0, and no parent. Any thread using this |
303 |
> |
* phaser will need to first register for it. |
304 |
|
*/ |
305 |
|
public Phaser() { |
306 |
|
this(null); |
307 |
|
} |
308 |
|
|
309 |
|
/** |
310 |
< |
* Creates a new Phaser with the given numbers of registered |
310 |
> |
* Creates a new phaser with the given numbers of registered |
311 |
|
* unarrived parties, initial phase number 0, and no parent. |
312 |
< |
* @param parties the number of parties required to trip barrier. |
312 |
> |
* |
313 |
> |
* @param parties the number of parties required to trip barrier |
314 |
|
* @throws IllegalArgumentException if parties less than zero |
315 |
< |
* or greater than the maximum number of parties supported. |
315 |
> |
* or greater than the maximum number of parties supported |
316 |
|
*/ |
317 |
|
public Phaser(int parties) { |
318 |
|
this(null, parties); |
319 |
|
} |
320 |
|
|
321 |
|
/** |
322 |
< |
* Creates a new Phaser with the given parent, without any |
322 |
> |
* Creates a new phaser with the given parent, without any |
323 |
|
* initially registered parties. If parent is non-null this phaser |
324 |
|
* is registered with the parent and its initial phase number is |
325 |
|
* the same as that of parent phaser. |
326 |
< |
* @param parent the parent phaser. |
326 |
> |
* |
327 |
> |
* @param parent the parent phaser |
328 |
|
*/ |
329 |
|
public Phaser(Phaser parent) { |
330 |
|
int phase = 0; |
339 |
|
} |
340 |
|
|
341 |
|
/** |
342 |
< |
* Creates a new Phaser with the given parent and numbers of |
343 |
< |
* registered unarrived parties. If parent is non-null this phaser |
342 |
> |
* Creates a new phaser with the given parent and numbers of |
343 |
> |
* registered unarrived parties. If parent is non-null, this phaser |
344 |
|
* is registered with the parent and its initial phase number is |
345 |
|
* the same as that of parent phaser. |
346 |
< |
* @param parent the parent phaser. |
347 |
< |
* @param parties the number of parties required to trip barrier. |
346 |
> |
* |
347 |
> |
* @param parent the parent phaser |
348 |
> |
* @param parties the number of parties required to trip barrier |
349 |
|
* @throws IllegalArgumentException if parties less than zero |
350 |
< |
* or greater than the maximum number of parties supported. |
350 |
> |
* or greater than the maximum number of parties supported |
351 |
|
*/ |
352 |
|
public Phaser(Phaser parent, int parties) { |
353 |
|
if (parties < 0 || parties > ushortMask) |
365 |
|
|
366 |
|
/** |
367 |
|
* Adds a new unarrived party to this phaser. |
368 |
+ |
* |
369 |
|
* @return the current barrier phase number upon registration |
370 |
|
* @throws IllegalStateException if attempting to register more |
371 |
< |
* than the maximum supported number of parties. |
371 |
> |
* than the maximum supported number of parties |
372 |
|
*/ |
373 |
|
public int register() { |
374 |
|
return doRegister(1); |
376 |
|
|
377 |
|
/** |
378 |
|
* Adds the given number of new unarrived parties to this phaser. |
379 |
< |
* @param parties the number of parties required to trip barrier. |
379 |
> |
* |
380 |
> |
* @param parties the number of parties required to trip barrier |
381 |
|
* @return the current barrier phase number upon registration |
382 |
|
* @throws IllegalStateException if attempting to register more |
383 |
< |
* than the maximum supported number of parties. |
383 |
> |
* than the maximum supported number of parties |
384 |
|
*/ |
385 |
|
public int bulkRegister(int parties) { |
386 |
|
if (parties < 0) |
403 |
|
if (phase < 0) |
404 |
|
break; |
405 |
|
if (parties > ushortMask || unarrived > ushortMask) |
406 |
< |
throw badBounds(parties, unarrived); |
406 |
> |
throw new IllegalStateException(badBounds(parties, unarrived)); |
407 |
|
if (phase == phaseOf(root.state) && |
408 |
|
casState(s, stateFor(phase, parties, unarrived))) |
409 |
|
break; |
416 |
|
* in turn wait for others via {@link #awaitAdvance}). |
417 |
|
* |
418 |
|
* @return the barrier phase number upon entry to this method, or a |
419 |
< |
* negative value if terminated; |
419 |
> |
* negative value if terminated |
420 |
|
* @throws IllegalStateException if not terminated and the number |
421 |
< |
* of unarrived parties would become negative. |
421 |
> |
* of unarrived parties would become negative |
422 |
|
*/ |
423 |
|
public int arrive() { |
424 |
|
int phase; |
425 |
|
for (;;) { |
426 |
|
long s = state; |
427 |
|
phase = phaseOf(s); |
428 |
+ |
if (phase < 0) |
429 |
+ |
break; |
430 |
|
int parties = partiesOf(s); |
431 |
|
int unarrived = unarrivedOf(s) - 1; |
432 |
|
if (unarrived > 0) { // Not the last arrival |
438 |
|
if (par == null) { // directly trip |
439 |
|
if (casState |
440 |
|
(s, |
441 |
< |
trippedStateFor(onAdvance(phase, parties)? -1 : |
441 |
> |
trippedStateFor(onAdvance(phase, parties) ? -1 : |
442 |
|
((phase + 1) & phaseMask), parties))) { |
443 |
|
releaseWaiters(phase); |
444 |
|
break; |
452 |
|
} |
453 |
|
} |
454 |
|
} |
444 |
– |
else if (phase < 0) // Don't throw exception if terminated |
445 |
– |
break; |
455 |
|
else if (phase != phaseOf(root.state)) // or if unreconciled |
456 |
|
reconcileState(); |
457 |
|
else |
458 |
< |
throw badBounds(parties, unarrived); |
458 |
> |
throw new IllegalStateException(badBounds(parties, unarrived)); |
459 |
|
} |
460 |
|
return phase; |
461 |
|
} |
462 |
|
|
463 |
|
/** |
464 |
< |
* Arrives at the barrier, and deregisters from it, without |
465 |
< |
* waiting for others. Deregistration reduces number of parties |
464 |
> |
* Arrives at the barrier and deregisters from it without waiting |
465 |
> |
* for others. Deregistration reduces the number of parties |
466 |
|
* required to trip the barrier in future phases. If this phaser |
467 |
|
* has a parent, and deregistration causes this phaser to have |
468 |
< |
* zero parties, this phaser is also deregistered from its parent. |
468 |
> |
* zero parties, this phaser also arrives at and is deregistered |
469 |
> |
* from its parent. |
470 |
|
* |
471 |
|
* @return the current barrier phase number upon entry to |
472 |
< |
* this method, or a negative value if terminated; |
472 |
> |
* this method, or a negative value if terminated |
473 |
|
* @throws IllegalStateException if not terminated and the number |
474 |
< |
* of registered or unarrived parties would become negative. |
474 |
> |
* of registered or unarrived parties would become negative |
475 |
|
*/ |
476 |
|
public int arriveAndDeregister() { |
477 |
|
// similar code to arrive, but too different to merge |
480 |
|
for (;;) { |
481 |
|
long s = state; |
482 |
|
phase = phaseOf(s); |
483 |
+ |
if (phase < 0) |
484 |
+ |
break; |
485 |
|
int parties = partiesOf(s) - 1; |
486 |
|
int unarrived = unarrivedOf(s) - 1; |
487 |
|
if (parties >= 0) { |
500 |
|
if (unarrived == 0) { |
501 |
|
if (casState |
502 |
|
(s, |
503 |
< |
trippedStateFor(onAdvance(phase, parties)? -1 : |
503 |
> |
trippedStateFor(onAdvance(phase, parties) ? -1 : |
504 |
|
((phase + 1) & phaseMask), parties))) { |
505 |
|
releaseWaiters(phase); |
506 |
|
break; |
507 |
|
} |
508 |
|
continue; |
509 |
|
} |
498 |
– |
if (phase < 0) |
499 |
– |
break; |
510 |
|
if (par != null && phase != phaseOf(root.state)) { |
511 |
|
reconcileState(); |
512 |
|
continue; |
513 |
|
} |
514 |
|
} |
515 |
< |
throw badBounds(parties, unarrived); |
515 |
> |
throw new IllegalStateException(badBounds(parties, unarrived)); |
516 |
|
} |
517 |
|
return phase; |
518 |
|
} |
519 |
|
|
520 |
|
/** |
521 |
|
* Arrives at the barrier and awaits others. Equivalent in effect |
522 |
< |
* to {@code awaitAdvance(arrive())}. If you instead need to |
523 |
< |
* await with interruption of timeout, and/or deregister upon |
524 |
< |
* arrival, you can arrange them using analogous constructions. |
522 |
> |
* to {@code awaitAdvance(arrive())}. If you need to await with |
523 |
> |
* interruption or timeout, you can arrange this with an analogous |
524 |
> |
* construction using one of the other forms of the awaitAdvance |
525 |
> |
* method. If instead you need to deregister upon arrival use |
526 |
> |
* {@code arriveAndDeregister}. |
527 |
> |
* |
528 |
|
* @return the phase on entry to this method |
529 |
|
* @throws IllegalStateException if not terminated and the number |
530 |
< |
* of unarrived parties would become negative. |
530 |
> |
* of unarrived parties would become negative |
531 |
|
*/ |
532 |
|
public int arriveAndAwaitAdvance() { |
533 |
|
return awaitAdvance(arrive()); |
534 |
|
} |
535 |
|
|
536 |
|
/** |
537 |
< |
* Awaits the phase of the barrier to advance from the given |
538 |
< |
* value, or returns immediately if argument is negative or this |
539 |
< |
* barrier is terminated. |
537 |
> |
* Awaits the phase of the barrier to advance from the given phase |
538 |
> |
* value, or returns immediately if the current phase of the barrier |
539 |
> |
* is not equal to the given phase value or this barrier is |
540 |
> |
* terminated. |
541 |
> |
* |
542 |
|
* @param phase the phase on entry to this method |
543 |
|
* @return the phase on exit from this method |
544 |
|
*/ |
549 |
|
int p = phaseOf(s); |
550 |
|
if (p != phase) |
551 |
|
return p; |
552 |
< |
if (unarrivedOf(s) == 0) |
552 |
> |
if (unarrivedOf(s) == 0 && parent != null) |
553 |
|
parent.awaitAdvance(phase); |
554 |
|
// Fall here even if parent waited, to reconcile and help release |
555 |
|
return untimedWait(phase); |
560 |
|
* value, or returns immediately if argument is negative or this |
561 |
|
* barrier is terminated, or throws InterruptedException if |
562 |
|
* interrupted while waiting. |
563 |
+ |
* |
564 |
|
* @param phase the phase on entry to this method |
565 |
|
* @return the phase on exit from this method |
566 |
|
* @throws InterruptedException if thread interrupted while waiting |
567 |
|
*/ |
568 |
< |
public int awaitAdvanceInterruptibly(int phase) throws InterruptedException { |
568 |
> |
public int awaitAdvanceInterruptibly(int phase) |
569 |
> |
throws InterruptedException { |
570 |
|
if (phase < 0) |
571 |
|
return phase; |
572 |
|
long s = getReconciledState(); |
573 |
|
int p = phaseOf(s); |
574 |
|
if (p != phase) |
575 |
|
return p; |
576 |
< |
if (unarrivedOf(s) != 0) |
576 |
> |
if (unarrivedOf(s) == 0 && parent != null) |
577 |
|
parent.awaitAdvanceInterruptibly(phase); |
578 |
|
return interruptibleWait(phase); |
579 |
|
} |
582 |
|
* Awaits the phase of the barrier to advance from the given value |
583 |
|
* or the given timeout elapses, or returns immediately if |
584 |
|
* argument is negative or this barrier is terminated. |
585 |
+ |
* |
586 |
|
* @param phase the phase on entry to this method |
587 |
|
* @return the phase on exit from this method |
588 |
|
* @throws InterruptedException if thread interrupted while waiting |
589 |
|
* @throws TimeoutException if timed out while waiting |
590 |
|
*/ |
591 |
< |
public int awaitAdvanceInterruptibly(int phase, long timeout, TimeUnit unit) |
591 |
> |
public int awaitAdvanceInterruptibly(int phase, |
592 |
> |
long timeout, TimeUnit unit) |
593 |
|
throws InterruptedException, TimeoutException { |
594 |
|
if (phase < 0) |
595 |
|
return phase; |
597 |
|
int p = phaseOf(s); |
598 |
|
if (p != phase) |
599 |
|
return p; |
600 |
< |
if (unarrivedOf(s) == 0) |
600 |
> |
if (unarrivedOf(s) == 0 && parent != null) |
601 |
|
parent.awaitAdvanceInterruptibly(phase, timeout, unit); |
602 |
|
return timedWait(phase, unit.toNanos(timeout)); |
603 |
|
} |
630 |
|
* Returns the current phase number. The maximum phase number is |
631 |
|
* {@code Integer.MAX_VALUE}, after which it restarts at |
632 |
|
* zero. Upon termination, the phase number is negative. |
633 |
+ |
* |
634 |
|
* @return the phase number, or a negative value if terminated |
635 |
|
*/ |
636 |
|
public final int getPhase() { |
638 |
|
} |
639 |
|
|
640 |
|
/** |
621 |
– |
* Returns {@code true} if the current phase number equals the given phase. |
622 |
– |
* @param phase the phase |
623 |
– |
* @return {@code true} if the current phase number equals the given phase |
624 |
– |
*/ |
625 |
– |
public final boolean hasPhase(int phase) { |
626 |
– |
return phaseOf(getReconciledState()) == phase; |
627 |
– |
} |
628 |
– |
|
629 |
– |
/** |
641 |
|
* Returns the number of parties registered at this barrier. |
642 |
+ |
* |
643 |
|
* @return the number of parties |
644 |
|
*/ |
645 |
|
public int getRegisteredParties() { |
649 |
|
/** |
650 |
|
* Returns the number of parties that have arrived at the current |
651 |
|
* phase of this barrier. |
652 |
+ |
* |
653 |
|
* @return the number of arrived parties |
654 |
|
*/ |
655 |
|
public int getArrivedParties() { |
659 |
|
/** |
660 |
|
* Returns the number of registered parties that have not yet |
661 |
|
* arrived at the current phase of this barrier. |
662 |
+ |
* |
663 |
|
* @return the number of unarrived parties |
664 |
|
*/ |
665 |
|
public int getUnarrivedParties() { |
667 |
|
} |
668 |
|
|
669 |
|
/** |
670 |
< |
* Returns the parent of this phaser, or null if none. |
671 |
< |
* @return the parent of this phaser, or null if none |
670 |
> |
* Returns the parent of this phaser, or {@code null} if none. |
671 |
> |
* |
672 |
> |
* @return the parent of this phaser, or {@code null} if none |
673 |
|
*/ |
674 |
|
public Phaser getParent() { |
675 |
|
return parent; |
678 |
|
/** |
679 |
|
* Returns the root ancestor of this phaser, which is the same as |
680 |
|
* this phaser if it has no parent. |
681 |
+ |
* |
682 |
|
* @return the root ancestor of this phaser |
683 |
|
*/ |
684 |
|
public Phaser getRoot() { |
687 |
|
|
688 |
|
/** |
689 |
|
* Returns {@code true} if this barrier has been terminated. |
690 |
+ |
* |
691 |
|
* @return {@code true} if this barrier has been terminated |
692 |
|
*/ |
693 |
|
public boolean isTerminated() { |
698 |
|
* Overridable method to perform an action upon phase advance, and |
699 |
|
* to control termination. This method is invoked whenever the |
700 |
|
* barrier is tripped (and thus all other waiting parties are |
701 |
< |
* dormant). If it returns true, then, rather than advance the |
702 |
< |
* phase number, this barrier will be set to a final termination |
703 |
< |
* state, and subsequent calls to {@code isTerminated} will |
704 |
< |
* return true. |
701 |
> |
* dormant). If it returns {@code true}, then, rather than advance |
702 |
> |
* the phase number, this barrier will be set to a final |
703 |
> |
* termination state, and subsequent calls to {@link #isTerminated} |
704 |
> |
* will return true. |
705 |
|
* |
706 |
< |
* <p> The default version returns true when the number of |
706 |
> |
* <p>The default version returns {@code true} when the number of |
707 |
|
* registered parties is zero. Normally, overrides that arrange |
708 |
|
* termination for other reasons should also preserve this |
709 |
|
* property. |
710 |
|
* |
711 |
< |
* <p> You may override this method to perform an action with side |
711 |
> |
* <p>You may override this method to perform an action with side |
712 |
|
* effects visible to participating tasks, but it is in general |
713 |
|
* only sensible to do so in designs where all parties register |
714 |
< |
* before any arrive, and all {@code awaitAdvance} at each phase. |
715 |
< |
* Otherwise, you cannot ensure lack of interference. In |
716 |
< |
* particular, this method may be invoked more than once per |
700 |
< |
* transition if other parties successfully register while the |
701 |
< |
* invocation of this method is in progress, thus postponing the |
702 |
< |
* transition until those parties also arrive, re-triggering this |
703 |
< |
* method. |
714 |
> |
* before any arrive, and all {@link #awaitAdvance} at each phase. |
715 |
> |
* Otherwise, you cannot ensure lack of interference from other |
716 |
> |
* parties during the invocation of this method. |
717 |
|
* |
718 |
|
* @param phase the phase number on entering the barrier |
719 |
|
* @param registeredParties the current number of registered parties |
742 |
|
|
743 |
|
// methods for waiting |
744 |
|
|
732 |
– |
/** The number of CPUs, for spin control */ |
733 |
– |
static final int NCPUS = Runtime.getRuntime().availableProcessors(); |
734 |
– |
|
735 |
– |
/** |
736 |
– |
* The number of times to spin before blocking in timed waits. |
737 |
– |
* The value is empirically derived. |
738 |
– |
*/ |
739 |
– |
static final int maxTimedSpins = (NCPUS < 2)? 0 : 32; |
740 |
– |
|
741 |
– |
/** |
742 |
– |
* The number of times to spin before blocking in untimed waits. |
743 |
– |
* This is greater than timed value because untimed waits spin |
744 |
– |
* faster since they don't need to check times on each spin. |
745 |
– |
*/ |
746 |
– |
static final int maxUntimedSpins = maxTimedSpins * 32; |
747 |
– |
|
748 |
– |
/** |
749 |
– |
* The number of nanoseconds for which it is faster to spin |
750 |
– |
* rather than to use timed park. A rough estimate suffices. |
751 |
– |
*/ |
752 |
– |
static final long spinForTimeoutThreshold = 1000L; |
753 |
– |
|
745 |
|
/** |
746 |
< |
* Wait nodes for Treiber stack representing wait queue for non-FJ |
756 |
< |
* tasks. |
746 |
> |
* Wait nodes for Treiber stack representing wait queue |
747 |
|
*/ |
748 |
< |
static final class QNode { |
749 |
< |
QNode next; |
748 |
> |
static final class QNode implements ForkJoinPool.ManagedBlocker { |
749 |
> |
final Phaser phaser; |
750 |
> |
final int phase; |
751 |
> |
final long startTime; |
752 |
> |
final long nanos; |
753 |
> |
final boolean timed; |
754 |
> |
final boolean interruptible; |
755 |
> |
volatile boolean wasInterrupted = false; |
756 |
|
volatile Thread thread; // nulled to cancel wait |
757 |
< |
QNode() { |
757 |
> |
QNode next; |
758 |
> |
QNode(Phaser phaser, int phase, boolean interruptible, |
759 |
> |
boolean timed, long startTime, long nanos) { |
760 |
> |
this.phaser = phaser; |
761 |
> |
this.phase = phase; |
762 |
> |
this.timed = timed; |
763 |
> |
this.interruptible = interruptible; |
764 |
> |
this.startTime = startTime; |
765 |
> |
this.nanos = nanos; |
766 |
|
thread = Thread.currentThread(); |
767 |
|
} |
768 |
+ |
public boolean isReleasable() { |
769 |
+ |
return (thread == null || |
770 |
+ |
phaser.getPhase() != phase || |
771 |
+ |
(interruptible && wasInterrupted) || |
772 |
+ |
(timed && (nanos - (System.nanoTime() - startTime)) <= 0)); |
773 |
+ |
} |
774 |
+ |
public boolean block() { |
775 |
+ |
if (Thread.interrupted()) { |
776 |
+ |
wasInterrupted = true; |
777 |
+ |
if (interruptible) |
778 |
+ |
return true; |
779 |
+ |
} |
780 |
+ |
if (!timed) |
781 |
+ |
LockSupport.park(this); |
782 |
+ |
else { |
783 |
+ |
long waitTime = nanos - (System.nanoTime() - startTime); |
784 |
+ |
if (waitTime <= 0) |
785 |
+ |
return true; |
786 |
+ |
LockSupport.parkNanos(this, waitTime); |
787 |
+ |
} |
788 |
+ |
return isReleasable(); |
789 |
+ |
} |
790 |
|
void signal() { |
791 |
|
Thread t = thread; |
792 |
|
if (t != null) { |
794 |
|
LockSupport.unpark(t); |
795 |
|
} |
796 |
|
} |
797 |
+ |
boolean doWait() { |
798 |
+ |
if (thread != null) { |
799 |
+ |
try { |
800 |
+ |
ForkJoinPool.managedBlock(this, false); |
801 |
+ |
} catch (InterruptedException ie) { |
802 |
+ |
} |
803 |
+ |
} |
804 |
+ |
return wasInterrupted; |
805 |
+ |
} |
806 |
+ |
|
807 |
|
} |
808 |
|
|
809 |
|
/** |
810 |
< |
* Removes and signals waiting threads from wait queue |
810 |
> |
* Removes and signals waiting threads from wait queue. |
811 |
|
*/ |
812 |
|
private void releaseWaiters(int phase) { |
813 |
|
AtomicReference<QNode> head = queueFor(phase); |
819 |
|
} |
820 |
|
|
821 |
|
/** |
822 |
+ |
* Tries to enqueue given node in the appropriate wait queue. |
823 |
+ |
* |
824 |
+ |
* @return true if successful |
825 |
+ |
*/ |
826 |
+ |
private boolean tryEnqueue(QNode node) { |
827 |
+ |
AtomicReference<QNode> head = queueFor(node.phase); |
828 |
+ |
return head.compareAndSet(node.next = head.get(), node); |
829 |
+ |
} |
830 |
+ |
|
831 |
+ |
/** |
832 |
|
* Enqueues node and waits unless aborted or signalled. |
833 |
+ |
* |
834 |
+ |
* @return current phase |
835 |
|
*/ |
836 |
|
private int untimedWait(int phase) { |
789 |
– |
int spins = maxUntimedSpins; |
837 |
|
QNode node = null; |
791 |
– |
boolean interrupted = false; |
838 |
|
boolean queued = false; |
839 |
+ |
boolean interrupted = false; |
840 |
|
int p; |
841 |
|
while ((p = getPhase()) == phase) { |
842 |
< |
interrupted = Thread.interrupted(); |
843 |
< |
if (node != null) { |
844 |
< |
if (!queued) { |
845 |
< |
AtomicReference<QNode> head = queueFor(phase); |
846 |
< |
queued = head.compareAndSet(node.next = head.get(), node); |
847 |
< |
} |
801 |
< |
else if (node.thread != null) |
802 |
< |
LockSupport.park(this); |
803 |
< |
} |
804 |
< |
else if (spins <= 0) |
805 |
< |
node = new QNode(); |
842 |
> |
if (Thread.interrupted()) |
843 |
> |
interrupted = true; |
844 |
> |
else if (node == null) |
845 |
> |
node = new QNode(this, phase, false, false, 0, 0); |
846 |
> |
else if (!queued) |
847 |
> |
queued = tryEnqueue(node); |
848 |
|
else |
849 |
< |
--spins; |
849 |
> |
interrupted = node.doWait(); |
850 |
|
} |
851 |
|
if (node != null) |
852 |
|
node.thread = null; |
853 |
+ |
releaseWaiters(phase); |
854 |
|
if (interrupted) |
855 |
|
Thread.currentThread().interrupt(); |
813 |
– |
releaseWaiters(phase); |
856 |
|
return p; |
857 |
|
} |
858 |
|
|
859 |
|
/** |
860 |
< |
* Messier interruptible version |
860 |
> |
* Interruptible version |
861 |
> |
* @return current phase |
862 |
|
*/ |
863 |
|
private int interruptibleWait(int phase) throws InterruptedException { |
821 |
– |
int spins = maxUntimedSpins; |
864 |
|
QNode node = null; |
865 |
|
boolean queued = false; |
866 |
|
boolean interrupted = false; |
867 |
|
int p; |
868 |
< |
while ((p = getPhase()) == phase) { |
869 |
< |
if (interrupted = Thread.interrupted()) |
870 |
< |
break; |
871 |
< |
if (node != null) { |
872 |
< |
if (!queued) { |
873 |
< |
AtomicReference<QNode> head = queueFor(phase); |
874 |
< |
queued = head.compareAndSet(node.next = head.get(), node); |
833 |
< |
} |
834 |
< |
else if (node.thread != null) |
835 |
< |
LockSupport.park(this); |
836 |
< |
} |
837 |
< |
else if (spins <= 0) |
838 |
< |
node = new QNode(); |
868 |
> |
while ((p = getPhase()) == phase && !interrupted) { |
869 |
> |
if (Thread.interrupted()) |
870 |
> |
interrupted = true; |
871 |
> |
else if (node == null) |
872 |
> |
node = new QNode(this, phase, true, false, 0, 0); |
873 |
> |
else if (!queued) |
874 |
> |
queued = tryEnqueue(node); |
875 |
|
else |
876 |
< |
--spins; |
876 |
> |
interrupted = node.doWait(); |
877 |
|
} |
878 |
|
if (node != null) |
879 |
|
node.thread = null; |
880 |
+ |
if (p != phase || (p = getPhase()) != phase) |
881 |
+ |
releaseWaiters(phase); |
882 |
|
if (interrupted) |
883 |
|
throw new InterruptedException(); |
846 |
– |
releaseWaiters(phase); |
884 |
|
return p; |
885 |
|
} |
886 |
|
|
887 |
|
/** |
888 |
< |
* Even messier timeout version. |
888 |
> |
* Timeout version. |
889 |
> |
* @return current phase |
890 |
|
*/ |
891 |
|
private int timedWait(int phase, long nanos) |
892 |
|
throws InterruptedException, TimeoutException { |
893 |
+ |
long startTime = System.nanoTime(); |
894 |
+ |
QNode node = null; |
895 |
+ |
boolean queued = false; |
896 |
+ |
boolean interrupted = false; |
897 |
|
int p; |
898 |
< |
if ((p = getPhase()) == phase) { |
899 |
< |
long lastTime = System.nanoTime(); |
900 |
< |
int spins = maxTimedSpins; |
901 |
< |
QNode node = null; |
902 |
< |
boolean queued = false; |
903 |
< |
boolean interrupted = false; |
904 |
< |
while ((p = getPhase()) == phase) { |
905 |
< |
if (interrupted = Thread.interrupted()) |
906 |
< |
break; |
907 |
< |
long now = System.nanoTime(); |
908 |
< |
if ((nanos -= now - lastTime) <= 0) |
867 |
< |
break; |
868 |
< |
lastTime = now; |
869 |
< |
if (node != null) { |
870 |
< |
if (!queued) { |
871 |
< |
AtomicReference<QNode> head = queueFor(phase); |
872 |
< |
queued = head.compareAndSet(node.next = head.get(), node); |
873 |
< |
} |
874 |
< |
else if (node.thread != null && |
875 |
< |
nanos > spinForTimeoutThreshold) { |
876 |
< |
LockSupport.parkNanos(this, nanos); |
877 |
< |
} |
878 |
< |
} |
879 |
< |
else if (spins <= 0) |
880 |
< |
node = new QNode(); |
881 |
< |
else |
882 |
< |
--spins; |
883 |
< |
} |
884 |
< |
if (node != null) |
885 |
< |
node.thread = null; |
886 |
< |
if (interrupted) |
887 |
< |
throw new InterruptedException(); |
888 |
< |
if (p == phase && (p = getPhase()) == phase) |
889 |
< |
throw new TimeoutException(); |
898 |
> |
while ((p = getPhase()) == phase && !interrupted) { |
899 |
> |
if (Thread.interrupted()) |
900 |
> |
interrupted = true; |
901 |
> |
else if (nanos - (System.nanoTime() - startTime) <= 0) |
902 |
> |
break; |
903 |
> |
else if (node == null) |
904 |
> |
node = new QNode(this, phase, true, true, startTime, nanos); |
905 |
> |
else if (!queued) |
906 |
> |
queued = tryEnqueue(node); |
907 |
> |
else |
908 |
> |
interrupted = node.doWait(); |
909 |
|
} |
910 |
< |
releaseWaiters(phase); |
910 |
> |
if (node != null) |
911 |
> |
node.thread = null; |
912 |
> |
if (p != phase || (p = getPhase()) != phase) |
913 |
> |
releaseWaiters(phase); |
914 |
> |
if (interrupted) |
915 |
> |
throw new InterruptedException(); |
916 |
> |
if (p == phase) |
917 |
> |
throw new TimeoutException(); |
918 |
|
return p; |
919 |
|
} |
920 |
|
|
921 |
< |
// Temporary Unsafe mechanics for preliminary release |
921 |
> |
// Unsafe mechanics |
922 |
|
|
923 |
< |
static final Unsafe _unsafe; |
924 |
< |
static final long stateOffset; |
923 |
> |
private static final sun.misc.Unsafe UNSAFE = getUnsafe(); |
924 |
> |
private static final long stateOffset = |
925 |
> |
objectFieldOffset("state", Phaser.class); |
926 |
|
|
927 |
< |
static { |
927 |
> |
private final boolean casState(long cmp, long val) { |
928 |
> |
return UNSAFE.compareAndSwapLong(this, stateOffset, cmp, val); |
929 |
> |
} |
930 |
> |
|
931 |
> |
private static long objectFieldOffset(String field, Class<?> klazz) { |
932 |
|
try { |
933 |
< |
if (Phaser.class.getClassLoader() != null) { |
934 |
< |
Field f = Unsafe.class.getDeclaredField("theUnsafe"); |
935 |
< |
f.setAccessible(true); |
936 |
< |
_unsafe = (Unsafe)f.get(null); |
937 |
< |
} |
938 |
< |
else |
908 |
< |
_unsafe = Unsafe.getUnsafe(); |
909 |
< |
stateOffset = _unsafe.objectFieldOffset |
910 |
< |
(Phaser.class.getDeclaredField("state")); |
911 |
< |
} catch (Exception e) { |
912 |
< |
throw new RuntimeException("Could not initialize intrinsics", e); |
933 |
> |
return UNSAFE.objectFieldOffset(klazz.getDeclaredField(field)); |
934 |
> |
} catch (NoSuchFieldException e) { |
935 |
> |
// Convert Exception to corresponding Error |
936 |
> |
NoSuchFieldError error = new NoSuchFieldError(field); |
937 |
> |
error.initCause(e); |
938 |
> |
throw error; |
939 |
|
} |
940 |
|
} |
941 |
|
|
942 |
< |
final boolean casState(long cmp, long val) { |
943 |
< |
return _unsafe.compareAndSwapLong(this, stateOffset, cmp, val); |
942 |
> |
/** |
943 |
> |
* Returns a sun.misc.Unsafe. Suitable for use in a 3rd party package. |
944 |
> |
* Replace with a simple call to Unsafe.getUnsafe when integrating |
945 |
> |
* into a jdk. |
946 |
> |
* |
947 |
> |
* @return a sun.misc.Unsafe |
948 |
> |
*/ |
949 |
> |
private static sun.misc.Unsafe getUnsafe() { |
950 |
> |
try { |
951 |
> |
return sun.misc.Unsafe.getUnsafe(); |
952 |
> |
} catch (SecurityException se) { |
953 |
> |
try { |
954 |
> |
return java.security.AccessController.doPrivileged |
955 |
> |
(new java.security |
956 |
> |
.PrivilegedExceptionAction<sun.misc.Unsafe>() { |
957 |
> |
public sun.misc.Unsafe run() throws Exception { |
958 |
> |
java.lang.reflect.Field f = sun.misc |
959 |
> |
.Unsafe.class.getDeclaredField("theUnsafe"); |
960 |
> |
f.setAccessible(true); |
961 |
> |
return (sun.misc.Unsafe) f.get(null); |
962 |
> |
}}); |
963 |
> |
} catch (java.security.PrivilegedActionException e) { |
964 |
> |
throw new RuntimeException("Could not initialize intrinsics", |
965 |
> |
e.getCause()); |
966 |
> |
} |
967 |
> |
} |
968 |
|
} |
969 |
|
} |