/** * _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); }
private static LockResult lockCombine(Transaction txn, LockResult r1, LockResult r2) { if (r2.isAcquired()) { if (r1 == r2) { txn.unlockCombine(); } return r2; } else { return r1.isAcquired() ? r1 : r1.commonOwned(r2); } }
if (result.isTimedOut()) { Object att = waitingFor == null ? null : waitingFor.findOwnerAttachment(this, lockType);
static RuntimeException lockCleanup(Throwable e, Transaction txn, LockResult result) { if (result.isAcquired()) { try { txn.unlock(); } catch (Throwable e2) { Utils.suppress(e, e2); } } throw Utils.rethrow(e); }
@Override public LockResult lockCheck(Transaction txn, byte[] key) throws ViewConstraintException { LockResult r1 = mFirst.lockCheck(txn, key); if (r1 == LockResult.UNOWNED) { return r1; } LockResult r2 = mSecond.lockCheck(txn, key); return r2 == LockResult.UNOWNED ? r2 : r1.commonOwned(r2); }
if (result.isTimedOut()) { Object att = waitingFor == null ? null : waitingFor.findOwnerAttachment(this, lockType);
if (result.isAcquired()) { c.link().unlock();
@Override public LockResult skip(long amount) throws IOException { if (amount == 0) { return mFirst.skip(0).commonOwned(mSecond.skip(0)); } return ViewUtils.skipWithLocks(this, amount); }
/** * 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); }
if (result.isTimedOut()) { Object att = waitingFor == null ? null : waitingFor.findOwnerAttachment(this, lockType, hash);
private LockResult resultCombine(Transaction txn, LockResult r1, LockResult r2) { if (r1.isAcquired()) { if (r1 == r2) { txn.unlockCombine(); } return r1; } else if (r2.isAcquired()) { return r2; } else { return r1.commonOwned(r2); } }
/** * Called by select method when the second value must be selected and the corresponding * first value doesn't exist. This cursor's key and value are set as a side effect. * * @return null if cursor must be moved before select can be called again */ protected LockResult selectSecond(Transaction txn, byte[] key) throws IOException { mKey = key; mValue = Cursor.NOT_LOADED; mSecond.link(txn); try { LockResult r1 = mView.mFirst.touch(txn, key); LockResult r2 = autoload() ? mSecond.load() : mSecond.lock(); byte[] value = mSecond.value(); mValue = value; if (value == null) { if (r1.isAcquired()) { txn.unlock(); } if (r2.isAcquired()) { txn.unlock(); } return null; } return resultCombine(txn, r1, r2); } finally { mSecond.link(Transaction.BOGUS); } }
/** * 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); }
if (result.isTimedOut()) { Object att = waitingFor == null ? null : waitingFor.findOwnerAttachment(this, lockType);
/** * Called by select method when the first value must be selected and the corresponding * second value doesn't exist. This cursor's key and value is set as a side effect. * * @return null if cursor must be moved before select can be called again */ protected LockResult selectFirst(Transaction txn, byte[] key) throws IOException { mKey = key; mValue = Cursor.NOT_LOADED; mFirst.link(txn); try { LockResult r1 = autoload() ? mFirst.load() : mFirst.lock(); LockResult r2 = mView.mSecond.touch(txn, key); byte[] value = mFirst.value(); mValue = value; if (value == null) { if (r1.isAcquired()) { txn.unlock(); } if (r2.isAcquired()) { txn.unlock(); } return null; } return resultCombine(txn, r1, r2); } finally { mFirst.link(Transaction.BOGUS); } }
/** * 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); }
if (result.isTimedOut()) { Object att = waitingFor == null ? null : waitingFor.findOwnerAttachment(this, lockType, hash);
@Override public boolean step() throws IOException { LockResult result = mLockResult; if (result == null) { return false; } Cursor c = mCursor; tryStep: { if (result.isAcquired()) { c.link().unlock(); } try { result = c.next(); } catch (UnpositionedCursorException e) { break tryStep; } catch (Throwable e) { throw ViewUtils.fail(this, e); } if (c.key() != null) { mLockResult = result; return true; } } mLockResult = null; finished(); return false; }
/** * _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); }
if (result.isTimedOut()) { Object att = waitingFor == null ? null : waitingFor.findOwnerAttachment(this, lockType);