private R queueNext() { int localIndex = index; AtomicReferenceArray<T> array = values; while (true) { if (localIndex >= array.length()) { return null; } T localValue = array.get(localIndex); if (localValue == null) { return null; } localIndex++; R alive = unwrap(localValue); if (alive == null) { continue; } index = localIndex; return alive; } }
private R queueNext() { int localIndex = index; AtomicReferenceArray<T> array = values; while (true) { if (localIndex >= array.length()) { return null; } T localValue = array.get(localIndex); if (localValue == null) { return null; } localIndex++; R alive = unwrap(localValue); if (alive == null) { continue; } index = localIndex; return alive; } }
@Override public final synchronized boolean add(R reference) { T wrappedElement = wrap(reference); if (wrappedElement == null) { // fail early throw new NullPointerException(); } if (nextInsertionIndex >= values.length()) { compact(); } values.set(nextInsertionIndex++, wrappedElement); return true; }
@Override public final synchronized boolean add(R reference) { T wrappedElement = wrap(reference); if (wrappedElement == null) { // fail early throw new NullPointerException(); } if (nextInsertionIndex >= values.length()) { compact(); } values.set(nextInsertionIndex++, wrappedElement); return true; }