/** * Creates a <tt>LinkedBlockingQueue</tt> with the given (fixed) capacity. * * @param capacity the capacity of this queue. * @throws IllegalArgumentException if <tt>capacity</tt> is not greater than zero. */ public ConcurrentBlockingQueue(int capacity) { if (capacity <= 0) throw new IllegalArgumentException(); this.capacity = capacity; last = head = new Node<E>(null); }
if (o.equals(p.getItem())) { removed = true; break;
if (o.equals(p.getItem())) { removed = true; break;
if (o.equals(p.getItem())) { removed = true; break;
public int drainTo(Collection<? super E> c) { if (c == null) throw new NullPointerException(); if (c == this) throw new IllegalArgumentException(); Node first; fullyLock(); try { first = head.next; head.next = null; last = head; if (ManagerUtil.isManaged(this)) { ManagerUtil.logicalInvoke(this, SerializationUtil.CLEAR_SIGNATURE, new Object[] {}); } if (count.getAndSet(0) == capacity) notFull.signalAll(); } finally { fullyUnlock(); } // Transfer the elements outside of locks int n = 0; for (Node<E> p = first; p != null; p = p.next) { c.add(p.getItem()); p.item = null; ++n; } return n; }
public int drainTo(Collection<? super E> c) { if (c == null) throw new NullPointerException(); if (c == this) throw new IllegalArgumentException(); Node first; fullyLock(); try { first = head.next; head.next = null; last = head; if (ManagerUtil.isManaged(this)) { ManagerUtil.logicalInvoke(this, SerializationUtil.CLEAR_SIGNATURE, new Object[] {}); } if (count.getAndSet(0) == capacity) notFull.signalAll(); } finally { fullyUnlock(); } // Transfer the elements outside of locks int n = 0; for (Node<E> p = first; p != null; p = p.next) { c.add(p.getItem()); p.item = null; ++n; } return n; }
public int drainTo(Collection<? super E> c, int maxElements) { if (c == null) throw new NullPointerException(); if (c == this) throw new IllegalArgumentException(); fullyLock(); try { int n = 0; Node<E> p = head.next; while (p != null && n < maxElements) { c.add(p.getItem()); p.item = null; p = p.next; ++n; } if (n != 0) { head.next = p; if (p == null) last = head; if (ManagerUtil.isManaged(this)) { ManagerUtil.logicalInvoke(this, SerializationUtil.REMOVE_FIRST_N_SIGNATURE, new Object[] { Integer.valueOf(n) }); } if (count.getAndAdd(-n) == capacity) notFull.signalAll(); } return n; } finally { fullyUnlock(); } }
public int drainTo(Collection<? super E> c) { if (c == null) throw new NullPointerException(); if (c == this) throw new IllegalArgumentException(); Node first; fullyLock(); try { first = head.next; head.next = null; last = head; if (ManagerUtil.isManaged(this)) { ManagerUtil.logicalInvoke(this, SerializationUtil.CLEAR_SIGNATURE, new Object[] {}); } if (count.getAndSet(0) == capacity) notFull.signalAll(); } finally { fullyUnlock(); } // Transfer the elements outside of locks int n = 0; for (Node<E> p = first; p != null; p = p.next) { c.add(p.getItem()); p.item = null; ++n; } return n; }
public int drainTo(Collection<? super E> c, int maxElements) { if (c == null) throw new NullPointerException(); if (c == this) throw new IllegalArgumentException(); fullyLock(); try { int n = 0; Node<E> p = head.next; while (p != null && n < maxElements) { c.add(p.getItem()); p.item = null; p = p.next; ++n; } if (n != 0) { head.next = p; if (p == null) last = head; if (ManagerUtil.isManaged(this)) { ManagerUtil.logicalInvoke(this, SerializationUtil.REMOVE_FIRST_N_SIGNATURE, new Object[] { Integer.valueOf(n) }); } if (count.getAndAdd(-n) == capacity) notFull.signalAll(); } return n; } finally { fullyUnlock(); } }
public int drainTo(Collection<? super E> c, int maxElements) { if (c == null) throw new NullPointerException(); if (c == this) throw new IllegalArgumentException(); fullyLock(); try { int n = 0; Node<E> p = head.next; while (p != null && n < maxElements) { c.add(p.getItem()); p.item = null; p = p.next; ++n; } if (n != 0) { head.next = p; if (p == null) last = head; if (ManagerUtil.isManaged(this)) { ManagerUtil.logicalInvoke(this, SerializationUtil.REMOVE_FIRST_N_SIGNATURE, new Object[] { Integer.valueOf(n) }); } if (count.getAndAdd(-n) == capacity) notFull.signalAll(); } return n; } finally { fullyUnlock(); } }
public E peek() { if (0 == count.get()) { return null; } takeWriteLock.lock(); try { Node<E> first = head.next; if (first == null) { return null; } else { return first.getItem(); } } finally { takeWriteLock.unlock(); } }
public E peek() { if (0 == count.get()) { return null; } takeWriteLock.lock(); try { Node<E> first = head.next; if (first == null) { return null; } else { return first.getItem(); } } finally { takeWriteLock.unlock(); } }
private void insert(E x) { last = last.next = new Node<E>(x); }
private void insert(E x) { last = last.next = new Node<E>(x); }
public E peek() { if (0 == count.get()) { return null; } takeWriteLock.lock(); try { Node<E> first = head.next; if (first == null) { return null; } else { return first.getItem(); } } finally { takeWriteLock.unlock(); } }
private E __tc_extract() { Node<E> first = head.next; head = first; E x = first.getItem(); first.item = null; return x; }
private E __tc_extract() { Node<E> first = head.next; head = first; E x = first.getItem(); first.item = null; return x; }
private E extract() { Node<E> first = head.next; head = first; E x = first.getItem(); first.item = null; return x; }
private E __tc_extract() { Node<E> first = head.next; head = first; E x = first.getItem(); first.item = null; return x; }
private void insert(E x) { last = last.next = new Node<E>(x); }