Represents an atomic integer that provides thread-safe operations. More...
Public Member Functions | |
AtomicInt (int value) | |
Initializes a new instance of the AtomicInt struct with the specified value. More... | |
int | CompareExchange (int value, int assumed) |
Compares the current value with a specified value and, if they are equal, replaces the current value. More... | |
int | Decrement () |
Atomically decrements the current value by one and returns the decremented value. More... | |
int | Exchange (int value) |
Atomically sets the value to the specified value and returns the original value. More... | |
int | IncrementPost () |
Atomically increments the current value by one and returns the original value. More... | |
int | IncrementPre () |
Atomically increments the current value by one and returns the incremented value. More... | |
Public Attributes | |
volatile int | _value |
The underlying value of the atomic integer. More... | |
Properties | |
int | Value [get] |
Gets the current value of the atomic integer. More... | |
Represents an atomic integer that provides thread-safe operations.
AtomicInt | ( | int | value | ) |
Initializes a new instance of the AtomicInt struct with the specified value.
value | The initial value of the atomic integer. |
int CompareExchange | ( | int | value, |
int | assumed | ||
) |
Compares the current value with a specified value and, if they are equal, replaces the current value.
value | The value to set if the comparison succeeds. |
assumed | The value to compare to the current value. |
int Decrement | ( | ) |
Atomically decrements the current value by one and returns the decremented value.
int Exchange | ( | int | value | ) |
Atomically sets the value to the specified value and returns the original value.
value | The value to set. |
int IncrementPost | ( | ) |
Atomically increments the current value by one and returns the original value.
int IncrementPre | ( | ) |
Atomically increments the current value by one and returns the incremented value.
volatile int _value |
The underlying value of the atomic integer.
|
get |
Gets the current value of the atomic integer.