/** {@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; }
while (!isHeldExclusively() && !interruptAll) Thread.yield(); else if (isHeldExclusively()) { int nextc = c + acquires;
/** {@inheritDoc} */ @Override public void signal() { ctx.kernalContext().gateway().readLock(); try { if (!isHeldExclusively()) throw new IllegalMonitorStateException(); validate(false); addOutgoingSignal(name); } finally { ctx.kernalContext().gateway().readUnlock(); } }
/** {@inheritDoc} */ @Override public void await() throws IgniteInterruptedException { ctx.kernalContext().gateway().readLock(); try { if (!isHeldExclusively()) throw new IllegalMonitorStateException(); lastCondition = name; obj.await(); sync.validate(true); } catch (InterruptedException e) { throw new IgniteInterruptedException(e); } finally { ctx.kernalContext().gateway().readUnlock(); } }
/** {@inheritDoc} */ @Override public boolean awaitUntil(Date deadline) throws IgniteInterruptedException { ctx.kernalContext().gateway().readLock(); try { if (!isHeldExclusively()) throw new IllegalMonitorStateException(); lastCondition = name; boolean result = obj.awaitUntil(deadline); sync.validate(true); return result; } catch (InterruptedException e) { throw new IgniteInterruptedException(e); } finally { ctx.kernalContext().gateway().readUnlock(); } }
/** {@inheritDoc} */ @Override public boolean await(long time, TimeUnit unit) throws IgniteInterruptedException { ctx.kernalContext().gateway().readLock(); try { if (!isHeldExclusively()) throw new IllegalMonitorStateException(); lastCondition = name; boolean result = obj.await(time, unit); sync.validate(true); return result; } catch (InterruptedException e) { throw new IgniteInterruptedException(e); } finally { ctx.kernalContext().gateway().readUnlock(); } }
/** {@inheritDoc} */ @Override public long awaitNanos(long nanosTimeout) throws IgniteInterruptedException { ctx.kernalContext().gateway().readLock(); try { if (!isHeldExclusively()) throw new IllegalMonitorStateException(); lastCondition = name; long result = obj.awaitNanos(nanosTimeout); sync.validate(true); return result; } catch (InterruptedException e) { throw new IgniteInterruptedException(e); } finally { ctx.kernalContext().gateway().readUnlock(); } }
/** {@inheritDoc} */ @Override public void signalAll() { ctx.kernalContext().gateway().readLock(); try { if (!isHeldExclusively()) throw new IllegalMonitorStateException(); sync.validate(false); addOutgoingSignalAll(name); } finally { ctx.kernalContext().gateway().readUnlock(); } } }
/** {@inheritDoc} */ @Override public void awaitUninterruptibly() { ctx.kernalContext().gateway().readLock(); try { if (!isHeldExclusively()) throw new IllegalMonitorStateException(); lastCondition = name; obj.awaitUninterruptibly(); sync.validate(false); } finally { ctx.kernalContext().gateway().readUnlock(); } }
final int getHoldCount() { return isHeldExclusively() ? getState() : 0; }
/** {@inheritDoc} */ @Override public void signal() { ctx.kernalContext().gateway().readLock(); try { if (!isHeldExclusively()) throw new IllegalMonitorStateException(); validate(false); addOutgoingSignal(name); } finally { ctx.kernalContext().gateway().readUnlock(); } }
/** {@inheritDoc} */ @Override public boolean isHeldByCurrentThread() { try{ initializeReentrantLock(); return sync.isHeldExclusively(); } catch (IgniteCheckedException e) { throw U.convertException(e); } }
/** {@inheritDoc} */ @Override public long awaitNanos(long nanosTimeout) throws IgniteInterruptedException { ctx.kernalContext().gateway().readLock(); try { if (!isHeldExclusively()) throw new IllegalMonitorStateException(); lastCondition = name; long result = obj.awaitNanos(nanosTimeout); sync.validate(true); return result; } catch (InterruptedException e) { throw new IgniteInterruptedException(e); } finally { ctx.kernalContext().gateway().readUnlock(); } }
/** {@inheritDoc} */ @Override public boolean await(long time, TimeUnit unit) throws IgniteInterruptedException { ctx.kernalContext().gateway().readLock(); try { if (!isHeldExclusively()) throw new IllegalMonitorStateException(); lastCondition = name; boolean result = obj.await(time, unit); sync.validate(true); return result; } catch (InterruptedException e) { throw new IgniteInterruptedException(e); } finally { ctx.kernalContext().gateway().readUnlock(); } }
/** {@inheritDoc} */ @Override public void await() throws IgniteInterruptedException { ctx.kernalContext().gateway().readLock(); try { if (!isHeldExclusively()) throw new IllegalMonitorStateException(); lastCondition = name; obj.await(); sync.validate(true); } catch (InterruptedException e) { throw new IgniteInterruptedException(e); } finally { ctx.kernalContext().gateway().readUnlock(); } }
/** {@inheritDoc} */ @Override public boolean awaitUntil(Date deadline) throws IgniteInterruptedException { ctx.kernalContext().gateway().readLock(); try { if (!isHeldExclusively()) throw new IllegalMonitorStateException(); lastCondition = name; boolean result = obj.awaitUntil(deadline); sync.validate(true); return result; } catch (InterruptedException e) { throw new IgniteInterruptedException(e); } finally { ctx.kernalContext().gateway().readUnlock(); } }
/** {@inheritDoc} */ @Override public void awaitUninterruptibly() { ctx.kernalContext().gateway().readLock(); try { if (!isHeldExclusively()) throw new IllegalMonitorStateException(); lastCondition = name; obj.awaitUninterruptibly(); sync.validate(false); } finally { ctx.kernalContext().gateway().readUnlock(); } }
final int getHoldCount() { return isHeldExclusively() ? getState() : 0; }
/** {@inheritDoc} */ @Override public void signalAll() { ctx.kernalContext().gateway().readLock(); try { if (!isHeldExclusively()) throw new IllegalMonitorStateException(); sync.validate(false); addOutgoingSignalAll(name); } finally { ctx.kernalContext().gateway().readUnlock(); } } }
/** {@inheritDoc} */ @Override public boolean isHeldByCurrentThread() { try{ initializeReentrantLock(); return sync.isHeldExclusively(); } catch (IgniteCheckedException e) { throw U.convertException(e); } }