Say we have a parallel job (implementing IJobParallelFor
) which requires a large array (>100,000 items) as an input to do some complicated processing. After said job is finished, I'd like to return a portion of those items that have passed certain checks.
Specifically, I'd like to check if >100,000 Vector3's satisfy a certain criteria. If they do, I'd like to add them to a list so that I can continue operating on that data in the main thread (or in other jobs).
The issue is that we can't use a NativeList to call .Add() because that data structure doesn't support parallel writing. It is also not viable to use a NativeArray because it requires its size to be initialized ahead of time, and we don't know how many items we are going to return.
What is a good way to solve this problem?