/** * NT == No Timeout or deadlock exception thrown * * @param lockType TYPE_SHARED, TYPE_UPGRADABLE, or TYPE_EXCLUSIVE * @return {@link LockResult#TIMED_OUT_LOCK TIMED_OUT_LOCK}, {@link * LockResult#ACQUIRED ACQUIRED}, {@link LockResult#OWNED_SHARED * OWNED_SHARED}, {@link LockResult#OWNED_UPGRADABLE OWNED_UPGRADABLE}, or * {@link LockResult#OWNED_EXCLUSIVE OWNED_EXCLUSIVE} */ @SuppressWarnings("incomplete-switch") final LockResult lockNT(int lockType, long indexId, byte[] key, int hash, long nanosTimeout) throws LockFailureException { LockResult result = manager().getLockHT(hash) .tryLock(lockType, this, indexId, key, hash, nanosTimeout); if (!result.isHeld()) { switch (result) { case ILLEGAL: throw new IllegalUpgradeException(); case INTERRUPTED: throw new LockInterruptedException(); } } return result; }
/** * NT == No Timeout or deadlock exception thrown * * @param lockType TYPE_SHARED, TYPE_UPGRADABLE, or TYPE_EXCLUSIVE * @return {@link LockResult#TIMED_OUT_LOCK TIMED_OUT_LOCK}, {@link * LockResult#ACQUIRED ACQUIRED}, {@link LockResult#OWNED_SHARED * OWNED_SHARED}, {@link LockResult#OWNED_UPGRADABLE OWNED_UPGRADABLE}, or * {@link LockResult#OWNED_EXCLUSIVE OWNED_EXCLUSIVE} */ @SuppressWarnings("incomplete-switch") final LockResult lockNT(int lockType, long indexId, byte[] key, int hash, long nanosTimeout) throws LockFailureException { LockResult result = manager().getLockHT(hash) .tryLock(lockType, this, indexId, key, hash, nanosTimeout); if (!result.isHeld()) { switch (result) { case ILLEGAL: throw new IllegalUpgradeException(); case INTERRUPTED: throw new LockInterruptedException(); } } return result; }
/** * @param lockType TYPE_SHARED, TYPE_UPGRADABLE, or TYPE_EXCLUSIVE */ final LockResult tryLock(int lockType, long indexId, byte[] key, int hash, long nanosTimeout) throws DeadlockException { LockResult result = manager().getLockHT(hash) .tryLock(lockType, this, indexId, key, hash, nanosTimeout); if (result == LockResult.TIMED_OUT_LOCK) { Lock waitingFor = mWaitingFor; if (waitingFor != null) { try { // Perform deadlock detection except for the fast-fail case. if (nanosTimeout != 0) { waitingFor.detectDeadlock(this, lockType, nanosTimeout); } } finally { mWaitingFor = null; } } } return result; }
/** * @param lockType TYPE_SHARED, TYPE_UPGRADABLE, or TYPE_EXCLUSIVE */ final LockResult tryLock(int lockType, long indexId, byte[] key, int hash, long nanosTimeout) throws DeadlockException { LockResult result = manager().getLockHT(hash) .tryLock(lockType, this, indexId, key, hash, nanosTimeout); if (result == LockResult.TIMED_OUT_LOCK) { Lock waitingFor = mWaitingFor; if (waitingFor != null) { try { // Perform deadlock detection except for the fast-fail case. if (nanosTimeout != 0) { detectDeadlock(waitingFor, lockType, nanosTimeout, hash); } } finally { mWaitingFor = null; } } } return result; }
/** * NT == No Timeout or deadlock exception thrown * * @param lockType TYPE_SHARED, TYPE_UPGRADABLE, or TYPE_EXCLUSIVE * @return {@link LockResult#TIMED_OUT_LOCK TIMED_OUT_LOCK}, {@link * LockResult#ACQUIRED ACQUIRED}, {@link LockResult#OWNED_SHARED * OWNED_SHARED}, {@link LockResult#OWNED_UPGRADABLE OWNED_UPGRADABLE}, or * {@link LockResult#OWNED_EXCLUSIVE OWNED_EXCLUSIVE} */ @SuppressWarnings("incomplete-switch") final LockResult lockNT(int lockType, long indexId, byte[] key, int hash, long nanosTimeout) throws LockFailureException { LockResult result = manager().getLockHT(hash) .tryLock(lockType, this, indexId, key, hash, nanosTimeout); if (!result.isHeld()) { switch (result) { case ILLEGAL: throw new IllegalUpgradeException(); case INTERRUPTED: throw new LockInterruptedException(); } } return result; }
/** * @param lockType TYPE_SHARED, TYPE_UPGRADABLE, or TYPE_EXCLUSIVE */ final LockResult tryLock(int lockType, long indexId, byte[] key, int hash, long nanosTimeout) throws DeadlockException { LockResult result = manager().getLockHT(hash) .tryLock(lockType, this, indexId, key, hash, nanosTimeout); if (result == LockResult.TIMED_OUT_LOCK) { Lock waitingFor = mWaitingFor; if (waitingFor != null) { try { // Perform deadlock detection except for the fast-fail case. if (nanosTimeout != 0) { waitingFor.detectDeadlock(this, lockType, nanosTimeout); } } finally { mWaitingFor = null; } } } return result; }
/** * @param lockType TYPE_SHARED, TYPE_UPGRADABLE, or TYPE_EXCLUSIVE */ final LockResult lock(int lockType, long indexId, byte[] key, int hash, long nanosTimeout) throws LockFailureException { LockResult result = manager().getLockHT(hash) .tryLock(lockType, this, indexId, key, hash, nanosTimeout); if (result.isHeld()) { return result; } throw failed(lockType, result, nanosTimeout); }
/** * @param lockType TYPE_SHARED, TYPE_UPGRADABLE, or TYPE_EXCLUSIVE */ final LockResult lock(int lockType, long indexId, byte[] key, int hash, long nanosTimeout) throws LockFailureException { LockResult result = manager().getLockHT(hash) .tryLock(lockType, this, indexId, key, hash, nanosTimeout); if (result.isHeld()) { return result; } throw failed(lockType, result, nanosTimeout, hash); }
final Locker lockExclusiveLocal(long indexId, byte[] key, int hash) throws LockFailureException { Locker locker = localLocker(); LockResult result = getLockHT(hash) .tryLock(TYPE_EXCLUSIVE, locker, indexId, key, hash, mDefaultTimeoutNanos); if (result.isHeld()) { return locker; } throw locker.failed(TYPE_EXCLUSIVE, result, mDefaultTimeoutNanos); }
final Locker lockSharedLocal(long indexId, byte[] key, int hash) throws LockFailureException { Locker locker = localLocker(); LockResult result = getLockHT(hash) .tryLock(TYPE_SHARED, locker, indexId, key, hash, mDefaultTimeoutNanos); if (result.isHeld()) { return locker; } throw locker.failed(TYPE_SHARED, result, mDefaultTimeoutNanos, hash); }
final Locker lockExclusiveLocal(long indexId, byte[] key, int hash) throws LockFailureException { Locker locker = localLocker(); LockResult result = getLockHT(hash) .tryLock(TYPE_EXCLUSIVE, locker, indexId, key, hash, mDefaultTimeoutNanos); if (result.isHeld()) { return locker; } throw locker.failed(TYPE_EXCLUSIVE, result, mDefaultTimeoutNanos); }
final Locker lockExclusiveLocal(long indexId, byte[] key, int hash) throws LockFailureException { Locker locker = localLocker(); LockResult result = getLockHT(hash) .tryLock(TYPE_EXCLUSIVE, locker, indexId, key, hash, mDefaultTimeoutNanos); if (result.isHeld()) { return locker; } throw locker.failed(TYPE_EXCLUSIVE, result, mDefaultTimeoutNanos, hash); }
/** * @param lockType TYPE_SHARED, TYPE_UPGRADABLE, or TYPE_EXCLUSIVE */ final LockResult lock(int lockType, long indexId, byte[] key, int hash, long nanosTimeout) throws LockFailureException { LockResult result = manager().getLockHT(hash) .tryLock(lockType, this, indexId, key, hash, nanosTimeout); if (result.isHeld()) { return result; } throw failed(lockType, result, nanosTimeout); }
final Locker lockSharedLocal(long indexId, byte[] key, int hash) throws LockFailureException { Locker locker = localLocker(); LockResult result = getLockHT(hash) .tryLock(TYPE_SHARED, locker, indexId, key, hash, mDefaultTimeoutNanos); if (result.isHeld()) { return locker; } throw locker.failed(TYPE_SHARED, result, mDefaultTimeoutNanos); }
final Locker lockSharedLocal(long indexId, byte[] key, int hash) throws LockFailureException { Locker locker = localLocker(); LockResult result = getLockHT(hash) .tryLock(TYPE_SHARED, locker, indexId, key, hash, mDefaultTimeoutNanos); if (result.isHeld()) { return locker; } throw locker.failed(TYPE_SHARED, result, mDefaultTimeoutNanos); }