ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/main/java/util/concurrent/PriorityBlockingQueue.java
(Generate patch)

Comparing jsr166/src/main/java/util/concurrent/PriorityBlockingQueue.java (file contents):
Revision 1.114 by jsr166, Tue Apr 19 22:55:30 2016 UTC vs.
Revision 1.115 by dl, Thu Jun 2 13:16:27 2016 UTC

# Line 6 | Line 6
6  
7   package java.util.concurrent;
8  
9 + import java.lang.invoke.MethodHandles;
10 + import java.lang.invoke.VarHandle;
11   import java.util.AbstractQueue;
12   import java.util.Arrays;
13   import java.util.Collection;
# Line 260 | Line 262 | public class PriorityBlockingQueue<E> ex
262          lock.unlock(); // must release and then re-acquire main lock
263          Object[] newArray = null;
264          if (allocationSpinLock == 0 &&
265 <            U.compareAndSwapInt(this, ALLOCATIONSPINLOCK, 0, 1)) {
265 >            ALLOCATIONSPINLOCK.compareAndSet(this, 0, 1)) {
266              try {
267                  int newCap = oldCap + ((oldCap < 64) ?
268                                         (oldCap + 2) : // grow faster if small
# Line 980 | Line 982 | public class PriorityBlockingQueue<E> ex
982          return new PBQSpliterator<E>(this, null, 0, -1);
983      }
984  
985 <    // Unsafe mechanics
986 <    private static final jdk.internal.misc.Unsafe U = jdk.internal.misc.Unsafe.getUnsafe();
985 <    private static final long ALLOCATIONSPINLOCK;
985 >    // VarHandle mechanics
986 >    private static final VarHandle ALLOCATIONSPINLOCK;
987      static {
988          try {
989 <            ALLOCATIONSPINLOCK = U.objectFieldOffset
990 <                (PriorityBlockingQueue.class.getDeclaredField("allocationSpinLock"));
989 >            MethodHandles.Lookup l = MethodHandles.lookup();
990 >            ALLOCATIONSPINLOCK = l.findVarHandle(PriorityBlockingQueue.class,
991 >                                                 "allocationSpinLock",
992 >                                                 int.class);
993          } catch (ReflectiveOperationException e) {
994              throw new Error(e);
995          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines