Difference between revisions of "Atomic Variable Operations"

From OpenGL Wiki
Jump to navigation Jump to search
(formatting.)
(Clarification)
 
Line 31: Line 31:
 
{{funcdef|''n''int atomicCompSwap(inout ''n''int {{param|mem}}, ''n''int {{param|compare}}, ''n''int {{param|data}})}}
 
{{funcdef|''n''int atomicCompSwap(inout ''n''int {{param|mem}}, ''n''int {{param|compare}}, ''n''int {{param|data}})}}
  
If the current value of {{param|mem}} is equal to {{param|compare}}, then {{param|mem}} is set to {{param|data}}.
+
If the current value of {{param|mem}} is equal to {{param|compare}}, then {{param|mem}} is set to {{param|data}}. Otherwise it is left unchanged.

Latest revision as of 04:24, 24 January 2013

All of the atomic functions return the original value. The term "nint" can be int or uint.

nint atomicAdd(inout nint mem​, nint data​)

Adds data​ to mem​.

nint atomicMin(inout nint mem​, nint data​)

The mem​'s value is no lower than data​.

nint atomicMax(inout nint mem​, nint data​)

The mem​'s value is no greater than data​.

nint atomicAnd (inout nint mem​, nint data​)

mem​ becomes the bitwise-and between mem​ and data​.

nint atomicOr(inout nint mem​, nint data​)

mem​ becomes the bitwise-or between mem​ and data​.

nint atomicXor(inout nint mem​, nint data​)

mem​ becomes the bitwise-xor between mem​ and data​.

nint atomicExchange(inout nint mem​, nint data​)

Sets mem​'s value to data​.

nint atomicCompSwap(inout nint mem​, nint compare​, nint data​)

If the current value of mem​ is equal to compare​, then mem​ is set to data​. Otherwise it is left unchanged.