@InterfaceAudience.Private public class LockAndQueue extends Object 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.
Modifier and Type | Field and Description |
---|---|
private Procedure<?> |
exclusiveLockOwnerProcedure |
private Function<Long,Procedure<?>> |
procedureRetriever |
private ProcedureDeque |
queue |
private int |
sharedLock |
Constructor and Description |
---|
LockAndQueue(Function<Long,Procedure<?>> procedureRetriever) |
Modifier and Type | Method and Description |
---|---|
void |
addLast(Procedure<?> proc) |
Stream<Procedure> |
filterWaitingQueue(Predicate<Procedure> predicate) |
Procedure<?> |
getExclusiveLockOwnerProcedure()
Get the procedure which holds the exclusive lock.
|
int |
getSharedLockCount()
Get the number of procedures which hold the shared lock.
|
boolean |
hasExclusiveLock()
Whether the exclusive lock has been held.
|
boolean |
hasLockAccess(Procedure<?> proc)
Return true if the procedure itself holds the exclusive lock, or any ancestors of the give
procedure hold the exclusive lock.
|
boolean |
isWaitingQueueEmpty() |
boolean |
releaseExclusiveLock(Procedure<?> proc) |
boolean |
releaseSharedLock() |
Procedure<?> |
removeFirst() |
String |
toString() |
boolean |
tryExclusiveLock(Procedure<?> proc) |
boolean |
trySharedLock(Procedure<?> proc) |
int |
wakeWaitingProcedures(ProcedureScheduler scheduler) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getExclusiveLockProcIdOwner, isLocked
private final Function<Long,Procedure<?>> procedureRetriever
private final ProcedureDeque queue
private Procedure<?> exclusiveLockOwnerProcedure
private int sharedLock
public LockAndQueue(Function<Long,Procedure<?>> procedureRetriever)
public boolean hasExclusiveLock()
LockStatus
hasExclusiveLock
in interface LockStatus
public boolean hasLockAccess(Procedure<?> proc)
LockStatus
hasLockAccess
in interface LockStatus
public Procedure<?> getExclusiveLockOwnerProcedure()
LockStatus
getExclusiveLockOwnerProcedure
in interface LockStatus
public int getSharedLockCount()
LockStatus
getSharedLockCount
in interface LockStatus
public boolean trySharedLock(Procedure<?> proc)
public boolean releaseSharedLock()
public boolean tryExclusiveLock(Procedure<?> proc)
public boolean releaseExclusiveLock(Procedure<?> proc)
public boolean isWaitingQueueEmpty()
public Procedure<?> removeFirst()
public int wakeWaitingProcedures(ProcedureScheduler scheduler)
public Stream<Procedure> filterWaitingQueue(Predicate<Procedure> predicate)
Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.