/** * Add an element to the head of the queue, providing the queue node to be used. * * This method can be used from any thread. * * @param n the node containing the element to be added; both must not be null */ public final void addNode(final Node<T> n) { n.setNext(null); getAndSet(n).setNext(n); }
/** * Query the queue tail for the next element without dequeuing it. * * Use this method only from the consumer thread! * * @return element if there was one, or null if there was none */ public final T peek() { final Node<T> n = peekNode(); return (n != null) ? n.value : null; }
/** * Removes the first element of this queue if any * @return the value of the first element of the queue, null if empty */ public final T poll() { final Node<T> n = pollNode(); return (n != null) ? n.value : null; }
/** * * @return the first value of this queue, null if empty */ public final T peek() { final Node<T> n = peekNode(); return (n != null) ? n.value : null; }
/** * Add an element to the head of the queue, providing the queue node to be used. * * This method can be used from any thread. * * @param n the node containing the element to be added; both must not be null */ public final void addNode(final Node<T> n) { n.setNext(null); getAndSet(n).setNext(n); }
/** * Query the queue tail for the next element without dequeuing it. * * Use this method only from the consumer thread! * * @return element if there was one, or null if there was none */ public final T peek() { final Node<T> n = peekNode(); return (n != null) ? n.value : null; }
/** * Add an element to the head of the queue, providing the queue node to be used. * * This method can be used from any thread. * * @param n the node containing the element to be added; both must not be null */ public final void addNode(final Node<T> n) { n.setNext(null); getAndSet(n).setNext(n); }
/** * Query the queue tail for the next element without dequeuing it. * * Use this method only from the consumer thread! * * @return element if there was one, or null if there was none */ public final T peek() { final Node<T> n = peekNode(); return (n != null) ? n.value : null; }
/** * Add an element to the head of the queue, providing the queue node to be used. * * This method can be used from any thread. * * @param n the node containing the element to be added; both must not be null */ public final void addNode(final Node<T> n) { n.setNext(null); getAndSet(n).setNext(n); }