Пример #1
0
 public PoolBlock(int size, int id, INativePool pool, PoolBlock prev)
 {
     Address  = Marshal.AllocHGlobal(size);
     Id       = id;
     Pool     = pool;
     Previous = prev;
 }
Пример #2
0
        void MakeBlock()
        {
            int blockSize = numBlockElems * objSize;
            int id        = tail?.Id + 1 ?? 0;

            tail = new PoolBlock(blockSize, id, this, tail);

            for (int i = 0; i < numBlockElems; i++)
            {
                tmpEnts[i] = new PoolEntry(tail, i);
            }
            free.PutAll(tmpEnts);
        }
Пример #3
0
        public NativePool(int numBlockElems = 0x100, int numInitialBlocks = 1)
        {
            this.numBlockElems = numBlockElems;
            free     = new Heap <PoolEntry>();
            sync     = new ReaderWriterLockSlim();
            tmpEnts  = new PoolEntry[numBlockElems];
            tail     = null;
            disposed = false;

            while (numInitialBlocks-- > 0)
            {
                MakeBlock();
            }
        }
Пример #4
0
 public PoolEntry(PoolBlock block, int index)
 {
     Block = block;
     Index = index;
 }