primitive-atomic-0.1.0.0: Wrappers for primops around atomic operations

Safe HaskellNone
LanguageHaskell2010

Data.Primitive.PrimArray.Atomic

Synopsis

Documentation

casPrimArray Source #

Arguments

:: (PrimMonad m, PrimMach a) 
=> MutablePrimArray (PrimState m) a

prim array

-> Int

index

-> a

expected old value

-> a

new value

-> m a 

Given an array, an offset in Int units, the expected old value, and the new value, perform an atomic compare and swap i.e. write the new value if the current value matches the provided old value. Returns the value of the element before the operation. Implies a full memory barrier.

fetchAddPrimArray Source #

Arguments

:: (PrimMonad m, PrimMach a) 
=> MutablePrimArray (PrimState m) a 
-> Int

index

-> a

value to add to the element

-> m a 

Given an array, and offset in Int units, and a value to add, atomically add the value to the element. Returns the value of the element before the operation. Implies a full memory barrier.

fetchSubPrimArray Source #

Arguments

:: (PrimMonad m, PrimMach a) 
=> MutablePrimArray (PrimState m) a 
-> Int

index

-> a

value to subtract from the element

-> m a 

Given an array, and offset in Int units, and a value to subtract, atomically subtract the value to the element. Returns the value of the element before the operation. Implies a full memory barrier.

fetchAndPrimArray Source #

Arguments

:: (PrimMonad m, PrimMach a) 
=> MutablePrimArray (PrimState m) a 
-> Int

index

-> a

value to AND with the element

-> m a 

Given an array, and offset in Int units, and a value to AND, atomically AND the value to the element. Returns the value of the element before the operation. Implies a full memory barrier.

fetchNandPrimArray Source #

Arguments

:: (PrimMonad m, PrimMach a) 
=> MutablePrimArray (PrimState m) a 
-> Int

index

-> a

value to NAND with the element

-> m a 

Given an array, and offset in Int units, and a value to NAND, atomically NAND the value to the element. Returns the value of the element before the operation. Implies a full memory barrier.

fetchOrPrimArray Source #

Arguments

:: (PrimMonad m, PrimMach a) 
=> MutablePrimArray (PrimState m) a 
-> Int

index

-> a

value to OR with the element

-> m a 

Given an array, and offset in Int units, and a value to OR, atomically OR the value to the element. Returns the value of the element before the operation. Implies a full memory barrier.

fetchXorPrimArray Source #

Arguments

:: (PrimMonad m, PrimMach a) 
=> MutablePrimArray (PrimState m) a 
-> Int

index

-> a

value to XOR with the element

-> m a 

Given an array, and offset in Int units, and a value to XOR, atomically XOR the value to the element. Returns the value of the element before the operation. Implies a full memory barrier.