public void lockInterruptibly() throws InterruptedException { if (Thread.interrupted()) throw new InterruptedException(); Thread caller = Thread.currentThread(); synchronized (this) { if (owner_ == null) { owner_ = caller; holds_ = 1; return; } else if (caller == owner_) { incHolds(); return; } } WaitQueue.WaitNode n = new WaitQueue.WaitNode(); n.doWait(this); }
public boolean tryLock(long nanos) throws InterruptedException { if (Thread.interrupted()) throw new InterruptedException(); Thread caller = Thread.currentThread(); synchronized (this) { if (owner_ == null) { owner_ = caller; holds_ = 1; return true; } else if (caller == owner_) { incHolds(); return true; } } WaitQueue.WaitNode n = new WaitQueue.WaitNode(); return n.doTimedWait(this, nanos); }
public void unlock() { Thread caller = Thread.currentThread(); for (;;) { WaitQueue.WaitNode w = getSignallee(caller); if (w == null) return; // no one to signal if (w.signal(this)) return; // notify if still waiting, else skip } }
public boolean await(long timeout, TimeUnit unit) throws InterruptedException { int holdCount = lock.getHoldCount(); if (holdCount == 0) { throw new IllegalMonitorStateException(); } if (Thread.interrupted()) throw new InterruptedException(); long nanos = unit.toNanos(timeout); WaitQueue.WaitNode n = new WaitQueue.WaitNode(); wq.insert(n); boolean success = false; for (int i=holdCount; i>0; i--) lock.unlock(); try { success = n.doTimedWait(sync, nanos); } finally { for (int i=holdCount; i>0; i--) lock.lock(); } return success; }
public boolean await(long timeout, TimeUnit unit) throws InterruptedException { int holdCount = lock.getHoldCount(); if (holdCount == 0) { throw new IllegalMonitorStateException(); } if (Thread.interrupted()) throw new InterruptedException(); long nanos = unit.toNanos(timeout); WaitQueue.WaitNode n = new WaitQueue.WaitNode(); wq.insert(n); boolean success = false; for (int i=holdCount; i>0; i--) lock.unlock(); try { success = n.doTimedWait(sync, nanos); } finally { for (int i=holdCount; i>0; i--) lock.lock(); } return success; }
public void lockInterruptibly() throws InterruptedException { if (Thread.interrupted()) throw new InterruptedException(); Thread caller = Thread.currentThread(); synchronized (this) { if (owner_ == null) { owner_ = caller; holds_ = 1; return; } else if (caller == owner_) { incHolds(); return; } } WaitQueue.WaitNode n = new WaitQueue.WaitNode(); n.doWait(this); }
public boolean tryLock(long nanos) throws InterruptedException { if (Thread.interrupted()) throw new InterruptedException(); Thread caller = Thread.currentThread(); synchronized (this) { if (owner_ == null) { owner_ = caller; holds_ = 1; return true; } else if (caller == owner_) { incHolds(); return true; } } WaitQueue.WaitNode n = new WaitQueue.WaitNode(); return n.doTimedWait(this, nanos); }
public boolean await(long timeout, TimeUnit unit) throws InterruptedException { int holdCount = lock.getHoldCount(); if (holdCount == 0) { throw new IllegalMonitorStateException(); } if (Thread.interrupted()) throw new InterruptedException(); long nanos = unit.toNanos(timeout); WaitQueue.WaitNode n = new WaitQueue.WaitNode(); wq.insert(n); boolean success = false; for (int i=holdCount; i>0; i--) lock.unlock(); try { success = n.doTimedWait(sync, nanos); } finally { for (int i=holdCount; i>0; i--) lock.lock(); } return success; }
public void await() throws InterruptedException { int holdCount = lock.getHoldCount(); if (holdCount == 0) { throw new IllegalMonitorStateException(); } if (Thread.interrupted()) throw new InterruptedException(); WaitQueue.WaitNode n = new WaitQueue.WaitNode(); wq.insert(n); for (int i=holdCount; i>0; i--) lock.unlock(); try { n.doWait(sync); } finally { for (int i=holdCount; i>0; i--) lock.lock(); } }
public void lock() { Thread caller = Thread.currentThread(); synchronized (this) { if (owner_ == null) { owner_ = caller; holds_ = 1; return; } else if (caller == owner_) { incHolds(); return; } } WaitQueue.WaitNode n = new WaitQueue.WaitNode(); n.doWaitUninterruptibly(this); }
public void lock() { Thread caller = Thread.currentThread(); synchronized (this) { if (owner_ == null) { owner_ = caller; holds_ = 1; return; } else if (caller == owner_) { incHolds(); return; } } WaitQueue.WaitNode n = new WaitQueue.WaitNode(); n.doWaitUninterruptibly(this); }
public void lockInterruptibly() throws InterruptedException { if (Thread.interrupted()) throw new InterruptedException(); Thread caller = Thread.currentThread(); synchronized (this) { if (owner_ == null) { owner_ = caller; holds_ = 1; return; } else if (caller == owner_) { incHolds(); return; } } WaitQueue.WaitNode n = new WaitQueue.WaitNode(); n.doWait(this); }
public boolean tryLock(long nanos) throws InterruptedException { if (Thread.interrupted()) throw new InterruptedException(); Thread caller = Thread.currentThread(); synchronized (this) { if (owner_ == null) { owner_ = caller; holds_ = 1; return true; } else if (caller == owner_) { incHolds(); return true; } } WaitQueue.WaitNode n = new WaitQueue.WaitNode(); return n.doTimedWait(this, nanos); }
public void lock() { Thread caller = Thread.currentThread(); synchronized (this) { if (owner_ == null) { owner_ = caller; holds_ = 1; return; } else if (caller == owner_) { incHolds(); return; } } WaitQueue.WaitNode n = new WaitQueue.WaitNode(); n.doWaitUninterruptibly(this); }
public void await() throws InterruptedException { int holdCount = lock.getHoldCount(); if (holdCount == 0) { throw new IllegalMonitorStateException(); } if (Thread.interrupted()) throw new InterruptedException(); WaitQueue.WaitNode n = new WaitQueue.WaitNode(); wq.insert(n); for (int i=holdCount; i>0; i--) lock.unlock(); try { n.doWait(sync); } finally { for (int i=holdCount; i>0; i--) lock.lock(); } }
public void awaitUninterruptibly() { int holdCount = lock.getHoldCount(); if (holdCount == 0) { throw new IllegalMonitorStateException(); } WaitQueue.WaitNode n = new WaitQueue.WaitNode(); wq.insert(n); for (int i=holdCount; i>0; i--) lock.unlock(); try { n.doWaitUninterruptibly(sync); } finally { for (int i=holdCount; i>0; i--) lock.lock(); } }
public void await() throws InterruptedException { int holdCount = lock.getHoldCount(); if (holdCount == 0) { throw new IllegalMonitorStateException(); } if (Thread.interrupted()) throw new InterruptedException(); WaitQueue.WaitNode n = new WaitQueue.WaitNode(); wq.insert(n); for (int i=holdCount; i>0; i--) lock.unlock(); try { n.doWait(sync); } finally { for (int i=holdCount; i>0; i--) lock.lock(); } }
public void awaitUninterruptibly() { int holdCount = lock.getHoldCount(); if (holdCount == 0) { throw new IllegalMonitorStateException(); } WaitQueue.WaitNode n = new WaitQueue.WaitNode(); wq.insert(n); for (int i=holdCount; i>0; i--) lock.unlock(); try { n.doWaitUninterruptibly(sync); } finally { for (int i=holdCount; i>0; i--) lock.lock(); } }
public void awaitUninterruptibly() { int holdCount = lock.getHoldCount(); if (holdCount == 0) { throw new IllegalMonitorStateException(); } WaitQueue.WaitNode n = new WaitQueue.WaitNode(); wq.insert(n); for (int i=holdCount; i>0; i--) lock.unlock(); try { n.doWaitUninterruptibly(sync); } finally { for (int i=holdCount; i>0; i--) lock.lock(); } }
public synchronized void takeOver(WaitQueue.WaitNode node) { // assert (holds_ == 1 && owner_ == Thread.currentThread() owner_ = node.getOwner(); }