Class AtomicInteger
A integer that can be operatered on atomically.
Inheritance
System.Object
AtomicInteger
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ToString()
System.Object.ReferenceEquals(System.Object, System.Object)
Namespace: FM.LiveSwitch
Assembly: FM.LiveSwitch.dll
Syntax
public class AtomicInteger
Constructors
AtomicInteger()
Create a new AtomicInteger with a initial value of 0.
Declaration
public AtomicInteger()
AtomicInteger(Int32)
Create a new AtomicInteger with an initial value.
Declaration
public AtomicInteger(int initialValue)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | initialValue |
Properties
Value
Gets the current value.
Declaration
public int Value { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Methods
Add(Int32)
Atomically add a integer to the value.
Declaration
public int Add(int delta)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | delta | The amount to add. |
Returns
Type | Description |
---|---|
System.Int32 |
CompareAndSwap(Int32, Int32)
Compares two 32-bit signed integers for equality and, if they are equal, replaces one of the values.
Declaration
public int CompareAndSwap(int expected, int newValue)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | expected | The value to compare. |
System.Int32 | newValue | The value used to replace. |
Returns
Type | Description |
---|---|
System.Int32 | The original value. |
Decrement()
Atomically decrement the value by 1.
Declaration
public int Decrement()
Returns
Type | Description |
---|---|
System.Int32 | The value decremented by one. |
Increment()
Atomically increment the value by 1.
Declaration
public int Increment()
Returns
Type | Description |
---|---|
System.Int32 | The value incremented by 1. |
Subtract(Int32)
Atomically subtract a integer to the value.
Declaration
public int Subtract(int delta)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | delta | The amount to subtract. |
Returns
Type | Description |
---|---|
System.Int32 |