Пример #1
0
    public unsafe void Reset()
    {
        HolderData *holderData = (HolderData *)Data;
        InnerData * data       = (InnerData *)holderData->InnerData;

        Interlocked.Exchange(ref data->Integer, -1);
    }
Пример #2
0
    public unsafe int Get()
    {
        HolderData *holderData = (HolderData *)Data;
        InnerData * data       = (InnerData *)holderData->InnerData;

        return(Interlocked.Exchange(ref data->Integer, data->Integer));
    }
Пример #3
0
    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);
    }
Пример #4
0
    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);
    }