Search in sources :

Example 1 with LockResult

use of org.cojen.tupl.LockResult in project Tupl by cojen.

the class DetachedLockImpl method acquireSharedNoPush.

/**
 * Acquire a shared lock, but don't push the lock into the owned lock stack. Returns this
 * lock if acquired, or null if already owned.
 */
final Lock acquireSharedNoPush(LocalTransaction txn) throws LockFailureException {
    long nanosTimeout = txn.lockTimeout(TimeUnit.NANOSECONDS);
    LockResult result;
    LockManager.Bucket bucket = mBucket;
    bucket.acquireExclusive();
    try {
        result = tryLockShared(bucket, txn, nanosTimeout);
    } finally {
        bucket.releaseExclusive();
    }
    if (!result.isHeld()) {
        throw txn.failed(LockManager.TYPE_SHARED, result, nanosTimeout);
    }
    return result == LockResult.ACQUIRED ? this : null;
}
Also used : LockResult(org.cojen.tupl.LockResult)

Example 2 with LockResult

use of org.cojen.tupl.LockResult in project Tupl by cojen.

the class DetachedLockImpl method tryAcquireExclusive.

@Override
public final LockResult tryAcquireExclusive(long nanosTimeout) {
    Locker locker = mOwner;
    LockResult result;
    LockManager.Bucket bucket = mBucket;
    bucket.acquireExclusive();
    try {
        result = tryLockExclusive(bucket, locker, nanosTimeout);
    } finally {
        bucket.releaseExclusive();
    }
    if (result == LockResult.UPGRADED) {
        locker.push(this);
        result = LockResult.ACQUIRED;
    }
    return result;
}
Also used : LockResult(org.cojen.tupl.LockResult)

Example 3 with LockResult

use of org.cojen.tupl.LockResult in project Tupl by cojen.

the class DetachedLockImpl method acquireShared.

final void acquireShared(LocalTransaction txn) throws LockFailureException {
    long nanosTimeout = txn.lockTimeout(TimeUnit.NANOSECONDS);
    LockResult result = tryAcquireShared(txn, nanosTimeout);
    if (!result.isHeld()) {
        throw txn.failed(LockManager.TYPE_SHARED, result, nanosTimeout);
    }
}
Also used : LockResult(org.cojen.tupl.LockResult)

Example 4 with LockResult

use of org.cojen.tupl.LockResult in project Tupl by cojen.

the class BasicRowUpdater method toFirst.

@Override
protected LockResult toFirst(Cursor c) throws IOException {
    LockResult result = c.first();
    c.register();
    return result;
}
Also used : LockResult(org.cojen.tupl.LockResult)

Example 5 with LockResult

use of org.cojen.tupl.LockResult in project Tupl by cojen.

the class AutoCommitRowUpdater method toFirst.

@Override
protected LockResult toFirst(Cursor c) throws IOException {
    LockResult result = c.first();
    c.register();
    return mLockResult = result;
}
Also used : LockResult(org.cojen.tupl.LockResult)

Aggregations

LockResult (org.cojen.tupl.LockResult)68 Cursor (org.cojen.tupl.Cursor)28 BoundedView (org.cojen.tupl.views.BoundedView)14 LockFailureException (org.cojen.tupl.LockFailureException)13 Transaction (org.cojen.tupl.Transaction)8 UnpositionedCursorException (org.cojen.tupl.UnpositionedCursorException)5 LockMode (org.cojen.tupl.LockMode)4 IOException (java.io.IOException)1 SoftReference (java.lang.ref.SoftReference)1 Combiner (org.cojen.tupl.Combiner)1 RowPredicateLock (org.cojen.tupl.core.RowPredicateLock)1 LocalPool (org.cojen.tupl.util.LocalPool)1