public BlockMemory(BigChunk chunk, int cIndex, int cSize) { this.chunk = chunk; chunkIndex = cIndex; chunkSize = cSize; memory = new Memory <byte>(chunk.data, chunkSize * chunkIndex + chunk.padding, chunkSize); }
public BlockMemory Rent() { lock (this) { foreach (BigChunk chunk in datablocks) { if (chunk.HasFreeBlocks()) { int index = chunk.Reserve(); BlockMemory memory = new BlockMemory(chunk, index, NumBytes); return(memory); } } BigChunk newChunk = new BigChunk(numKB, bigChunkSizeKb / numKB); datablocks.Add(newChunk); int i = newChunk.Reserve(); BlockMemory m = new BlockMemory(newChunk, i, NumBytes); return(m); } }