static { SIZE_OF_ELEMENT = UnsafeAccess.UNSAFE.arrayIndexScale(Object[].class); if (4 == SIZE_OF_ELEMENT) { REF_ELEMENT_SHIFT = 2 + SPARSE_SHIFT; } else if (8 == SIZE_OF_ELEMENT) { REF_ELEMENT_SHIFT = 3 + SPARSE_SHIFT; } else { throw new IllegalStateException("Unknown pointer size"); } // Including the buffer pad in the array base offset REF_ARRAY_BASE = UnsafeAccess.UNSAFE.arrayBaseOffset(Object[].class) + (BUFFER_PAD << (REF_ELEMENT_SHIFT - SPARSE_SHIFT)); }
static { try { HEAD_OFFSET = UnsafeAccess.UNSAFE.objectFieldOffset( MpmcConcurrentQueueSMHeadField.class.getDeclaredField("head")); } catch (NoSuchFieldException e) { throw new RuntimeException(e); } }
protected final boolean casHead(long expect, long newValue) { return UnsafeAccess.UNSAFE.compareAndSwapLong(this, HEAD_OFFSET, expect, newValue); }