/** * Called with any latch held, which is retained. * * @return UNOWNED, OWNED_SHARED, OWNED_UPGRADABLE, or OWNED_EXCLUSIVE */ LockResult check(_LockOwner locker) { int count = mLockCount; return mOwner == locker ? (count == ~0 ? OWNED_EXCLUSIVE : OWNED_UPGRADABLE) : ((count != 0 && isSharedLockOwner(locker)) ? OWNED_SHARED : UNOWNED); }
/** * Called with any latch held, which is retained. * * @return UNOWNED, OWNED_SHARED, OWNED_UPGRADABLE, or OWNED_EXCLUSIVE */ LockResult check(_LockOwner locker) { int count = mLockCount; return mOwner == locker ? (count == ~0 ? OWNED_EXCLUSIVE : OWNED_UPGRADABLE) : ((count != 0 && isSharedLockOwner(locker)) ? OWNED_SHARED : UNOWNED); }
/** * Called with any latch held, which is retained. * * @return UNOWNED, OWNED_SHARED, OWNED_UPGRADABLE, or OWNED_EXCLUSIVE */ LockResult check(_LockOwner locker) { int count = mLockCount; return mOwner == locker ? (count == ~0 ? OWNED_EXCLUSIVE : OWNED_UPGRADABLE) : ((count != 0 && isSharedLockOwner(locker)) ? OWNED_SHARED : UNOWNED); }
/** * @return ACQUIRED, OWNED_SHARED, or null */ private LockResult tryLockShared(_LockOwner locker) { int count = mLockCount; if (count == ~0) { return null; } if (count != 0 && isSharedLockOwner(locker)) { return OWNED_SHARED; } if ((count & 0x7fffffff) >= 0x7ffffffe) { throw new IllegalStateException("Too many shared locks held"); } addSharedLockOwner(count, locker); return ACQUIRED; }
/** * @return ACQUIRED, OWNED_SHARED, or null */ private LockResult tryLockShared(_LockOwner locker) { int count = mLockCount; if (count == ~0) { return null; } if (count != 0 && isSharedLockOwner(locker)) { return OWNED_SHARED; } if ((count & 0x7fffffff) >= 0x7ffffffe) { throw new IllegalStateException("Too many shared locks held"); } addSharedLockOwner(count, locker); return ACQUIRED; }
/** * @return ACQUIRED, OWNED_SHARED, or null */ private LockResult tryLockShared(_LockOwner locker) { int count = mLockCount; if (count == ~0) { return null; } if (count != 0 && isSharedLockOwner(locker)) { return OWNED_SHARED; } if ((count & 0x7fffffff) >= 0x7ffffffe) { throw new IllegalStateException("Too many shared locks held"); } addSharedLockOwner(count, locker); return ACQUIRED; }
/** * Called with exclusive latch held, which is retained. * * @param latch briefly released and re-acquired for deleting a ghost * @throws IllegalStateException if lock not held */ void unlockToUpgradable(_LockOwner locker, Latch latch) { if (mOwner != locker) { String message = "Exclusive or upgradable lock not held"; if (mLockCount == 0 || !isSharedLockOwner(locker)) { message = "_Lock not held"; } throw new IllegalStateException(message); } if (mLockCount != ~0) { // Already upgradable. return; } deleteGhost(latch); mLockCount = 0x80000000; LatchCondition queueSX = mQueueSX; if (queueSX != null) { queueSX.signalShared(); } }
} else if (mLockCount == 0 || !isSharedLockOwner(locker)) { throw new IllegalStateException("_Lock not held");
if (count != 0 && isSharedLockOwner(locker)) { if (!locker.canAttemptUpgrade(count)) { return ILLEGAL; if (count != 0 && isSharedLockOwner(locker)) { if (!locker.canAttemptUpgrade(count)) {
if (count != 0 && isSharedLockOwner(locker)) { if (!locker.canAttemptUpgrade(count)) { return ILLEGAL; if (count != 0 && isSharedLockOwner(locker)) { if (!locker.canAttemptUpgrade(count)) {
if (mLockCount != 0 && isSharedLockOwner(locker)) { return OWNED_SHARED;
if (count != 0 && isSharedLockOwner(locker)) { if (!locker.canAttemptUpgrade(count)) { return ILLEGAL; if (count != 0 && isSharedLockOwner(locker)) { if (!locker.canAttemptUpgrade(count)) {
/** * Called with exclusive latch held, which is released unless an exception is thrown. * * @param latch briefly released and re-acquired for deleting a ghost * @throws IllegalStateException if lock not held */ void unlockToUpgradable(_LockOwner locker, Latch latch) { if (mOwner != locker) { if (isClosed(locker)) { latch.releaseExclusive(); return; } String message = "Exclusive or upgradable lock not held"; if (mLockCount == 0 || !isSharedLockOwner(locker)) { message = "Lock not held"; } throw new IllegalStateException(message); } if (mLockCount != ~0) { // Already upgradable. latch.releaseExclusive(); return; } deleteGhost(latch); mLockCount = 0x80000000; LatchCondition queueSX = mQueueSX; if (queueSX == null || !queueSX.signalSharedRelease(latch)) { latch.releaseExclusive(); } }
if (mLockCount != 0 && isSharedLockOwner(locker)) { return OWNED_SHARED;
/** * Called with exclusive latch held, which is released unless an exception is thrown. * * @param latch briefly released and re-acquired for deleting a ghost * @throws IllegalStateException if lock not held */ void unlockToUpgradable(_LockOwner locker, Latch latch) { if (mOwner != locker) { if (isClosed(locker)) { latch.releaseExclusive(); return; } String message = "Exclusive or upgradable lock not held"; if (mLockCount == 0 || !isSharedLockOwner(locker)) { message = "Lock not held"; } throw new IllegalStateException(message); } if (mLockCount != ~0) { // Already upgradable. latch.releaseExclusive(); return; } deleteGhost(latch); mLockCount = 0x80000000; LatchCondition queueSX = mQueueSX; if (queueSX == null || !queueSX.signalSharedRelease(latch)) { latch.releaseExclusive(); } }
return; } else if ((mLockCount == 0 || !isSharedLockOwner(locker)) && !isClosed(locker)) { throw new IllegalStateException("Lock not held");
return; } else if ((mLockCount == 0 || !isSharedLockOwner(locker)) && !isClosed(locker)) { throw new IllegalStateException("Lock not held");