public Object poll() { final ReentrantLock lock = this.lock; lock.lock(); try { if (count == 0) return null; Object x = extract(); return x; } finally { lock.unlock(); } }
public Object poll() { final ReentrantLock lock = this.lock; lock.lock(); try { if (count == 0) return null; Object x = extract(); return x; } finally { lock.unlock(); } }
public Object poll() { final ReentrantLock lock = this.lock; lock.lock(); try { if (count == 0) return null; Object x = extract(); return x; } finally { lock.unlock(); } }
public Object take() throws InterruptedException { final ReentrantLock lock = this.lock; lock.lockInterruptibly(); try { try { while (count == 0) notEmpty.await(); } catch (InterruptedException ie) { notEmpty.signal(); // propagate to non-interrupted thread throw ie; } Object x = extract(); return x; } finally { lock.unlock(); } }
public Object take() throws InterruptedException { final ReentrantLock lock = this.lock; lock.lockInterruptibly(); try { try { while (count == 0) notEmpty.await(); } catch (InterruptedException ie) { notEmpty.signal(); // propagate to non-interrupted thread throw ie; } Object x = extract(); return x; } finally { lock.unlock(); } }
public Object take() throws InterruptedException { final ReentrantLock lock = this.lock; lock.lockInterruptibly(); try { try { while (count == 0) notEmpty.await(); } catch (InterruptedException ie) { notEmpty.signal(); // propagate to non-interrupted thread throw ie; } Object x = extract(); return x; } finally { lock.unlock(); } }
public Object poll(long timeout, TimeUnit unit) throws InterruptedException { long nanos = unit.toNanos(timeout); final ReentrantLock lock = this.lock; lock.lockInterruptibly(); try { long deadline = Utils.nanoTime() + nanos; for (;;) { if (count != 0) { Object x = extract(); return x; } if (nanos <= 0) return null; try { notEmpty.await(nanos, TimeUnit.NANOSECONDS); nanos = deadline - Utils.nanoTime(); } catch (InterruptedException ie) { notEmpty.signal(); // propagate to non-interrupted thread throw ie; } } } finally { lock.unlock(); } }
public Object poll(long timeout, TimeUnit unit) throws InterruptedException { long nanos = unit.toNanos(timeout); final ReentrantLock lock = this.lock; lock.lockInterruptibly(); try { long deadline = Utils.nanoTime() + nanos; for (;;) { if (count != 0) { Object x = extract(); return x; } if (nanos <= 0) return null; try { notEmpty.await(nanos, TimeUnit.NANOSECONDS); nanos = deadline - Utils.nanoTime(); } catch (InterruptedException ie) { notEmpty.signal(); // propagate to non-interrupted thread throw ie; } } } finally { lock.unlock(); } }
public Object poll(long timeout, TimeUnit unit) throws InterruptedException { long nanos = unit.toNanos(timeout); final ReentrantLock lock = this.lock; lock.lockInterruptibly(); try { long deadline = Utils.nanoTime() + nanos; for (;;) { if (count != 0) { Object x = extract(); return x; } if (nanos <= 0) return null; try { notEmpty.await(nanos, TimeUnit.NANOSECONDS); nanos = deadline - Utils.nanoTime(); } catch (InterruptedException ie) { notEmpty.signal(); // propagate to non-interrupted thread throw ie; } } } finally { lock.unlock(); } }