356 |
|
* @param registrations number to add to both parties and unarrived fields |
357 |
|
*/ |
358 |
|
private int doRegister(int registrations) { |
359 |
< |
long adj = (long)registrations; // adjustment to state |
360 |
< |
adj |= adj << PARTIES_SHIFT; |
361 |
< |
Phaser par = parent; |
359 |
> |
// adjustment to state |
360 |
> |
long adj = ((long)registrations << PARTIES_SHIFT) | registrations; |
361 |
> |
final Phaser parent = this.parent; |
362 |
|
for (;;) { |
363 |
< |
int phase, parties; |
364 |
< |
long s = par == null? state : reconcileState(); |
365 |
< |
if ((phase = (int)(s >>> PHASE_SHIFT)) < 0) |
363 |
> |
long s = (parent == null) ? state : reconcileState(); |
364 |
> |
int phase = (int)(s >>> PHASE_SHIFT); |
365 |
> |
if (phase < 0) |
366 |
|
return phase; |
367 |
< |
if ((parties = (int)s >>> PARTIES_SHIFT) != 0 && |
368 |
< |
((int)s & UNARRIVED_MASK) == 0) |
367 |
> |
int parties = (int)s >>> PARTIES_SHIFT; |
368 |
> |
if (parties != 0 && ((int)s & UNARRIVED_MASK) == 0) |
369 |
|
internalAwaitAdvance(phase, null); // wait for onAdvance |
370 |
|
else if (parties + registrations > MAX_PARTIES) |
371 |
|
throw new IllegalStateException(badRegister(s)); |