/** * _Lock acquisition used by recovery. * * @param lock _Lock instance to insert, unless another already exists. The mIndexId, * mKey, and mHashCode fields must be set. */ final LockResult lockExclusive(_Lock lock, long nanosTimeout) throws LockFailureException { LockResult result = mManager.getLockHT(lock.mHashCode) .tryLockExclusive(this, lock, nanosTimeout); if (result.isHeld()) { return result; } throw failed(TYPE_EXCLUSIVE, result, nanosTimeout, lock.mHashCode); }
/** * _Lock acquisition used by recovery. * * @param lock _Lock instance to insert, unless another already exists. The mIndexId, * mKey, and mHashCode fields must be set. */ final LockResult lockExclusive(_Lock lock, long nanosTimeout) throws LockFailureException { LockResult result = mManager.getLockHT(lock.mHashCode) .tryLockExclusive(this, lock, nanosTimeout); if (result.isHeld()) { return result; } throw failed(TYPE_EXCLUSIVE, result, nanosTimeout); }
/** * _Lock acquisition used by recovery. * * @param lock _Lock instance to insert, unless another already exists. The mIndexId, * mKey, and mHashCode fields must be set. */ final LockResult lockExclusive(_Lock lock, long nanosTimeout) throws LockFailureException { LockResult result = mManager.getLockHT(lock.mHashCode) .tryLockExclusive(this, lock, nanosTimeout); if (result.isHeld()) { return result; } throw failed(TYPE_EXCLUSIVE, 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, 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); }
/** * @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 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); }
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); }
/** * @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); }
/** * Acquire an upgradable lock, with infinite timeout, but don't push the lock into the * owned lock stack. Returns the lock which was acquired, or null if already owned. */ final _Lock lockUpgradableNoPush(long indexId, byte[] key) throws LockFailureException { int hash = hash(indexId, key); _LockManager.LockHT ht = mManager.getLockHT(hash); _Lock lock; LockResult result; ht.acquireExclusive(); try { lock = ht.lockAccess(indexId, key, hash); result = lock.tryLockUpgradable(ht, this, -1); } finally { ht.releaseExclusive(); } if (!result.isHeld()) { throw failed(TYPE_UPGRADABLE, result, -1); } return result == LockResult.ACQUIRED ? lock : null; }
/** * Acquire a shared lock, with infinite timeout, but don't push the lock into the owned * lock stack. Returns the lock which was acquired, or null if already owned. */ final _Lock lockSharedNoPush(long indexId, byte[] key) throws LockFailureException { int hash = hash(indexId, key); _LockManager.LockHT ht = mManager.getLockHT(hash); _Lock lock; LockResult result; ht.acquireExclusive(); try { lock = ht.lockAccess(indexId, key, hash); result = lock.tryLockShared(ht, this, -1); } finally { ht.releaseExclusive(); } if (!result.isHeld()) { throw failed(TYPE_SHARED, result, -1); } return result == LockResult.ACQUIRED ? lock : null; }
/** * Acquire a shared lock, with infinite timeout, but don't push the lock into the owned * lock stack. Returns the lock which was acquired, or null if already owned. */ final _Lock lockSharedNoPush(long indexId, byte[] key) throws LockFailureException { int hash = hash(indexId, key); _LockManager.LockHT ht = mManager.getLockHT(hash); _Lock lock; LockResult result; ht.acquireExclusive(); try { lock = ht.lockAccess(indexId, key, hash); result = lock.tryLockShared(ht, this, -1); } finally { ht.releaseExclusive(); } if (!result.isHeld()) { throw failed(TYPE_SHARED, result, -1); } return result == LockResult.ACQUIRED ? lock : null; }
/** * Acquire an upgradable lock, with infinite timeout, but don't push the lock into the * owned lock stack. Returns the lock which was acquired, or null if already owned. */ final _Lock lockUpgradableNoPush(long indexId, byte[] key) throws LockFailureException { int hash = hash(indexId, key); _LockManager.LockHT ht = mManager.getLockHT(hash); _Lock lock; LockResult result; ht.acquireExclusive(); try { lock = ht.lockAccess(indexId, key, hash); result = lock.tryLockUpgradable(ht, this, -1); } finally { ht.releaseExclusive(); } if (!result.isHeld()) { throw failed(TYPE_UPGRADABLE, result, -1); } return result == LockResult.ACQUIRED ? lock : null; }