/** * @see stream.io.Barrel#clear() */ @Override public int clear() { fullyLock(); int removed = count.get(); try { for (Node<Data> p, h = head; (p = h.next) != null; h = p) { h.next = h; p.item = null; } head = last; // assert head.item == null && head.next == null; if (count.getAndSet(0) == capacity) notFull.signal(); } finally { fullyUnlock(); } return removed; }
/** * @see stream.io.Barrel#clear() */ @Override public int clear() { fullyLock(); int removed = count.get(); try { for (Node<Data> p, h = head; (p = h.next) != null; h = p) { h.next = h; p.item = null; } head = last; // assert head.item == null && head.next == null; if (count.getAndSet(0) == capacity) notFull.signal(); } finally { fullyUnlock(); } return removed; }
/** * @see stream.io.Stream#close() */ public void close() throws Exception { log.debug("Closing queue '{}'...", getId()); fullyLock(); try { if (closed.get()) { log.debug("Queue '{}' already closed.", getId()); return; } // log.debug("queue: {}", queue); closed.getAndSet(true); } finally { fullyUnlock(); } }
/** * @see stream.io.Stream#close() */ public void close() throws Exception { log.debug("Closing queue '{}'...", getId()); fullyLock(); try { if (closed.get()) { log.debug("Queue '{}' already closed.", getId()); return; } // log.debug("queue: {}", queue); closed.getAndSet(true); } finally { fullyUnlock(); } }