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;
}
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;
}
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);
}
}
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;
}
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;
}
Aggregations