LockType - the type of locks used by this targetpublic class Target<LockType> extends Object
LockPolicy present in the LockManager.| Constructor and Description |
|---|
Target(LockManager<LockType> lm)
Creates a new target.
|
Target(Target<LockType> parent)
Creates a new target, child of an existing parent.
|
| Modifier and Type | Method and Description |
|---|---|
Set<Target<LockType>> |
children()
Obtains the set of all children (non-recursive) of this target.
|
LockGrantFuture<LockType> |
lock(LockRequest<LockType> request)
Requests an asynchronous lock of this target.
|
Target<LockType> |
parent()
Obtains the parent of this target.
|
void |
parent(Target<LockType> p)
Sets the parent target of this target.
|
void |
unlock(LockGrant<LockType> g)
Unlocks a target, which must have been previously locked.
|
public Target(LockManager<LockType> lm)
lm - the target's lock managerpublic void parent(Target<LockType> p)
p - the parent target or null if this target should
not have a parentCyclicTargetHierarchyException - setting the parent as
p would yield a cyclepublic Target<LockType> parent()
null if nonepublic Set<Target<LockType>> children()
public LockGrantFuture<LockType> lock(LockRequest<LockType> request)
Requests an asynchronous lock of this target. This method will return
immediately. The LockGrantFuture.get() method (or its timed
variant) may be used to wait for the lock to be acquired.
This method will create a chain starting from the top of the hierarchy of this target up to this target.
request - the lock request which may not be already acquiredpublic void unlock(LockGrant<LockType> g)
g - the lock grantNotLockedException - the lock is not locked or was unlocked
concurrently during execution of this operationCopyright © 2015. All rights reserved.