Represents an atomic integer that provides thread-safe operations.
More...
|
| | AtomicInt (int value) |
| | Initializes a new instance of the AtomicInt struct with the specified value.
|
| int | CompareExchange (int value, int assumed) |
| | Compares the current value with a specified value and, if they are equal, replaces 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.
|
| 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.
|
|
|
int | Value [get] |
| | Gets the current value of the atomic integer.
|
Represents an atomic integer that provides thread-safe operations.
◆ AtomicInt()
Initializes a new instance of the AtomicInt struct with the specified value.
- Parameters
-
| value | The initial value of the atomic integer. |
◆ CompareExchange()
| int CompareExchange |
( |
int | value, |
|
|
int | assumed ) |
Compares the current value with a specified value and, if they are equal, replaces the current value.
- Parameters
-
| value | The value to set if the comparison succeeds. |
| assumed | The value to compare to the current value. |
- Returns
- The original value before the comparison.
◆ Decrement()
Atomically decrements the current value by one and returns the decremented value.
- Returns
- The decremented value.
◆ Exchange()
| int Exchange |
( |
int | value | ) |
|
Atomically sets the value to the specified value and returns the original value.
- Parameters
-
- Returns
- The original value before the exchange.
◆ IncrementPost()
Atomically increments the current value by one and returns the original value.
- Returns
- The original value before the increment.
◆ IncrementPre()
Atomically increments the current value by one and returns the incremented value.
- Returns
- The incremented value.