示例#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;
 }