The SKIRT project
advanced radiative transfer for astrophysics
Functions
LockFree Namespace Reference

Functions

void add (double &target, double value)
 

Detailed Description

This namespace contains functions that support lock-free programming in a multi-threaded shared memory environment. All implementations are provided inline in the header.

Function Documentation

◆ add()

void LockFree::add ( double &  target,
double  value 
)
inline

This function adds the specified double value (which can be an expression) to the specified target variable (passed as a reference to a memory location) in a thread-safe manner. The function avoids race conditions between concurrent threads by implementing a classical compare and swap (CAS) loop using the corresponding atomic operation on the target memory location.