Method from java.util.concurrent.atomic.AtomicLong Detail: |
public final long addAndGet(long delta) {
for (;;) {
long current = get();
long next = current + delta;
if (compareAndSet(current, next))
return next;
}
}
Atomically adds the given value to the current value. |
public final boolean compareAndSet(long expect,
long update) {
return unsafe.compareAndSwapLong(this, valueOffset, expect, update);
}
Atomically sets the value to the given updated value
if the current value {@code ==} the expected value. |
public final long decrementAndGet() {
for (;;) {
long current = get();
long next = current - 1;
if (compareAndSet(current, next))
return next;
}
}
Atomically decrements by one the current value. |
public double doubleValue() {
return (double)get();
}
|
public float floatValue() {
return (float)get();
}
|
public final long get() {
return value;
}
|
public final long getAndAdd(long delta) {
while (true) {
long current = get();
long next = current + delta;
if (compareAndSet(current, next))
return current;
}
}
Atomically adds the given value to the current value. |
public final long getAndDecrement() {
while (true) {
long current = get();
long next = current - 1;
if (compareAndSet(current, next))
return current;
}
}
Atomically decrements by one the current value. |
public final long getAndIncrement() {
while (true) {
long current = get();
long next = current + 1;
if (compareAndSet(current, next))
return current;
}
}
Atomically increments by one the current value. |
public final long getAndSet(long newValue) {
while (true) {
long current = get();
if (compareAndSet(current, newValue))
return current;
}
}
Atomically sets to the given value and returns the old value. |
public final long incrementAndGet() {
for (;;) {
long current = get();
long next = current + 1;
if (compareAndSet(current, next))
return next;
}
}
Atomically increments by one the current value. |
public int intValue() {
return (int)get();
}
|
public final void lazySet(long newValue) {
unsafe.putOrderedLong(this, valueOffset, newValue);
}
Eventually sets to the given value. |
public long longValue() {
return get();
}
|
public final void set(long newValue) {
value = newValue;
}
|
public String toString() {
return Long.toString(get());
}
Returns the String representation of the current value. |
public final boolean weakCompareAndSet(long expect,
long update) {
return unsafe.compareAndSwapLong(this, valueOffset, expect, update);
}
Atomically sets the value to the given updated value
if the current value {@code ==} the expected value.
May fail spuriously
and does not provide ordering guarantees, so is only rarely an
appropriate alternative to {@code compareAndSet}. |