Advice on using unsafe_wrap to view integers as atomic integers

If you want to manipulate integers in an array atomically, see https://github.com/tkf/TSXPlayground.jl/blob/master/src/UnsafeAtomics.jl and its usage. Not sure how much of this is “legal” though.

unsafe_wrap(Vector{Atomic{Int32}}, pointer(::Vector{Int32}), _) doesn’t work because it means interpreting two consecutive Int32s as a pointer to the memory location of the mutable struct Atomic{Int32} (assuming 64 bit machine).

1 Like