public PoolBlock(int size, int id, INativePool pool, PoolBlock prev) { Address = Marshal.AllocHGlobal(size); Id = id; Pool = pool; Previous = prev; }
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); }
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(); } }
public PoolEntry(PoolBlock block, int index) { Block = block; Index = index; }