public unsafe void Reset() { HolderData *holderData = (HolderData *)Data; InnerData * data = (InnerData *)holderData->InnerData; Interlocked.Exchange(ref data->Integer, -1); }
public unsafe int Get() { HolderData *holderData = (HolderData *)Data; InnerData * data = (InnerData *)holderData->InnerData; return(Interlocked.Exchange(ref data->Integer, data->Integer)); }
private static unsafe void Deallocate(IntPtr data, Allocator alloc) { HolderData *holderData = (HolderData *)data; UnsafeUtility.Free(holderData->InnerData, alloc); holderData->InnerData = IntPtr.Zero; UnsafeUtility.Free(data, alloc); }
public unsafe int Increment() { HolderData *holderData = (HolderData *)Data; InnerData * data = (InnerData *)holderData->InnerData; int current, next; do { current = data->Integer; next = current + 1; } while (Interlocked.CompareExchange(ref data->Integer, next, current) != current); return(next); }