public class DefaultAtomicCounter extends Synchronous<AsyncAtomicCounter> implements AtomicCounter
AtomicCounter
backed by a AsyncAtomicCounter
.DistributedPrimitive.Status, DistributedPrimitive.Type
DEFAULT_OPERATION_TIMEOUT_MILLIS, DEFAULT_OPERTATION_TIMEOUT_MILLIS
Constructor and Description |
---|
DefaultAtomicCounter(AsyncAtomicCounter asyncCounter,
long operationTimeoutMillis) |
Modifier and Type | Method and Description |
---|---|
long |
addAndGet(long delta)
Atomically adds the given value to the current value.
|
boolean |
compareAndSet(long expectedValue,
long updateValue)
Atomically sets the given counter to the updated value if the current value is the expected value, otherwise
no change occurs.
|
long |
get()
Returns the current value of the counter without modifying it.
|
long |
getAndAdd(long delta)
Atomically adds the given value to the current value.
|
long |
getAndIncrement()
Atomically increment by one the current value.
|
long |
incrementAndGet()
Atomically increment by one the current value.
|
void |
set(long value)
Atomically sets the given value to the current value.
|
destroy, name, primitiveType
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
primitiveType
addStatusChangeListener, applicationId, destroy, name, removeStatusChangeListener, statusChangeListeners
public DefaultAtomicCounter(AsyncAtomicCounter asyncCounter, long operationTimeoutMillis)
public long incrementAndGet()
AtomicCounter
incrementAndGet
in interface AtomicCounter
public long getAndIncrement()
AtomicCounter
getAndIncrement
in interface AtomicCounter
public long getAndAdd(long delta)
AtomicCounter
getAndAdd
in interface AtomicCounter
delta
- the value to addpublic long addAndGet(long delta)
AtomicCounter
addAndGet
in interface AtomicCounter
delta
- the value to addpublic void set(long value)
AtomicCounter
set
in interface AtomicCounter
value
- the value to setpublic boolean compareAndSet(long expectedValue, long updateValue)
AtomicCounter
compareAndSet
in interface AtomicCounter
expectedValue
- the expected current value of the counterupdateValue
- the new value to be setpublic long get()
AtomicCounter
get
in interface AtomicCounter