public void accept ( Supplier < PrimitiveIterator . OfInt > segments ) { Supplier < PrimitiveIterator . OfInt > notifyThese ; Object key = currentKey . get ( ) ; if ( key != null ) { pendingSegments . put ( key , segments ) ; // We now try to go back and set current key to null if ( currentKey . getAndSet ( null ) == null ) { // If it was already null that means we returned our key via the iterator below // In this case they may or may not have seen the pendingSegments so if they didn't we have to // notify ourselves notifyThese = pendingSegments . remove ( key ) ; } else { // Means that the iteration will see this notifyThese = null ; } } else { // This means that we got a set of segments that had no entries in them or the iterator // consumed all entries, so just notify right away notifyThese = segments ; } if ( notifyThese != null ) { completionListener . accept ( notifyThese ) ; } }
Method to be invoked after all entries have been passed to the stream that belong to these segments