/** * Get the flag indicating whether there are threads waiting on this lock. */ protected final boolean hasWaiters() { return (getState() & HAS_WAITERS) != 0; }
protected StringBuilder appendFieldsToString(final StringBuilder sb) { return sb.append("lockState=0x").append(Integer.toHexString(getState())); } }
/** * Set the flag indicating that there are threads waiting on this lock. */ protected final void setHasWaiters() { setFlag(getState(), HAS_WAITERS); }
/** * Clear the flag indicating that there are no more threads waiting on this * lock. */ protected final void clearHasWaiters() { clearFlag(getState(), HAS_WAITERS); }
/** Return the number of active read-only locks on this object. */ public final int numReadOnlyLocks() { return readOnlyCount(getState()); }
/** Return the number of active shared locks on this object. */ public final int numSharedLocks() { return readSharedCount(getState()); }
/** set the given bit mask in the lock state */ protected final void setFlag(int currentState, final int flag) { InternalDistributedSystem sys = null; for (;;) { if (compareAndSetState(currentState, (currentState | flag))) { return; } // check if DS is disconnecting if (sys == null) { sys = getDistributedSystem(); } sys.getCancelCriterion().checkCancelInProgress(null); currentState = getState(); } }
/** clear the given bit mask from the lock state */ protected final void clearFlag(int currentState, final int flag) { InternalDistributedSystem sys = null; for (;;) { if (compareAndSetState(currentState, (currentState & ~flag))) { return; } // check if DS is disconnecting if (sys == null) { sys = getDistributedSystem(); } sys.getCancelCriterion().checkCancelInProgress(null); currentState = getState(); } }
Object currentOwnerId = null; for (;;) { final int currentState = getState(); final int newState; switch (mode) {
final Object context) { for (;;) { final int currentState = getState(); if (currentState == 0) { if (compareAndSetState(0, WRITE_ONE | WRITE_EXCLUSIVE_BIT)) {
final int lockMode = (lockModeArg & MODE_MASK); for (;;) { final int currentState = getState(); final int currentReadHolds; final int currentReadOnlyHolds;
final Object ownerId, final Object context) { final int requestedLockMode = (lockModeArg & MODE_MASK); final int currentState = getState(); final int currentReadOnlyHolds; final int currentWriteHolds;