/** * Adds a new unarrived party to this phaser. If an ongoing * invocation of {@link #onAdvance} is in progress, this method * may await its completion before returning. If this phaser has * a parent, and this phaser previously had no registered parties, * this child phaser is also registered with its parent. If * this phaser is terminated, the attempt to register has * no effect, and a negative value is returned. * * @return the arrival phase number to which this registration * applied. If this value is negative, then this phaser has * terminated, in which case registration has no effect. * @throws IllegalStateException if attempting to register more * than the maximum supported number of parties */ public int register() { return doRegister(1); }
this.oddQ = root.oddQ; if (parties != 0) phase = parent.doRegister(1);
/** * Adds the given number of new unarrived parties to this phaser. * If an ongoing invocation of {@link #onAdvance} is in progress, * this method may await its completion before returning. If this * phaser has a parent, and the given number of parties is greater * than zero, and this phaser previously had no registered * parties, this child phaser is also registered with its parent. * If this phaser is terminated, the attempt to register has no * effect, and a negative value is returned. * * @param parties the number of additional parties required to * advance to the next phase * @return the arrival phase number to which this registration * applied. If this value is negative, then this phaser has * terminated, in which case registration has no effect. * @throws IllegalStateException if attempting to register more * than the maximum supported number of parties * @throws IllegalArgumentException if {@code parties < 0} */ public int bulkRegister(int parties) { if (parties < 0) throw new IllegalArgumentException(); if (parties == 0) return getPhase(); return doRegister(parties); }
synchronized (this) { // 1st sub registration if (state == s) { // recheck under lock phase = parent.doRegister(1); if (phase < 0) break;
/** * Adds a new unarrived party to this phaser. If an ongoing * invocation of {@link #onAdvance} is in progress, this method * may await its completion before returning. If this phaser has * a parent, and this phaser previously had no registered parties, * this child phaser is also registered with its parent. If * this phaser is terminated, the attempt to register has * no effect, and a negative value is returned. * * @return the arrival phase number to which this registration * applied. If this value is negative, then this phaser has * terminated, in which case registration has no effect. * @throws IllegalStateException if attempting to register more * than the maximum supported number of parties */ public int register() { return doRegister(1); }
this.oddQ = root.oddQ; if (parties != 0) phase = parent.doRegister(1);
/** * Adds the given number of new unarrived parties to this phaser. * If an ongoing invocation of {@link #onAdvance} is in progress, * this method may await its completion before returning. If this * phaser has a parent, and the given number of parties is greater * than zero, and this phaser previously had no registered * parties, this child phaser is also registered with its parent. * If this phaser is terminated, the attempt to register has no * effect, and a negative value is returned. * * @param parties the number of additional parties required to * advance to the next phase * @return the arrival phase number to which this registration * applied. If this value is negative, then this phaser has * terminated, in which case registration has no effect. * @throws IllegalStateException if attempting to register more * than the maximum supported number of parties * @throws IllegalArgumentException if {@code parties < 0} */ public int bulkRegister(int parties) { if (parties < 0) throw new IllegalArgumentException(); if (parties == 0) return getPhase(); return doRegister(parties); }
synchronized (this) { // 1st sub registration if (state == s) { // recheck under lock par.doRegister(1); do { // force current phase phase = (int)(root.state >>> PHASE_SHIFT);