public class LocalLockMediator<T> extends Object
| Constructor and Description |
|---|
LocalLockMediator(String name,
TimestampProvider times) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
lock(KeyColumn kc,
T requestor,
java.time.Instant expires)
Acquire the lock specified by
kc. |
String |
toString() |
boolean |
unlock(KeyColumn kc,
T requestor)
Release the lock specified by
kc and which was previously
locked by requestor, if it is possible to release it. |
public LocalLockMediator(String name, TimestampProvider times)
public boolean lock(KeyColumn kc, T requestor, java.time.Instant expires)
kc.
For any particular key-column, whatever value of requestor is
passed to this method must also be passed to the associated later call to
#unlock(KeyColumn, ExpectedValueCheckingTransaction).
If some requestor r calls this method on a KeyColumn k
and this method returns true, then subsequent calls to this method by
r on l merely attempt to update the expiresAt
timestamp. This differs from typical lock reentrance: multiple successful
calls to this method do not require an equal number of calls to
#unlock(). One #unlock() call is enough, no matter how
many times a requestor called lock beforehand. Note that
updating the timestamp may fail, in which case the lock is considered to
have expired and the calling context should assume it no longer holds the
lock specified by kc.
The current implementation of this method returns true when given an
expiresAt argument in the past. Future implementations may return
false instead.kc - lock identifierrequestor - the object locking kcexpires - instant at which this lock will automatically expirepublic boolean unlock(KeyColumn kc, T requestor)
kc and which was previously
locked by requestor, if it is possible to release it.kc - lock identifierrequestor - the object which previously locked kcCopyright © 2012–2015. All rights reserved.