Methods Summary |
---|
public long | addAndGet(int i, long delta)Atomically add the given value to element at index i.
while (true) {
long current = get(i);
long next = current + delta;
if (compareAndSet(i, current, next))
return next;
}
|
public final boolean | compareAndSet(int i, long expect, long update)Atomically set the value to the given updated value
if the current value == the expected value.
return unsafe.compareAndSwapLong(array, rawIndex(i),
expect, update);
|
public final long | decrementAndGet(int i)Atomically decrement the element at index i.
while (true) {
long current = get(i);
long next = current - 1;
if (compareAndSet(i, current, next))
return next;
}
|
public final long | get(int i)Get the current value at position i.
return unsafe.getLongVolatile(array, rawIndex(i));
|
public final long | getAndAdd(int i, long delta)Atomically add the given value to element at index i.
while (true) {
long current = get(i);
long next = current + delta;
if (compareAndSet(i, current, next))
return current;
}
|
public final long | getAndDecrement(int i)Atomically decrement by one the element at index i.
while (true) {
long current = get(i);
long next = current - 1;
if (compareAndSet(i, current, next))
return current;
}
|
public final long | getAndIncrement(int i)Atomically increment by one the element at index i.
while (true) {
long current = get(i);
long next = current + 1;
if (compareAndSet(i, current, next))
return current;
}
|
public final long | getAndSet(int i, long newValue)Set the element at position i to the given value and return the
old value.
while (true) {
long current = get(i);
if (compareAndSet(i, current, newValue))
return current;
}
|
public final long | incrementAndGet(int i)Atomically increment the element at index i.
while (true) {
long current = get(i);
long 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, long newValue)Set the element at position i to the given value.
unsafe.putLongVolatile(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, long expect, long 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);
|