org.jgroups.protocols
Class COUNTER.CounterImpl

java.lang.Object
  extended by org.jgroups.protocols.COUNTER.CounterImpl
All Implemented Interfaces:
Counter
Enclosing class:
COUNTER

protected class COUNTER.CounterImpl
extends java.lang.Object
implements Counter


Field Summary
protected  java.lang.String name
           
 
Constructor Summary
protected COUNTER.CounterImpl(java.lang.String name)
           
 
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
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

name

protected final java.lang.String name
Constructor Detail

COUNTER.CounterImpl

protected COUNTER.CounterImpl(java.lang.String name)
Method Detail

getName

public java.lang.String getName()
Specified by:
getName in interface Counter

get

public long get()
Description copied from interface: Counter
Gets the current value of the counter

Specified by:
get in interface Counter
Returns:
The current value

set

public void set(long new_value)
Description copied from interface: Counter
Sets the counter to a new value

Specified by:
set in interface Counter
Parameters:
new_value - The 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 interface Counter
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

public long incrementAndGet()
Description copied from interface: Counter
Atomically increments the counter and returns the new value

Specified by:
incrementAndGet in interface Counter
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 interface Counter
Returns:
The new value

addAndGet

public long addAndGet(long delta)
Description copied from interface: Counter
Atomically adds the given value to the current value.

Specified by:
addAndGet in interface Counter
Parameters:
delta - the value to add
Returns:
the updated value

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


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