260 |
|
lock.unlock(); // must release and then re-acquire main lock |
261 |
|
Object[] newArray = null; |
262 |
|
if (allocationSpinLock == 0 && |
263 |
< |
UNSAFE.compareAndSwapInt(this, allocationSpinLockOffset, |
264 |
< |
0, 1)) { |
263 |
> |
U.compareAndSwapInt(this, ALLOCATIONSPINLOCK, 0, 1)) { |
264 |
|
try { |
265 |
|
int newCap = oldCap + ((oldCap < 64) ? |
266 |
|
(oldCap + 2) : // grow faster if small |
998 |
|
} |
999 |
|
|
1000 |
|
// Unsafe mechanics |
1001 |
< |
private static final sun.misc.Unsafe UNSAFE; |
1002 |
< |
private static final long allocationSpinLockOffset; |
1001 |
> |
private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe(); |
1002 |
> |
private static final long ALLOCATIONSPINLOCK; |
1003 |
|
static { |
1004 |
|
try { |
1005 |
< |
UNSAFE = sun.misc.Unsafe.getUnsafe(); |
1006 |
< |
Class<?> k = PriorityBlockingQueue.class; |
1008 |
< |
allocationSpinLockOffset = UNSAFE.objectFieldOffset |
1009 |
< |
(k.getDeclaredField("allocationSpinLock")); |
1005 |
> |
ALLOCATIONSPINLOCK = U.objectFieldOffset |
1006 |
> |
(PriorityBlockingQueue.class.getDeclaredField("allocationSpinLock")); |
1007 |
|
} catch (ReflectiveOperationException e) { |
1008 |
|
throw new Error(e); |
1009 |
|
} |