Class AtomicCounter
An atomic 32 bit integer counter.
Implements
Inherited Members
Namespace: Akka.Util.Internal
Assembly: Akka.dll
Syntax
public class AtomicCounter : IAtomicCounter<int>
Constructors
| Edit this page View SourceAtomicCounter()
Creates an instance of an AtomicCounter with a starting value of -1.
Declaration
public AtomicCounter()
AtomicCounter(int)
Creates an instance of an AtomicCounter.
Declaration
public AtomicCounter(int initialValue)
Parameters
| Type | Name | Description |
|---|---|---|
| int | initialValue | The initial value of this counter. |
Properties
| Edit this page View SourceCurrent
Retrieves the current value of the counter
Declaration
public int Current { get; }
Property Value
| Type | Description |
|---|---|
| int |
Methods
| Edit this page View SourceAddAndGet(int)
Adds the specified value to the counter and returns the new value.
Declaration
public int AddAndGet(int amount)
Parameters
| Type | Name | Description |
|---|---|---|
| int | amount | The amount to add to the counter. |
Returns
| Type | Description |
|---|---|
| int | The new value after additions. |
CompareAndSet(int, int)
Compares current counter value with provided expected value,
and sets it to newValue if compared values where equal.
Returns true if replacement has succeed.
Declaration
public bool CompareAndSet(int expected, int newValue)
Parameters
| Type | Name | Description |
|---|---|---|
| int | expected | TBD |
| int | newValue | TBD |
Returns
| Type | Description |
|---|---|
| bool | TBD |
Decrement()
Decrements the counter and returns the next value
Declaration
public int Decrement()
Returns
| Type | Description |
|---|---|
| int | TBD |
DecrementAndGet()
Atomically decrements the counter by one.
Declaration
public int DecrementAndGet()
Returns
| Type | Description |
|---|---|
| int | The new value. |
GetAndAdd(int)
Returns the current value and adds the specified value to the counter.
Declaration
public int GetAndAdd(int amount)
Parameters
| Type | Name | Description |
|---|---|---|
| int | amount | The amount to add to the counter. |
Returns
| Type | Description |
|---|---|
| int | The original value before additions. |
GetAndDecrement()
Atomically decrements the counter by one.
Declaration
public int GetAndDecrement()
Returns
| Type | Description |
|---|---|
| int | The original value. |
GetAndIncrement()
Atomically increments the counter by one.
Declaration
public int GetAndIncrement()
Returns
| Type | Description |
|---|---|
| int | The original value. |
GetAndSet(int)
Returns current counter value and sets a new value on it's place in one operation.
Declaration
public int GetAndSet(int value)
Parameters
| Type | Name | Description |
|---|---|---|
| int | value | TBD |
Returns
| Type | Description |
|---|---|
| int | TBD |
IncrementAndGet()
Atomically increments the counter by one.
Declaration
public int IncrementAndGet()
Returns
| Type | Description |
|---|---|
| int | The new value. |
Next()
Increments the counter and returns the next value
Declaration
public int Next()
Returns
| Type | Description |
|---|---|
| int | TBD |
Reset()
Resets the counter to zero.
Declaration
public void Reset()
Edit this page