/** * Returns true if a shared lock can be granted for the given key. Caller must hold the * node latch which contains the key. * * @param locker optional locker */ boolean isAvailable(_LockOwner locker, long indexId, byte[] key, int hash) { // Optimistically find the lock. int stamp = mStamp; if (stamp >= 0) { _Lock lock = lockFor(indexId, key, hash); if (lock != null) { return lock.isAvailable(locker); } if (stamp == mStamp) { return true; } } _Lock lock; acquireShared(); try { lock = lockFor(indexId, key, hash); } finally { releaseShared(); } return lock == null ? true : lock.isAvailable(locker); }
/** * Returns true if a shared lock can be granted for the given key. Caller must hold the * node latch which contains the key. * * @param locker optional locker */ boolean isAvailable(_LockOwner locker, long indexId, byte[] key, int hash) { // Optimistically find the lock. int stamp = mStamp; if (stamp >= 0) { _Lock lock = lockFor(indexId, key, hash); if (lock != null) { return lock.isAvailable(locker); } if (stamp == mStamp) { return true; } } _Lock lock; acquireShared(); try { lock = lockFor(indexId, key, hash); } finally { releaseShared(); } return lock == null ? true : lock.isAvailable(locker); }
/** * Mark a lock as referencing a ghosted entry. Caller must ensure that lock * is already exclusively held. * * @param frame must be bound to the ghost position */ final void ghosted(long indexId, byte[] key, int hash, _GhostFrame frame) { LockHT ht = getLockHT(hash); ht.acquireExclusive(); try { ht.lockFor(indexId, key, hash).setGhostFrame(frame); } finally { ht.releaseExclusive(); } }
/** * Mark a lock as referencing a ghosted entry. Caller must ensure that lock * is already exclusively held. * * @param frame must be bound to the ghost position */ final void ghosted(long indexId, byte[] key, int hash, _CursorFrame.Ghost frame) { LockHT ht = getLockHT(hash); ht.acquireExclusive(); try { ht.lockFor(indexId, key, hash).setGhostFrame(frame); } finally { ht.releaseExclusive(); } }
/** * Mark a lock as referencing a ghosted entry. Caller must ensure that lock * is already exclusively held. * * @param frame must be bound to the ghost position */ final void ghosted(long indexId, byte[] key, int hash, _CursorFrame.Ghost frame) { LockHT ht = getLockHT(hash); ht.acquireExclusive(); try { ht.lockFor(indexId, key, hash).mSharedLockOwnersObj = frame; } finally { ht.releaseExclusive(); } }
/** * Returns true if a shared lock can be granted for the given key. Caller must hold the * node latch which contains the key. * * @param locker optional locker */ final boolean isAvailable(_LockOwner locker, long indexId, byte[] key, int hash) { // Note that no LockHT latch is acquired. The current thread is not required to // immediately observe the activity of other threads acting upon the same lock. If // another thread has just acquired an exclusive lock, it must still acquire the node // latch before any changes can be made. _Lock lock = getLockHT(hash).lockFor(indexId, key, hash); return lock == null ? true : lock.isAvailable(locker); }
final LockResult check(_LockOwner locker, long indexId, byte[] key, int hash) { LockHT ht = getLockHT(hash); ht.acquireShared(); try { _Lock lock = ht.lockFor(indexId, key, hash); return lock == null ? LockResult.UNOWNED : lock.check(locker); } finally { ht.releaseShared(); } }
final LockResult check(_LockOwner locker, long indexId, byte[] key, int hash) { LockHT ht = getLockHT(hash); ht.acquireShared(); try { _Lock lock = ht.lockFor(indexId, key, hash); return lock == null ? LockResult.UNOWNED : lock.check(locker); } finally { ht.releaseShared(); } }
final LockResult check(_LockOwner locker, long indexId, byte[] key, int hash) { LockHT ht = getLockHT(hash); ht.acquireShared(); try { _Lock lock = ht.lockFor(indexId, key, hash); return lock == null ? LockResult.UNOWNED : lock.check(locker); } finally { ht.releaseShared(); } }