Int32
No overview available.
Methods
Load()
@classmethod
def Load() - > int32
Loads the current value of the Int32. Callers use this to retrieve the integer value stored in the object.
Returns
| Type | Description |
|---|---|
int32 | The current integer value. |
CompareAndSwap()
@classmethod
def CompareAndSwap(
old: int32,
new: int32
) - > bool
Atomically compares the current value with 'old' and, if they are equal, replaces the current value with 'new'. This is used for thread-safe updates where a value should only be changed if it matches an expected state.
Parameters
| Name | Type | Description |
|---|---|---|
| old | int32 | The expected current value for the comparison. |
| new | int32 | The new value to set if the comparison succeeds. |
Returns
| Type | Description |
|---|---|
bool | True if the swap occurred (i.e., the current value matched 'old'), false otherwise. |
Add()
@classmethod
def Add(
delta: int32
) - > int32
Atomically adds 'delta' to the current value and returns the new value. This is used for thread-safe increments.
Parameters
| Name | Type | Description |
|---|---|---|
| delta | int32 | The integer value to add to the current value. |
Returns
| Type | Description |
|---|---|
int32 | The new integer value after the addition. |
Sub()
@classmethod
def Sub(
delta: int32
) - > int32
Atomically subtracts 'delta' from the current value and returns the new value. This is used for thread-safe decrements.
Parameters
| Name | Type | Description |
|---|---|---|
| delta | int32 | The integer value to subtract from the current value. |
Returns
| Type | Description |
|---|---|
int32 | The new integer value after the subtraction. |
Inc()
@classmethod
def Inc() - > int32
Atomically increments the current value by one and returns the new value. This is a convenience method for adding 1.
Returns
| Type | Description |
|---|---|
int32 | The new integer value after the increment. |
Dec()
@classmethod
def Dec() - > int32
Atomically decrements the current value by one and returns the new value. This is a convenience method for subtracting 1.
Returns
| Type | Description |
|---|---|
int32 | The new integer value after the decrement. |
Store()
@classmethod
def Store(
v: int32
)
Atomically stores the given value 'v' into the Int32. Callers use this to set the integer value in a thread-safe manner.
Parameters
| Name | Type | Description |
|---|---|---|
| v | int32 | The integer value to store. |