Skip to main content

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

TypeDescription
int32The 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

NameTypeDescription
oldint32The expected current value for the comparison.
newint32The new value to set if the comparison succeeds.

Returns

TypeDescription
boolTrue 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

NameTypeDescription
deltaint32The integer value to add to the current value.

Returns

TypeDescription
int32The 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

NameTypeDescription
deltaint32The integer value to subtract from the current value.

Returns

TypeDescription
int32The 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

TypeDescription
int32The 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

TypeDescription
int32The 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

NameTypeDescription
vint32The integer value to store.