private <T extends Comparable<T>> boolean isLockReady(Procedure<?> proc, Queue<T> rq) { LockStatus s = rq.getLockStatus(); // if we have the lock access, we are ready if (s.hasLockAccess(proc)) { return true; } boolean xlockReq = rq.requireExclusiveLock(proc); // if we need to hold the xlock, then we need to make sure that no one holds any lock, including // the shared lock, otherwise, we just need to make sure that no one holds the xlock return xlockReq ? !s.isLocked() : !s.hasExclusiveLock(); }