Class SequenceLock

  • All Implemented Interfaces:
    OptimisticLock

    public class SequenceLock
    extends Object
    implements OptimisticLock
    http://www.hpl.hp.com/techreports/2012/HPL-2012-68.pdf Created by jcairns on 2/12/16.
    • Constructor Detail

      • SequenceLock

        public SequenceLock()
    • Method Detail

      • readLock

        public long readLock()
        Description copied from interface: OptimisticLock
        Aquire a lock token for reading
        Specified by:
        readLock in interface OptimisticLock
        Returns:
        long - the token indicating the lock state
      • readLockHeld

        public boolean readLockHeld​(long lockToken)
        Description copied from interface: OptimisticLock
        check if optimistic locking succeeded
        Specified by:
        readLockHeld in interface OptimisticLock
        Parameters:
        lockToken - - the value returned from tryLock
        Returns:
        boolean - true if lock was held
      • writeLock

        public long writeLock()
        Description copied from interface: OptimisticLock
        Acquire the lock for writing, waiting if needed
        Specified by:
        writeLock in interface OptimisticLock
        Returns:
        long - the token indicating the lock state
      • unlock

        public void unlock​(long sequence)
        Description copied from interface: OptimisticLock
        "commit" or unlock the sequence when the write lock is held
        Specified by:
        unlock in interface OptimisticLock
        Parameters:
        sequence - - lock sequence to unlock
      • tryWriteLock

        public long tryWriteLock()
        Specified by:
        tryWriteLock in interface OptimisticLock
        Returns:
        long - the token indicating the lock state, or 0 if not available