protected synchronized WaitQueue.WaitNode getSignallee(Thread caller) { if (caller != owner_) throw new IllegalMonitorStateException("Not owner"); // assert (holds_ > 0) if (holds_ >= 2) { // current thread will keep the lock --holds_; return null; } // assert (holds_ == 1) WaitQueue.WaitNode w = wq_.extract(); if (w == null) { // if none, clear for new arrivals owner_ = null; holds_ = 0; } return w; }
protected synchronized WaitQueue.WaitNode getSignallee(Thread caller) { if (caller != owner_) throw new IllegalMonitorStateException("Not owner"); // assert (holds_ > 0) if (holds_ >= 2) { // current thread will keep the lock --holds_; return null; } // assert (holds_ == 1) WaitQueue.WaitNode w = wq_.extract(); if (w == null) { // if none, clear for new arrivals owner_ = null; holds_ = 0; } return w; }
protected synchronized WaitQueue.WaitNode getSignallee(Thread caller) { if (caller != owner_) throw new IllegalMonitorStateException("Not owner"); // assert (holds_ > 0) if (holds_ >= 2) { // current thread will keep the lock --holds_; return null; } // assert (holds_ == 1) WaitQueue.WaitNode w = wq_.extract(); if (w == null) { // if none, clear for new arrivals owner_ = null; holds_ = 0; } return w; }
protected synchronized Node getSignallee(int n) { Node w = (Node)wq_.extract(); permits_ += n; if (w == null) { return null; } else if (w.requests > permits_) { // not enough permits released for the "next in line" wq_.putBack(w); return null; } else { permits_ -= w.requests; return w; } }
protected synchronized Node getSignallee(int n) { Node w = (Node)wq_.extract(); permits_ += n; if (w == null) { return null; } else if (w.requests > permits_) { // not enough permits released for the "next in line" wq_.putBack(w); return null; } else { permits_ -= w.requests; return w; } }
protected synchronized Node getSignallee(int n) { Node w = (Node)wq_.extract(); permits_ += n; if (w == null) { return null; } else if (w.requests > permits_) { // not enough permits released for the "next in line" wq_.putBack(w); return null; } else { permits_ -= w.requests; return w; } }
public void signal() { if (!lock.isHeldByCurrentThread()) { throw new IllegalMonitorStateException(); } for (;;) { WaitQueue.WaitNode w = wq.extract(); if (w == null) return; // no one to signal if (w.signal(sync)) return; // notify if still waiting, else skip } }
public void signalAll() { if (!lock.isHeldByCurrentThread()) { throw new IllegalMonitorStateException(); } for (;;) { WaitQueue.WaitNode w = wq.extract(); if (w == null) return; // no more to signal w.signal(sync); } }
public void signal() { if (!lock.isHeldByCurrentThread()) { throw new IllegalMonitorStateException(); } for (;;) { WaitQueue.WaitNode w = wq.extract(); if (w == null) return; // no one to signal if (w.signal(sync)) return; // notify if still waiting, else skip } }
public void signal() { if (!lock.isHeldByCurrentThread()) { throw new IllegalMonitorStateException(); } for (;;) { WaitQueue.WaitNode w = wq.extract(); if (w == null) return; // no one to signal if (w.signal(sync)) return; // notify if still waiting, else skip } }
public void signalAll() { if (!lock.isHeldByCurrentThread()) { throw new IllegalMonitorStateException(); } for (;;) { WaitQueue.WaitNode w = wq.extract(); if (w == null) return; // no more to signal w.signal(sync); } }
public void signalAll() { if (!lock.isHeldByCurrentThread()) { throw new IllegalMonitorStateException(); } for (;;) { WaitQueue.WaitNode w = wq.extract(); if (w == null) return; // no more to signal w.signal(sync); } }