Class InversibleLock


  • @Beta
    public final class InversibleLock
    extends Object
    A lock implementation which allows users to perform optimistic reads and validate them in a fashion similar to StampedLock. In case a read is contented with a write, the read side will throw an InversibleLockException, which the caller can catch and use to wait for the write to resolve.
    Author:
    Robert Varga
    • Constructor Detail

      • InversibleLock

        public InversibleLock()
    • Method Detail

      • optimisticRead

        public long optimisticRead()
        Return a stamp for read validation.
        Returns:
        A stamp, which can be used with validate(long).
        Throws:
        InversibleLockException - if this lock is currently write-locked
      • validate

        public boolean validate​(long stamp)
      • writeLock

        public long writeLock()
      • unlockWrite

        public void unlockWrite​(long stamp)