public ThreadPool() { started = false; // If the number of threads is not correctly specified, create as many as possible minus one (taking // all available core is not effective - there's still the main thread we should not forget). // Allways create at least one thread, however. int threadCnt = Features.useThreadPool ? Mathf.Max(Environment.ProcessorCount - 1, 1) : 1; pools = Helpers.CreateArray1D <TaskPool>(threadCnt); // NOTE: Normally, I would simply call CreateAndInitArray1D, however, any attempt to allocate memory // for TaskPool in this contructor ends up with Unity3D crashing :( }
public ArrayPool(int length, int initialCapacity, int initialSize) { arrLength = length; if (initialSize > 0) { // Init arrays = new Stack <T[]>(initialSize < initialCapacity ? initialCapacity : initialSize); for (int i = 0; i < initialSize; ++i) { T[] item = Helpers.CreateArray1D <T>(length); arrays.Push(item); } } else { // Init arrays = new Stack <T[]>(initialCapacity); } }
public CircularArray1D(int width) { Offset = 0; items = Helpers.CreateArray1D <T>(width); }