C# Interlocked to Pointers
I'm using C# but I'm working with Unmanaged memory to aviod the GC to move the memory and increase performance ( so no fixed) for certain buffers. Only way I found to apply Interlocked operations to C# pointers is through but it has a really bad performance
In C++ we have functions like
long atomic_fetch_add(long * dest, long val)
or I can find in the Windows libraries functions like
LONG InterlockedAdd(LONG volatile *Addend, LONG Value);
but I coudn't find any PInvoke that allows a direct call to an Atomic operation using a pointer resulting in a call with way better performance. C# will produce a poor performance call.
Any thoughts on how to be able to use a low level Interlocked, so I could to something like
Interlocked.Increment(pointer) so it accepts my pointer and not a C# ref.