void unlockLastToShared(Locker locker) { int size = mSize - 1; if ((mUpgrades & (1L << size)) != 0) { throw new IllegalStateException("Cannot unlock non-immediate upgrade"); } locker.mManager.unlockToShared(locker, mLocks[size]); }
void unlockLastToShared(Locker locker) { int size = mSize - 1; if ((mUpgrades & (1L << size)) != 0) { throw new IllegalStateException("Cannot unlock non-immediate upgrade"); } locker.mManager.unlockToShared(locker, mLocks[size]); }
static void unlockLastToShared(Block block, Locker locker) { int size = block.mSize; while (true) { size--; long mask = (1L << 63) >>> size; if ((block.mUpgrades & mask) != 0) { throw new IllegalStateException("Cannot unlock non-immediate upgrade"); } Lock lock = block.mLocks[size]; block.parentCheck(locker, lock); locker.mManager.unlockToShared(locker, lock); if ((block.mUnlockGroup & mask) == 0) { return; } if (size == 0) { block = block.mPrev; size = block.mSize; } } }
/** * Releases the last lock or group acquired, within the current scope, retaining a shared * lock. If the last lock operation was an upgrade, for a lock not immediately acquired, * unlock is not allowed. Instead, an IllegalStateException is thrown. * * <p><i>Note: This method is intended for advanced use cases.</i> * * @throws IllegalStateException if no locks held, or if crossing a scope boundary, or if * too many shared locks, or if unlocking a non-immediate upgrade */ public final void unlockToShared() { Object tailObj = mTailBlock; if (tailObj == null) { throw new IllegalStateException("No locks held"); } if (tailObj instanceof Lock) { ParentScope parent = mParentScope; if (parent != null && parent.mTailBlock == tailObj) { throw new IllegalStateException("Cannot cross a scope boundary"); } mManager.unlockToShared(this, (Lock) tailObj); } else { Block.unlockLastToShared((Block) tailObj, this); } }
/** * Releases last lock acquired, within the current scope, retaining a * shared lock. If the last lock operation was an upgrade, for a lock not * immediately acquired, unlock is not allowed. Instead, an * IllegalStateException is thrown. * * <p><i>Note: This method is intended for advanced use cases.</i> Also, the current * implementation does not accurately track scopes. It may permit an unlock operation to * cross a scope boundary, which has undefined behavior. * * @throws IllegalStateException if no locks held, or if too many shared * locks, or if unlocking a non-immediate upgrade */ public final void unlockToShared() { Object tailObj = mTailBlock; if (tailObj == null) { throw new IllegalStateException("No locks held"); } if (tailObj instanceof Lock) { mManager.unlockToShared(this, (Lock) tailObj); } else { ((Block) tailObj).unlockLastToShared(this); } }
/** * Releases last lock acquired, within the current scope, retaining a * shared lock. If the last lock operation was an upgrade, for a lock not * immediately acquired, unlock is not allowed. Instead, an * IllegalStateException is thrown. * * <p><i>Note: This method is intended for advanced use cases.</i> Also, the current * implementation does not accurately track scopes. It may permit an unlock operation to * cross a scope boundary, which has undefined behavior. * * @throws IllegalStateException if no locks held, or if too many shared * locks, or if unlocking a non-immediate upgrade */ public final void unlockToShared() { Object tailObj = mTailBlock; if (tailObj == null) { throw new IllegalStateException("No locks held"); } if (tailObj instanceof Lock) { mManager.unlockToShared(this, (Lock) tailObj); } else { ((Block) tailObj).unlockLastToShared(this); } }