Package org.jgroups.protocols
Class COUNTER.CounterImpl
- java.lang.Object
-
- org.jgroups.protocols.COUNTER.CounterImpl
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.Stringname
-
Constructor Summary
Constructors Modifier Constructor Description protectedCounterImpl(java.lang.String name)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longaddAndGet(long delta)Atomically adds the given value to the current value.booleancompareAndSet(long expect, long update)Atomically updates the counter using a CAS operationlongdecrementAndGet()Atomically decrements the counter and returns the new valuelongget()Gets the current value of the counterjava.lang.StringgetName()longincrementAndGet()Atomically increments the counter and returns the new valuevoidset(long new_value)Sets the counter to a new valuejava.lang.StringtoString()
-
-
-
Method Detail
-
get
public long get()
Description copied from interface:CounterGets the current value of the counter
-
set
public void set(long new_value)
Description copied from interface:CounterSets the counter to a new value
-
compareAndSet
public boolean compareAndSet(long expect, long update)Description copied from interface:CounterAtomically updates the counter using a CAS operation- Specified by:
compareAndSetin interfaceCounter- Parameters:
expect- The expected value of the counterupdate- The new value of the counter- Returns:
- True if the counter could be updated, false otherwise
-
incrementAndGet
public long incrementAndGet()
Description copied from interface:CounterAtomically increments the counter and returns the new value- Specified by:
incrementAndGetin interfaceCounter- Returns:
- The new value
-
decrementAndGet
public long decrementAndGet()
Description copied from interface:CounterAtomically decrements the counter and returns the new value- Specified by:
decrementAndGetin interfaceCounter- Returns:
- The new value
-
addAndGet
public long addAndGet(long delta)
Description copied from interface:CounterAtomically adds the given value to the current value.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-