Пример #1
0
        public T[][] Allocate(int size)
        {
            var ret = new T[][] { new T[size] };

            _events?.Allocate(size);
            return(ret);
        }
Пример #2
0
        public bool TryPush(T buffer)
        {
            if (_buffers.Count >= _maxCount)
            {
                return(false);
            }

            _buffers.Push(buffer);
            _events?.Allocate(_bufferSize);
            return(true);
        }
Пример #3
0
        public BufferPtr Allocate(int size)
        {
            if (size <= 0)
            {
                return(BufferPtr.Zero);
            }

            var ret = Marshal.AllocHGlobal(size);

            _buffers.TryAdd(ret, size);
            _events?.Allocate(size);
            if (_clear)
            {
                UnmanagedAllocator.ClearBuffer(ret, size);
            }

            return(new BufferPtr(ret, size));
        }
Пример #4
0
 public T Add(T buffer)
 {
     _buffers.Add(buffer);
     _events?.Allocate(_bufferSize);
     return(buffer);
 }