Class InversibleLock
java.lang.Object
org.opendaylight.controller.cluster.access.client.InversibleLock
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlong
Return a stamp for read validation.void
unlockWrite
(long stamp) boolean
validate
(long stamp) long
-
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)
-