/** * @param state State. */ protected Sync(GridCacheLockState state) { setState(state.get()); thisNode = ctx.localNodeId(); currentOwnerNode = state.getId(); currentOwnerThreadId = state.getThreadId(); conditionMap = new HashMap<>(); outgoingSignals = new HashMap<>(); failoverSafe = state.isFailoverSafe(); fair = state.isFair(); waitingThreads = new ConcurrentSkipListSet<>(); }
/** {@inheritDoc} */ @Override protected final boolean tryRelease(int releases) { // This method is called with release==0 only when trying to wake through update, // to check if some other node released the lock. if (releases == 0) return true; // If broken in non-failoversafe mode, exit immediately. if (interruptAll) return true; int c = getState() - releases; if (!isHeldExclusively()) { log.error("Lock.unlock() is called in illegal state [callerNodeId=" + thisNode + ", ownerNodeId=" + currentOwnerNode + ", callerThreadId=" + Thread.currentThread().getId() + ", ownerThreadId=" + currentOwnerThreadId + ", lockState=" + getState() + "]"); throw new IllegalMonitorStateException(); } boolean free = false; if (c == 0) { free = true; setGlobalState(0, processAwait(), processSignal()); while (isHeldExclusively() && !interruptAll) Thread.yield(); } else setState(c); return free; }
throw new Error("Maximum lock count exceeded."); setState(nextc);
throw new Error("Maximum lock count exceeded."); setState(nextc);
/** {@inheritDoc} */ @Override protected final boolean tryRelease(int releases) { // This method is called with release==0 only when trying to wake through update, // to check if some other node released the lock. if (releases == 0) return true; // If broken in non-failoversafe mode, exit immediately. if (interruptAll) return true; int c = getState() - releases; if (!isHeldExclusively()) { log.error("Lock.unlock() is called in illegal state [callerNodeId=" + thisNode + ", ownerNodeId=" + currentOwnerNode + ", callerThreadId=" + Thread.currentThread().getId() + ", ownerThreadId=" + currentOwnerThreadId + ", lockState=" + getState() + "]"); throw new IllegalMonitorStateException(); } boolean free = false; if (c == 0) { free = true; setGlobalState(0, processAwait(), processSignal()); while (isHeldExclusively() && !interruptAll) Thread.yield(); } else setState(c); return free; }
/** * @param state State. */ protected Sync(GridCacheLockState state) { setState(state.get()); thisNode = ctx.localNodeId(); currentOwnerNode = state.getId(); currentOwnerThreadId = state.getThreadId(); conditionMap = new HashMap<>(); outgoingSignals = new HashMap<>(); failoverSafe = state.isFailoverSafe(); fair = state.isFair(); waitingThreads = new ConcurrentSkipListSet<>(); }
/** * Sets the number of permits currently acquired on this lock. This method should only be used in {@linkplain * GridCacheLockImpl#onUpdate(GridCacheLockState)}. * * @param permits Number of permits acquired at this reentrant lock. */ final synchronized void setPermits(int permits) { setState(permits); }
/** * Sets the number of permits currently acquired on this lock. This method should only be used in {@linkplain * GridCacheLockImpl#onUpdate(GridCacheLockState)}. * * @param permits Number of permits acquired at this reentrant lock. */ final synchronized void setPermits(int permits) { setState(permits); }