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.String
name
-
Constructor Summary
Constructors Modifier Constructor Description protected
CounterImpl(java.lang.String name)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
addAndGet(long delta)
Atomically adds the given value to the current value.boolean
compareAndSet(long expect, long update)
Atomically updates the counter using a CAS operationlong
decrementAndGet()
Atomically decrements the counter and returns the new valuelong
get()
Gets the current value of the counterjava.lang.String
getName()
long
incrementAndGet()
Atomically increments the counter and returns the new valuevoid
set(long new_value)
Sets the counter to a new valuejava.lang.String
toString()
-
-
-
Method Detail
-
get
public long get()
Description copied from interface:Counter
Gets the current value of the counter
-
set
public void set(long new_value)
Description copied from interface:Counter
Sets the counter to a new value
-
compareAndSet
public boolean compareAndSet(long expect, long update)
Description copied from interface:Counter
Atomically updates the counter using a CAS operation- Specified by:
compareAndSet
in 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:Counter
Atomically increments the counter and returns the new value- Specified by:
incrementAndGet
in interfaceCounter
- Returns:
- The new value
-
decrementAndGet
public long decrementAndGet()
Description copied from interface:Counter
Atomically decrements the counter and returns the new value- Specified by:
decrementAndGet
in interfaceCounter
- Returns:
- The new value
-
addAndGet
public long addAndGet(long delta)
Description copied from interface:Counter
Atomically adds the given value to the current value.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-