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
| Improve this Doc View SourceAtomicCounter()
Creates an instance of an AtomicCounter with a starting value of -1.
Declaration
public AtomicCounter()
AtomicCounter(Int32)
Creates an instance of an AtomicCounter.
Declaration
public AtomicCounter(int initialValue)
Parameters
Type | Name | Description |
---|---|---|
Int32 | initialValue | The initial value of this counter. |
Properties
| Improve this Doc View SourceCurrent
Retrieves the current value of the counter
Declaration
public int Current { get; }
Property Value
Type | Description |
---|---|
Int32 |
Methods
| Improve this Doc View SourceAddAndGet(Int32)
Adds the specified value to the counter and returns the new value.
Declaration
public int AddAndGet(int amount)
Parameters
Type | Name | Description |
---|---|---|
Int32 | amount | The amount to add to the counter. |
Returns
Type | Description |
---|---|
Int32 | The new value after additions. |
CompareAndSet(Int32, Int32)
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 |
---|---|---|
Int32 | expected | TBD |
Int32 | newValue | TBD |
Returns
Type | Description |
---|---|
Boolean | TBD |
Decrement()
Decrements the counter and returns the next value
Declaration
public int Decrement()
Returns
Type | Description |
---|---|
Int32 | TBD |
DecrementAndGet()
Atomically decrements the counter by one.
Declaration
public int DecrementAndGet()
Returns
Type | Description |
---|---|
Int32 | The new value. |
GetAndAdd(Int32)
Returns the current value and adds the specified value to the counter.
Declaration
public int GetAndAdd(int amount)
Parameters
Type | Name | Description |
---|---|---|
Int32 | amount | The amount to add to the counter. |
Returns
Type | Description |
---|---|
Int32 | The original value before additions. |
GetAndDecrement()
Atomically decrements the counter by one.
Declaration
public int GetAndDecrement()
Returns
Type | Description |
---|---|
Int32 | The original value. |
GetAndIncrement()
Atomically increments the counter by one.
Declaration
public int GetAndIncrement()
Returns
Type | Description |
---|---|
Int32 | The original value. |
GetAndSet(Int32)
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 |
---|---|---|
Int32 | value | TBD |
Returns
Type | Description |
---|---|
Int32 | TBD |
IncrementAndGet()
Atomically increments the counter by one.
Declaration
public int IncrementAndGet()
Returns
Type | Description |
---|---|
Int32 | The new value. |
Next()
Increments the counter and returns the next value
Declaration
public int Next()
Returns
Type | Description |
---|---|
Int32 | TBD |
Reset()
Resets the counter to zero.
Declaration
public void Reset()