I've got a ConcurrentQueue<Vector3[]>
that I'm filling up and I want to read out of it in chunks for the sake of performance.
private ConcurrentQueue<Vector3[]> positionsQueue = new ConcurrentQueue<Vector3[]>();
For example I want to wait until there's 20 Vector3[]s in queue and then read them as a single, continous array (I need the data to be simplified to a single Vector3[] as I'm passing it to a buffer later on). I am looking for a better method than looping, like a memory copy or sth similar. I tried using CopyTo()
that copies queue contents into 2D array, but then I still need to convert 2D array to a merged 1D array.
Vector3[][] positionsFromQueue = new Vector3[positionsQueue.Count][];
positionsQueue.CopyTo(positionsFromQueue, 0);
Vector3[] mergedResult = ???
Tried using System.Buffer.BlockCopy
, but I don't think I'm able to achieve what I want with that.
What else could I try to get a merged 1D vector and make this process' performance reasonable?
(btw I'm working in Unity, but asking this questions as a generic C# problem)