@InterfaceAudience.Private public class LockAndQueue extends ProcedureDeque implements LockStatus
LockAndQueue has two purposes:
LockAndQueue extends ProcedureDeque class. Blocked Procedures are added
to our super Deque. Using inheritance over composition to keep the Deque of waiting
Procedures is unusual, but we do it this way because in certain cases, there will be
millions of regions. This layout uses less memory.
NOT thread-safe. Needs external concurrency control: e.g. uses in MasterProcedureScheduler are
guarded by schedLock().
There is no need of 'volatile' keyword for member variables because of memory synchronization
guarantees of locks (see 'Memory Synchronization',
http://docs.oracle.com/javase/8/docs/api/java/util/concurrent/locks/Lock.html)
We do not implement Lock interface because we need exclusive and shared locking, and also
because try-lock functions require procedure id.
We do not use ReentrantReadWriteLock directly because of its high memory overhead.
| Constructor and Description |
|---|
LockAndQueue() |
| Modifier and Type | Method and Description |
|---|---|
Procedure<?> |
getExclusiveLockOwnerProcedure() |
long |
getExclusiveLockProcIdOwner() |
int |
getSharedLockCount() |
boolean |
hasExclusiveLock() |
boolean |
hasLockAccess(Procedure proc) |
boolean |
hasParentLock(Procedure proc) |
boolean |
isLocked() |
boolean |
isLockOwner(long procId) |
boolean |
releaseExclusiveLock(Procedure proc) |
boolean |
releaseSharedLock() |
String |
toString() |
boolean |
tryExclusiveLock(Procedure proc) |
boolean |
trySharedLock() |
add, addFirst, addLast, clear, clone, contains, descendingIterator, element, getFirst, getLast, isEmpty, iterator, offer, offerFirst, offerLast, peek, peekFirst, peekLast, poll, pollFirst, pollLast, pop, push, remove, remove, removeFirst, removeFirstOccurrence, removeLast, removeLastOccurrence, size, spliterator, toArray, toArrayaddAll, containsAll, removeAll, retainAllequals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitaddAll, containsAll, equals, hashCode, parallelStream, removeAll, removeIf, retainAll, streampublic boolean isLocked()
isLocked in interface LockStatuspublic boolean hasExclusiveLock()
hasExclusiveLock in interface LockStatuspublic boolean isLockOwner(long procId)
isLockOwner in interface LockStatuspublic boolean hasParentLock(Procedure proc)
hasParentLock in interface LockStatuspublic boolean hasLockAccess(Procedure proc)
hasLockAccess in interface LockStatuspublic Procedure<?> getExclusiveLockOwnerProcedure()
getExclusiveLockOwnerProcedure in interface LockStatuspublic long getExclusiveLockProcIdOwner()
getExclusiveLockProcIdOwner in interface LockStatuspublic int getSharedLockCount()
getSharedLockCount in interface LockStatuspublic boolean trySharedLock()
public boolean releaseSharedLock()
public boolean tryExclusiveLock(Procedure proc)
public boolean releaseExclusiveLock(Procedure proc)
public String toString()
toString in class AbstractCollection<Procedure>Copyright © 2007–2018 The Apache Software Foundation. All rights reserved.