Class AtomicCounterLong
An atomic 64 bit integer counter.
Implements
Inherited Members
Namespace: Akka.Util.Internal
Assembly: Akka.dll
Syntax
public class AtomicCounterLong : IAtomicCounter<long>
Constructors
| Improve this Doc View SourceAtomicCounterLong()
Creates an instance of an AtomicCounterLong with a starting value of -1.
Declaration
public AtomicCounterLong()
AtomicCounterLong(Int64)
Creates an instance of an AtomicCounterLong.
Declaration
public AtomicCounterLong(long value)
Parameters
Type | Name | Description |
---|---|---|
Int64 | value | The initial value of this counter. |
Properties
| Improve this Doc View SourceCurrent
Retrieves the current value of the counter
Declaration
public long Current { get; }
Property Value
Type | Description |
---|---|
Int64 |
Methods
| Improve this Doc View SourceAddAndGet(Int64)
Adds an amount to the counter and returns the new value.
Declaration
public long AddAndGet(long amount)
Parameters
Type | Name | Description |
---|---|---|
Int64 | amount | The amount to add to the counter. |
Returns
Type | Description |
---|---|
Int64 | The new counter value. |
Remarks
This uses a CAS loop as Interlocked.Increment is not atomic for longs on 32bit systems.
CompareAndSet(Int64, Int64)
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(long expected, long newValue)
Parameters
Type | Name | Description |
---|---|---|
Int64 | expected | TBD |
Int64 | newValue | TBD |
Returns
Type | Description |
---|---|
Boolean | TBD |
DecrementAndGet()
Atomically decrements the counter by one
Declaration
public long DecrementAndGet()
Returns
Type | Description |
---|---|
Int64 | The new value |
GetAndAdd(Int64)
Gets the current value of the counter and adds an amount to it.
Declaration
public long GetAndAdd(long amount)
Parameters
Type | Name | Description |
---|---|---|
Int64 | amount | The amount to add to the counter. |
Returns
Type | Description |
---|---|
Int64 | The original value. |
Remarks
This uses a CAS loop as Interlocked.Increment is not atomic for longs on 32bit systems.
GetAndIncrement()
Atomically increments the counter by one.
Declaration
public long GetAndIncrement()
Returns
Type | Description |
---|---|
Int64 | The original value. |
GetAndSet(Int64)
Returns current counter value and sets a new value on it's place in one operation.
Declaration
public long GetAndSet(long value)
Parameters
Type | Name | Description |
---|---|---|
Int64 | value | TBD |
Returns
Type | Description |
---|---|
Int64 | TBD |
IncrementAndGet()
Atomically increments the counter by one.
Declaration
public long IncrementAndGet()
Returns
Type | Description |
---|---|
Int64 | The new value. |
Next()
Increments the counter and returns the next value.
Declaration
public long Next()
Returns
Type | Description |
---|---|
Int64 | TBD |
Reset()
Resets the counter to zero.
Declaration
public void Reset()
ToString()
TBD
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
String | TBD |