org.jgroups.blocks.atomic
Interface Counter

All Known Implementing Classes:
COUNTER.CounterImpl

public interface Counter

Since:
3.0.0
Author:
Bela Ban

Method Summary
 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 operation
 long decrementAndGet()
          Atomically decrements the counter and returns the new value
 long get()
          Gets the current value of the counter
 java.lang.String getName()
           
 long incrementAndGet()
          Atomically increments the counter and returns the new value
 void set(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 counter
update - 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


Copyright © 1998-2012 Bela Ban / Red Hat. All Rights Reserved.