993 /**
994 * Returns a {@link Spliterator} over the elements in this queue.
995 *
996 * <p>The returned spliterator is
997 * <a href="package-summary.html#Weakly"><i>weakly consistent</i></a>.
998 *
999 * <p>The {@code Spliterator} reports {@link Spliterator#SIZED} and
1000 * {@link Spliterator#NONNULL}.
1001 *
1002 * @implNote
1003 * The {@code Spliterator} additionally reports {@link Spliterator#SUBSIZED}.
1004 *
1005 * @return a {@code Spliterator} over the elements in this queue
1006 * @since 1.8
1007 */
1008 public Spliterator<E> spliterator() {
1009 return new PBQSpliterator<E>(this, null, 0, -1);
1010 }
1011
1012 // Unsafe mechanics
1013 private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe();
1014 private static final long ALLOCATIONSPINLOCK;
1015 static {
1016 try {
1017 ALLOCATIONSPINLOCK = U.objectFieldOffset
1018 (PriorityBlockingQueue.class.getDeclaredField("allocationSpinLock"));
1019 } catch (ReflectiveOperationException e) {
1020 throw new Error(e);
1021 }
1022 }
1023 }
|
993 /**
994 * Returns a {@link Spliterator} over the elements in this queue.
995 *
996 * <p>The returned spliterator is
997 * <a href="package-summary.html#Weakly"><i>weakly consistent</i></a>.
998 *
999 * <p>The {@code Spliterator} reports {@link Spliterator#SIZED} and
1000 * {@link Spliterator#NONNULL}.
1001 *
1002 * @implNote
1003 * The {@code Spliterator} additionally reports {@link Spliterator#SUBSIZED}.
1004 *
1005 * @return a {@code Spliterator} over the elements in this queue
1006 * @since 1.8
1007 */
1008 public Spliterator<E> spliterator() {
1009 return new PBQSpliterator<E>(this, null, 0, -1);
1010 }
1011
1012 // Unsafe mechanics
1013 private static final jdk.internal.misc.Unsafe U = jdk.internal.misc.Unsafe.getUnsafe();
1014 private static final long ALLOCATIONSPINLOCK;
1015 static {
1016 try {
1017 ALLOCATIONSPINLOCK = U.objectFieldOffset
1018 (PriorityBlockingQueue.class.getDeclaredField("allocationSpinLock"));
1019 } catch (ReflectiveOperationException e) {
1020 throw new Error(e);
1021 }
1022 }
1023 }
|