1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
| public final int get(int i) { return getRaw(checkedByteOffset(i)); }
private int getRaw(long offset) { return unsafe.getIntVolatile(array, offset); }
public final void set(int i, int newValue) { unsafe.putIntVolatile(array, checkedByteOffset(i), newValue); }
public final int getAndSet(int i, int newValue) { return unsafe.getAndSetInt(array, checkedByteOffset(i), newValue); }
public final boolean compareAndSet(int i, int expect, int update) { return compareAndSetRaw(checkedByteOffset(i), expect, update); }
private boolean compareAndSetRaw(long offset, int expect, int update) { return unsafe.compareAndSwapInt(array, offset, expect, update); }
public final int getAndIncrement(int i) { return getAndAdd(i, 1); }
public final int getAndDecrement(int i) { return getAndAdd(i, -1); }
public final int incrementAndGet(int i) { return getAndAdd(i, 1) + 1; }
public final int decrementAndGet(int i) { return getAndAdd(i, -1) - 1; }
public final int getAndAdd(int i, int delta) { return unsafe.getAndAddInt(array, checkedByteOffset(i), delta); }
|