Overview | Package | Class | Tree | Index | Help

Oracle® Coherence Java API Reference
v3.5.3
E15583-01
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.tangosol.util
Class AtomicCounter

    java.lang.Object
      com.tangosol.util.Base
          com.tangosol.util.AtomicCounter

    public abstract class AtomicCounter

extends Base

Abstract base class for AtomicCounters. The AtomicCounter allows for atomic updates to a "long" value where possible without requiring synchronization. The underlying AtomicCounter impelementation will be choosen based at runtime.

Since:
  Coherence 3.2
Author:
  mf 2006.05.09

Field Summary
`protected static java.lang.Class` | `s_clzImplementation` The counter implementation which will be used.

Constructor Summary
`AtomicCounter()`

Method Summary
`protected abstract long` | `adjust(long c)` Adjust the value of the counter by the specified amount, and return the new value.
`long` | `decrement()` Decrement the value, and return the new value.
`long` | `decrement(long c)` Decrement the value by c, and return the new value.
`abstract long` | `getCount()` Return the current value of the counter.
`long` | `increment()` Incremenet the value, and return the new value.
`long` | `increment(long c)` Incremenet the value by c, and return the new value.
`static AtomicCounter` | `newAtomicCounter()` Instantiate and return a new AtomicCounter.
`static AtomicCounter` | `newAtomicCounter(long l)` Instantiate and return a new AtomicCounter initialized to a particular value.
`protected abstract long` | `postAdjust(long c)` Adjust the value of the counter by the specified amount, and return the old value.
`long` | `postDecrement()` Decrement the value, and return the original value.
`long` | `postDecrement(long c)` Decrement the value by c, and return the original value.
`long` | `postIncrement()` Incremenet the value, and return the original value.
`long` | `postIncrement(long c)` Incremenet the value by c, and return the original value.
`abstract long` | `setCount(long cNew)` Update the current value, and return the previous value.
`abstract boolean` | `setCount(long cAssume, long cNew)` Update the current value, only if it is equal to the assumed value.
`java.lang.String` | `toString()` Return the count as a string.

Field Detail

### s_clzImplementation

    protected static java.lang.Class s_clzImplementation

  The counter implementation which will be used.

Constructor Detail

### AtomicCounter

    public AtomicCounter()

Method Detail

### increment

    public long increment()

  Incremenet the value, and return the new value.

  Returns:
    the new value

### increment

    public long increment(long c)

  Incremenet the value by c, and return the new value.

  Parameters:
    `c` - the amount to increment the counter by
  Returns:
    the new value

### postIncrement

    public long postIncrement()

  Incremenet the value, and return the original value.

  Returns:
    the original value

### postIncrement

    public long postIncrement(long c)

  Incremenet the value by c, and return the original value.

  Parameters:
    `c` - the amount to increment the counter by
  Returns:
    the original value

### decrement

    public long decrement()

  Decrement the value, and return the new value.

  Returns:
    the new value

### decrement

    public long decrement(long c)

  Decrement the value by c, and return the new value.

  Parameters:
    `c` - the amount to decrement the counter by
  Returns:
    the new value

### postDecrement

    public long postDecrement()

  Decrement the value, and return the original value.

  Returns:
    the original value

### postDecrement

    public long postDecrement(long c)

  Decrement the value by c, and return the original value.

  Parameters:
    `c` - the amount to decrement the counter by
  Returns:
    the original value

### getCount

    public abstract long getCount()

  Return the current value of the counter.

  Returns:
    the current value

### setCount

    public abstract boolean setCount(long cAssume,
                                     long cNew)

  Update the current value, only if it is equal to the assumed value.

  Parameters:
    `cAssume` - the assumed old value
    `cNew` - the new value
  Returns:
    true if the value was updated, false otherwise

### setCount

    public abstract long setCount(long cNew)

  Update the current value, and return the previous value.

  Parameters:
    `cNew` - the new value
  Returns:
    the previous value just before the update went through

### toString

    public java.lang.String toString()

  Return the count as a string.

  Returns:
    a string represenation of the count

### adjust

    protected abstract long adjust(long c)

  Adjust the value of the counter by the specified amount, and return the new value.

  Parameters:
    `c` - the amount to adjust the counter by
  Returns:
    the new value, after the adjustment has been made

### postAdjust

    protected abstract long postAdjust(long c)

  Adjust the value of the counter by the specified amount, and return the old value.

  Parameters:
    `c` - the amount to adjust the counter by
  Returns:
    the old value, prior to the adjustment having been made

### newAtomicCounter

    public static AtomicCounter newAtomicCounter()

  Instantiate and return a new AtomicCounter. The underlying implementation be choosen based on the JVM.

  Returns:
    a new AtomicCounter with a count of zero

### newAtomicCounter

    public static AtomicCounter newAtomicCounter(long l)

  Instantiate and return a new AtomicCounter initialized to a particular value.

  Parameters:
    `l` - the initial counter value
  Returns:
    a new AtomicCounter with the specified counter value

Overview | Package | Class | Tree | Index | Help

Oracle® Coherence Java API Reference
v3.5.3
E15583-01
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000, 2010, Oracle. All rights reserved.