Open CASCADE Technology  7.5.0
Functions
Standard_Atomic.hxx File Reference

Implementation of some atomic operations (elementary operations with data that cannot be interrupted by parallel threads in the multithread process) on various platforms. More...

Functions

int Standard_Atomic_Increment (volatile int *theValue)
 Increments atomically integer variable pointed by theValue and returns resulting incremented value. More...
 
int Standard_Atomic_Decrement (volatile int *theValue)
 Decrements atomically integer variable pointed by theValue and returns resulting decremented value. More...
 
bool Standard_Atomic_CompareAndSwap (volatile int *theValue, int theOldValue, int theNewValue)
 Perform an atomic compare and swap. That is, if the current value of *theValue is theOldValue, then write theNewValue into *theValue. More...
 

Detailed Description

Implementation of some atomic operations (elementary operations with data that cannot be interrupted by parallel threads in the multithread process) on various platforms.

By the moment, only operations necessary for reference counter in Standard_Transient objects are implemented.

This is preffered to use fixed size types "int32_t" / "int64_t" for correct function declarations however we leave "int" assuming it is 32bits for now.

Function Documentation

◆ Standard_Atomic_CompareAndSwap()

bool Standard_Atomic_CompareAndSwap ( volatile int *  theValue,
int  theOldValue,
int  theNewValue 
)
inline

Perform an atomic compare and swap. That is, if the current value of *theValue is theOldValue, then write theNewValue into *theValue.

Parameters
theValuepointer to variable to modify
theOldValueexpected value to perform modification
theNewValuenew value to set in case if *theValue was equal to theOldValue
Returns
TRUE if theNewValue has been set to *theValue

◆ Standard_Atomic_Decrement()

int Standard_Atomic_Decrement ( volatile int *  theValue)
inline

Decrements atomically integer variable pointed by theValue and returns resulting decremented value.

◆ Standard_Atomic_Increment()

int Standard_Atomic_Increment ( volatile int *  theValue)
inline

Increments atomically integer variable pointed by theValue and returns resulting incremented value.