Package org.jgroups.blocks.atomic
Interface Counter
- 
- All Known Implementing Classes:
 COUNTER.CounterImpl
public interface Counter- Since:
 - 3.0.0
 - Author:
 - Bela Ban
 
 
- 
- 
Method Summary
All Methods Instance Methods Abstract 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 value 
 - 
 
- 
- 
Method Detail
- 
getName
java.lang.String getName()
 
- 
get
long get()
Gets the current value of the counter- Returns:
 - The current value
 
 
- 
set
void set(long new_value)
Sets the counter to a new value- Parameters:
 new_value- The new value
 
- 
compareAndSet
boolean compareAndSet(long expect, long update)Atomically updates the counter using a CAS operation- 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
long incrementAndGet()
Atomically increments the counter and returns the new value- Returns:
 - The new value
 
 
- 
decrementAndGet
long decrementAndGet()
Atomically decrements the counter and returns the new value- Returns:
 - The new value
 
 
- 
addAndGet
long addAndGet(long delta)
Atomically adds the given value to the current value.- Parameters:
 delta- the value to add- Returns:
 - the updated value
 
 
 - 
 
 -