Methods Summary |
---|
public final int | addAndGet(int i, int delta)Atomically add the given value to element at index i.
while (true) {
int current = get(i);
int next = current + delta;
if (compareAndSet(i, current, next))
return next;
}
|
public final boolean | compareAndSet(int i, int expect, int update)Atomically set the value to the given updated value
if the current value == the expected value.
return unsafe.compareAndSwapInt(array, rawIndex(i),
expect, update);
|
public final int | decrementAndGet(int i)Atomically decrement by one the element at index i.
while (true) {
int current = get(i);
int next = current - 1;
if (compareAndSet(i, current, next))
return next;
}
|
public final int | get(int i)Get the current value at position i.
return unsafe.getIntVolatile(array, rawIndex(i));
|
public final int | getAndAdd(int i, int delta)Atomically add the given value to element at index i.
while (true) {
int current = get(i);
int next = current + delta;
if (compareAndSet(i, current, next))
return current;
}
|
public final int | getAndDecrement(int i)Atomically decrement by one the element at index i.
while (true) {
int current = get(i);
int next = current - 1;
if (compareAndSet(i, current, next))
return current;
}
|
public final int | getAndIncrement(int i)Atomically increment by one the element at index i.
while (true) {
int current = get(i);
int next = current + 1;
if (compareAndSet(i, current, next))
return current;
}
|
public final int | getAndSet(int i, int newValue)Set the element at position i to the given value and return the
old value.
while (true) {
int current = get(i);
if (compareAndSet(i, current, newValue))
return current;
}
|
public final int | incrementAndGet(int i)Atomically increment by one the element at index i.
while (true) {
int current = get(i);
int next = current + 1;
if (compareAndSet(i, current, next))
return next;
}
|
public final int | length()Returns the length of the array.
return array.length;
|
private long | rawIndex(int i)
if (i < 0 || i >= array.length)
throw new IndexOutOfBoundsException("index " + i);
return base + i * scale;
|
public final void | set(int i, int newValue)Set the element at position i to the given value.
unsafe.putIntVolatile(array, rawIndex(i), newValue);
|
public java.lang.String | toString()Returns the String representation of the current values of array.
if (array.length > 0) // force volatile read
get(0);
return Arrays.toString(array);
|
public final boolean | weakCompareAndSet(int i, int expect, int update)Atomically set the value to the given updated value
if the current value == the expected value.
May fail spuriously.
return compareAndSet(i, expect, update);
|