java.lang.Object
org.opendaylight.controller.cluster.access.client.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 Details

    • InversibleLock

      public InversibleLock()
  • Method Details

    • 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)