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 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 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 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 boolean attempt(int n, long nanos) throws InterruptedException { if (Thread.interrupted()) throw new InterruptedException(); if (precheck(n)) return true; if (nanos <= 0) return false; WaitQueue.WaitNode w = new Node(n); return w.doTimedWait(this, nanos); }
public boolean attempt(int n, long nanos) throws InterruptedException { if (Thread.interrupted()) throw new InterruptedException(); if (precheck(n)) return true; if (nanos <= 0) return false; WaitQueue.WaitNode w = new Node(n); return w.doTimedWait(this, nanos); }
public boolean attempt(int n, long nanos) throws InterruptedException { if (Thread.interrupted()) throw new InterruptedException(); if (precheck(n)) return true; if (nanos <= 0) return false; WaitQueue.WaitNode w = new Node(n); return w.doTimedWait(this, nanos); }