public E next()

in src/main/java/com/twitter/whiskey/futures/ReactiveFuture.java [234:254]


        public E next() {

            if (drained != null && drained.hasNext()) return drained.next();

            if (currentElement != null && currentElement != SENTINEL) {
                E element = (E) currentElement;
                currentElement = null;
                return element;
            }

            if (isDone() && queue.isEmpty()) throw new NoSuchElementException();

            synchronized (ReactiveFuture.this) {
                if (isDone() && queue.isEmpty()) throw new NoSuchElementException();
            }

            if (!hasNext()) throw new NoSuchElementException();
            E element = (E) currentElement;
            currentElement = null;
            return element;
        }