public ref T Allocate(BufferPool pool, out int index) { index = Ids.Take(); if (Caches.Length < index) { pool.SpecializeFor <T>().Resize(ref Caches, index, Caches.Length); } return(ref Caches[index]); }
public ref T CreateContinuation(int slotsInContinuation, BufferPool pool, out int index) { if (!Continuations.Allocated) { Debug.Assert(!IdPool.Allocated); //Lazy initialization. pool.TakeAtLeast(InitialCapacity, out Continuations); IdPool = new IdPool(InitialCapacity, pool); } index = IdPool.Take(); if (index >= Continuations.Length) { pool.ResizeToAtLeast(ref Continuations, index + 1, index); } ref var continuation = ref Continuations[index];
public ref T CreateContinuation(int slotsInContinuation, BufferPool pool, out int index) { if (!Continuations.Allocated) { Debug.Assert(!IdPool.Allocated); //Lazy initialization. pool.Take(InitialCapacity, out Continuations); IdPool <Buffer <int> > .Create(pool.SpecializeFor <int>(), InitialCapacity, out IdPool); } index = IdPool.Take(); if (index >= Continuations.Length) { pool.Resize(ref Continuations, index + 1, index); } ref var continuation = ref Continuations[index];