Class AtomicCounter
Abstract base class for AtomicCounters.
Inherited Members
Namespace: Tangosol.Util
Assembly: Coherence.dll
Syntax
public abstract class AtomicCounter
Remarks
The AtomicCounter allows for atomic updates to a "long" value where possible without requiring synchronization. The underlying AtomicCounter implementation will be choosen at runtime.
Default implementation used in .NET 2.0 is InterlockedCounter, while in .NET 1.1 we have to fall back to a SynchronizedCounter.Methods
Adjust(long)
Adjust the value of the counter by the specified amount, and return the new value.
Declaration
protected abstract long Adjust(long c)
Parameters
| Type | Name | Description |
|---|---|---|
| long | c | The amount to adjust the counter by. |
Returns
| Type | Description |
|---|---|
| long | The new value, after the adjustment has been made. |
Decrement()
Decrement the value, and return the new value.
Declaration
public long Decrement()
Returns
| Type | Description |
|---|---|
| long | The new value. |
Decrement(long)
Decrement the value by c, and return the new value.
Declaration
public long Decrement(long c)
Parameters
| Type | Name | Description |
|---|---|---|
| long | c | The amount to decrement the counter by. |
Returns
| Type | Description |
|---|---|
| long | The new value. |
GetCount()
Return the current value of the counter.
Declaration
public abstract long GetCount()
Returns
| Type | Description |
|---|---|
| long | The current value. |
Increment()
Increment the value, and return the new value.
Declaration
public long Increment()
Returns
| Type | Description |
|---|---|
| long | The new value. |
Increment(long)
Incremenet the value by c, and return the new value.
Declaration
public long Increment(long c)
Parameters
| Type | Name | Description |
|---|---|---|
| long | c | The amount to increment the counter by. |
Returns
| Type | Description |
|---|---|
| long | The new value. |
NewAtomicCounter()
Instantiate and return a new AtomicCounter.
Declaration
public static AtomicCounter NewAtomicCounter()
Returns
| Type | Description |
|---|---|
| AtomicCounter | A new AtomicCounter with a count of zero. |
NewAtomicCounter(long)
Instantiate and return a new AtomicCounter initialized to a particular value.
Declaration
public static AtomicCounter NewAtomicCounter(long count)
Parameters
| Type | Name | Description |
|---|---|---|
| long | count | The initial counter value. |
Returns
| Type | Description |
|---|---|
| AtomicCounter | A new AtomicCounter with the specified counter value. |
PostAdjust(long)
Adjust the value of the counter by the specified amount, and return the old value.
Declaration
protected abstract long PostAdjust(long c)
Parameters
| Type | Name | Description |
|---|---|---|
| long | c | The amount to adjust the counter by. |
Returns
| Type | Description |
|---|---|
| long | The old value, prior to the adjustment having been made. |
PostDecrement()
Decrement the value, and return the original value.
Declaration
public long PostDecrement()
Returns
| Type | Description |
|---|---|
| long | The original value. |
PostDecrement(long)
Decrement the value by c, and return the original value.
Declaration
public long PostDecrement(long c)
Parameters
| Type | Name | Description |
|---|---|---|
| long | c | The amount to decrement the counter by. |
Returns
| Type | Description |
|---|---|
| long | The original value. |
PostIncrement()
Incremenet the value, and return the original value.
Declaration
public long PostIncrement()
Returns
| Type | Description |
|---|---|
| long | The original value. |
PostIncrement(long)
Incremenet the value by c, and return the original value.
Declaration
public long PostIncrement(long c)
Parameters
| Type | Name | Description |
|---|---|---|
| long | c | The amount to increment the counter by. |
Returns
| Type | Description |
|---|---|
| long | The original value. |
SetCount(long)
Update the current value, and return the previous value.
Declaration
public abstract long SetCount(long newValue)
Parameters
| Type | Name | Description |
|---|---|---|
| long | newValue | The new value. |
Returns
| Type | Description |
|---|---|
| long | The previous value just before the update went through. |
SetCount(long, long)
Update the current value, only if it is equal to the assumed value.
Declaration
public abstract bool SetCount(long assumedValue, long newValue)
Parameters
| Type | Name | Description |
|---|---|---|
| long | assumedValue | The assumed old value. |
| long | newValue | The new value. |
Returns
| Type | Description |
|---|---|
| bool | true if the value was updated, false otherwise. |
ToString()
Return the count as a string.
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| string | A string represenation of the count. |