Photon Fusion 2.0.3

Public Member Functions | Public Attributes | Properties | List of all members
AtomicInt Struct Reference

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...
 

Detailed Description

Represents an atomic integer that provides thread-safe operations.

Constructor & Destructor Documentation

◆ AtomicInt()

AtomicInt ( int  value)

Initializes a new instance of the AtomicInt struct with the specified value.

Parameters
valueThe initial value of the atomic integer.

Member Function Documentation

◆ 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
valueThe value to set if the comparison succeeds.
assumedThe value to compare to the current value.
Returns
The original value before the comparison.

◆ Decrement()

int 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
valueThe value to set.
Returns
The original value before the exchange.

◆ IncrementPost()

int IncrementPost ( )

Atomically increments the current value by one and returns the original value.

Returns
The original value before the increment.

◆ IncrementPre()

int IncrementPre ( )

Atomically increments the current value by one and returns the incremented value.

Returns
The incremented value.

Member Data Documentation

◆ _value

volatile int _value

The underlying value of the atomic integer.

Property Documentation

◆ Value

int Value
get

Gets the current value of the atomic integer.