/** * Adds a new entry to this list. * * @param element The element to add. */ public void add(T element) { final Node<T> newnode = new Node<T>( element ); addNode( newnode ); }
/** * Returns an Iterable over all results added so far, but * atomically clears the structure as well. * The returned iterable will be the only entry point to * read the previously appended data. * @return an Iterable, or null if there is no data. */ public Iterable<T> drainToDetachedIterable() { final Node<T> head = drainHead(); if ( head != null ) { return new DetachedNodeIterable<T>( head ); } else { //The choice to return null rather than an empty iterator //allows the client to not need an isEmpty() method, which would //need a different level of lock granularity. return null; } }
@Override public void run() { Iterable<Changeset> changesets; try { while ( !stop ) { changesets = transferQueue.drainToDetachedIterable(); while ( changesets == null && !stop ) { // Avoid busy wait parkCurrentThread(); changesets = transferQueue.drainToDetachedIterable(); } if ( changesets != null ) { applyChangesets( changesets ); } } log.stoppingSyncConsumerThread( indexName ); } finally { shutdownLatch.countDown(); } }
transferQueue.add( changeset ); wakeUpConsumer(); boolean interrupted = false;
transferQueue.add( changeset ); wakeUpConsumer(); boolean interrupted = false;
/** * Adds a new entry to this list. * * @param element The element to add. */ public void add(T element) { final Node<T> newnode = new Node<T>( element ); addNode( newnode ); }
/** * Returns an Iterable over all results added so far, but * atomically clears the structure as well. * The returned iterable will be the only entry point to * read the previously appended data. * @return an Iterable, or null if there is no data. */ public Iterable<T> drainToDetachedIterable() { final Node<T> head = drainHead(); if ( head != null ) { return new DetachedNodeIterable<T>( head ); } else { //The choice to return null rather than an empty iterator //allows the client to not need an isEmpty() method, which would //need a different level of lock granularity. return null; } }
@Override public void run() { Iterable<Changeset> changesets; try { while ( !stop ) { changesets = transferQueue.drainToDetachedIterable(); while ( changesets == null && !stop ) { // Avoid busy wait parkCurrentThread(); changesets = transferQueue.drainToDetachedIterable(); } if ( changesets != null ) { applyChangesets( changesets ); } } log.stoppingSyncConsumerThread( indexName ); } finally { shutdownLatch.countDown(); } }