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
| Edit this page View SourceAtomicCounterLong()
Creates an instance of an AtomicCounterLong with a starting value of -1.
Declaration
public AtomicCounterLong()
AtomicCounterLong(long)
Creates an instance of an AtomicCounterLong.
Declaration
public AtomicCounterLong(long value)
Parameters
| Type | Name | Description |
|---|---|---|
| long | value | The initial value of this counter. |
Properties
| Edit this page View SourceCurrent
Retrieves the current value of the counter
Declaration
public long Current { get; }
Property Value
| Type | Description |
|---|---|
| long |
Methods
| Edit this page View SourceAddAndGet(long)
Adds an amount to the counter and returns the new value.
Declaration
public long AddAndGet(long amount)
Parameters
| Type | Name | Description |
|---|---|---|
| long | amount | The amount to add to the counter. |
Returns
| Type | Description |
|---|---|
| long | The new counter value. |
Remarks
This uses a CAS loop as Interlocked.Increment is not atomic for longs on 32bit systems.
CompareAndSet(long, long)
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 |
|---|---|---|
| long | expected | TBD |
| long | newValue | TBD |
Returns
| Type | Description |
|---|---|
| bool | TBD |
DecrementAndGet()
Atomically decrements the counter by one
Declaration
public long DecrementAndGet()
Returns
| Type | Description |
|---|---|
| long | The new value |
GetAndAdd(long)
Gets the current value of the counter and adds an amount to it.
Declaration
public long GetAndAdd(long amount)
Parameters
| Type | Name | Description |
|---|---|---|
| long | amount | The amount to add to the counter. |
Returns
| Type | Description |
|---|---|
| long | 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 |
|---|---|
| long | The original value. |
GetAndSet(long)
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 |
|---|---|---|
| long | value | TBD |
Returns
| Type | Description |
|---|---|
| long | TBD |
IncrementAndGet()
Atomically increments the counter by one.
Declaration
public long IncrementAndGet()
Returns
| Type | Description |
|---|---|
| long | The new value. |
Next()
Increments the counter and returns the next value.
Declaration
public long Next()
Returns
| Type | Description |
|---|---|
| long | TBD |
Reset()
Resets the counter to zero.
Declaration
public void Reset()
ToString()
TBD
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| string | TBD |
Edit this page