Class InversibleLock
- 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 toStampedLock
. In case a read is contented with a write, the read side will throw anInversibleLockException
, which the caller can catch and use to wait for the write to resolve.- Author:
- Robert Varga
-
-
Constructor Summary
Constructors Constructor Description InversibleLock()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
optimisticRead()
Return a stamp for read validation.void
unlockWrite(long stamp)
boolean
validate(long stamp)
long
writeLock()
-
-
-
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)
-
-