public class OptimisticLockStamped extends Object implements OptimisticLock
StampedLock
Constructor and Description |
---|
OptimisticLockStamped() |
Modifier and Type | Method and Description |
---|---|
boolean |
canCheckHolder()
True if this lock supports
OptimisticLock.isHoldingWriteLock() |
boolean |
isHoldingWriteLock()
Checks whether current thread is holding the write lock.
|
long |
readLock()
Non-exclusively acquires the lock, blocking if necessary
until available.
|
long |
tryOptimisticRead()
Returns a stamp that can later be validated, or zero
if exclusively locked.
|
void |
unlockRead(long stamp)
If the lock state matches the given stamp, releases the
non-exclusive lock.
|
void |
unlockWrite(long stamp)
If the lock state matches the given stamp, releases the
exclusive lock.
|
boolean |
validate(long stamp)
Returns true if the lock has not been exclusively acquired
since issuance of the given stamp.
|
long |
writeLock()
Exclusively acquires the lock, blocking if necessary
until available.
|
public long readLock()
OptimisticLock
readLock
in interface OptimisticLock
public long writeLock()
OptimisticLock
writeLock
in interface OptimisticLock
public long tryOptimisticRead()
OptimisticLock
OptimisticLock.unlockWrite(long)
become visible.tryOptimisticRead
in interface OptimisticLock
public boolean validate(long stamp)
OptimisticLock
OptimisticLock.tryOptimisticRead()
or a locking method
for this lock has no defined effect or result.validate
in interface OptimisticLock
stamp
- a stamptrue
if the lock has not been exclusively acquired
since issuance of the given stamp; else falsepublic void unlockRead(long stamp)
OptimisticLock
unlockRead
in interface OptimisticLock
stamp
- a stamp returned by a read-lock operationpublic void unlockWrite(long stamp)
OptimisticLock
unlockWrite
in interface OptimisticLock
stamp
- a stamp returned by a write-lock operationpublic boolean canCheckHolder()
OptimisticLock
OptimisticLock.isHoldingWriteLock()
canCheckHolder
in interface OptimisticLock
public boolean isHoldingWriteLock()
OptimisticLock
isHoldingWriteLock
in interface OptimisticLock
cache2k API documentation. Copyright © 2000–2018 headissue GmbH, Munich.