|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sun.sgs.impl.util.lock.LockManager<K>
com.sun.sgs.impl.util.lock.MultiLockManager<K>
K - the type of keypublic final class MultiLockManager<K>
A class for managing lock conflicts where locks are not held by transactions
and the locker can make simultaneous requests from multiple threads. This
class does not detect deadlocks, but provides support for downgrading locks. All Locker objects supplied to
this class should be instances of MultiLocker.
This class and its superclass use the Logger named com.sun.sgs.impl.util.lock to log information at the
following logging levels:
FINER - Releasing locks; requesting, waiting for,
and returning from lock requests
FINEST - Notifying new lock owners, results of
requesting locks before waiting, releasing locks, results of attempting
to assign locks to waiters
| Field Summary |
|---|
| Fields inherited from class com.sun.sgs.impl.util.lock.LockManager |
|---|
currentKeySync, currentLockerSync, logger |
| Constructor Summary | |
|---|---|
MultiLockManager(long lockTimeout,
int numKeyMaps)
Creates an instance of this class. |
|
| Method Summary | |
|---|---|
void |
downgradeLock(Locker<K> locker,
K key)
Downgrades a lock held by a locker from write to read access. |
(package private) LockAttemptResult<K> |
getWaitingFor()
Checks if this thread is waiting for a lock. |
LockConflict<K> |
lock(Locker<K> locker,
K key,
boolean forWrite)
Attempts to acquire a lock, waiting if needed. |
LockConflict<K> |
lockNoWait(Locker<K> locker,
K key,
boolean forWrite)
Attempts to acquire a lock, returning immediately. |
(package private) void |
setWaitingFor(LockAttemptResult<K> waitingFor)
Records the lock that this thread is waiting for, or marks that it is not waiting if the argument is null. |
LockConflict<K> |
waitForLock(Locker<K> locker)
Waits for a previous attempt to obtain a lock that blocked. |
| Methods inherited from class com.sun.sgs.impl.util.lock.LockManager |
|---|
getKeyMap, getLock, getOwners, getWaiters, lockNoWaitInternal, releaseLock, releaseLockInternal, waitForLockInternal |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public MultiLockManager(long lockTimeout,
int numKeyMaps)
lockTimeout - the maximum number of milliseconds to acquire a
locknumKeyMaps - the number of separate maps to use for storing keys
IllegalArgumentException - if lockTimeout or numKeyMaps is less than 1| Method Detail |
|---|
public LockConflict<K> lock(Locker<K> locker,
K key,
boolean forWrite)
null if the lock
was acquired. If the type field of the return value is DEADLOCK, then the caller should abort the
transaction, and any subsequent lock or wait requests will throw IllegalStateException. Otherwise, the caller can repeat this call, and
any conflicts from earlier calls will be ignored.
lock in class LockManager<K>locker - the locker requesting the lockkey - the key identifying the lockforWrite - whether to request a write lock
null if there was no
conflict
IllegalArgumentException - if locker has a different lock
manager, or if locker is
not an instance of MultiLocker
public LockConflict<K> lockNoWait(Locker<K> locker,
K key,
boolean forWrite)
null if the lock was acquired. If the attempt to
acquire the lock was blocked, returns a value with a type field
of BLOCKED rather than waiting. If the
type field of the return value is DEADLOCK, then the caller should abort the
transaction, and any subsequent lock or wait requests will throw IllegalStateException. Otherwise, the caller can repeat this call, and
any conflicts from earlier calls will be ignored.
lockNoWait in class LockManager<K>locker - the locker requesting the lockkey - the key identifying the lockforWrite - whether to request a write lock
null if there was no
conflict
IllegalArgumentException - if locker has a different lock
manager, or if locker is
not an instance of MultiLockerpublic LockConflict<K> waitForLock(Locker<K> locker)
null if the lock was acquired or the
transaction was not waiting. If the type field of the return
value is DEADLOCK, then the caller
should abort the transaction, and any subsequent lock or wait requests
will throw IllegalStateException.
waitForLock in class LockManager<K>locker - the locker requesting the lock
null if there was no
conflict
IllegalArgumentException - if locker has a different lock
manager, or if locker is
not an instance of MultiLocker
public void downgradeLock(Locker<K> locker,
K key)
locker - the locker holding the lockkey - the key identifying the lock
IllegalArgumentException - if locker has a different lock
manager, or if locker is not an instance of MultiLockerLockAttemptResult<K> getWaitingFor()
null if it is not waitingvoid setWaitingFor(LockAttemptResult<K> waitingFor)
null.
waitingFor - the lock or null
|
RedDwarf, Version 0.10.1 2010-03-14 10:56:12 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||