org.multiverse.api.commitlock
Interface CommitLock


public interface CommitLock

The CommitLock should never by acquired directly, but always through the CommitLockPolicy. The implementation of the lock are not supposed to use techniques like spinning, that should all be part of the lockpolicy. The lock implementation should try to acquire the lock and fail immediately if it can't.

An element in a LockSet (an array of LockSetElements).

A null array is equal to an array of length 0. items are always placed from the left to the right. as soon as a null element is found, the items on the right don't need to be tried.

It could be that after a null element, there still are junk objects from the past.

Author:
Peter Veentjer.

Method Summary
 Transaction ___getLockOwner()
          Returns the current owner of the lock, or null if not locked.
 void ___releaseLock(Transaction expectedLockOwner)
          Releases the lock under the condition that it was owned by the expectedLockOwner.
 boolean ___tryLock(Transaction lockOwner)
          Tries to acquire the lock.
 

Method Detail

___getLockOwner

Transaction ___getLockOwner()
Returns the current owner of the lock, or null if not locked.

Returns:
the current owner, or null if lock is free.

___tryLock

boolean ___tryLock(Transaction lockOwner)
Tries to acquire the lock.

CommitLocks are not reentrant.

Parameters:
lockOwner - the Transaction that wants to own the lock.
Returns:
true if the lock was acquired, false otherwise.

___releaseLock

void ___releaseLock(Transaction expectedLockOwner)
Releases the lock under the condition that it was owned by the expectedLockOwner. If a different Transaction owns, the lock, the lock should not be released.

It is very important that this method doesn't fail because when it does it could leave locks locked.

Parameters:
expectedLockOwner - the expected Transaction that owns the lock.


Copyright © 2008-2010 Multiverse. All Rights Reserved.