Writing to the same native container from diferent jobs, diferent indexes

I have a nativearray and i want to create 2 jobs to spread the workload, can i write to the same nativearray from 2 IJobs?

The indexes il be accessing are different so there’s no overlap.

for example, 1 job would go from 0 to 40000, and the other from 40001 to 80000.

Specifically for IJob, i don’t want to use IJopparallelfor if possible.

You can use NativeDisableContainerSafetyRestrictionAttribute for multiple jobs.

If you’re doing the same work in both jobs, you can use an array length of 2 and inner loop batch count of 1 with IJobParallelFor or IJobFor using ScheduleParallel and use NativeDisableParallelForRestrictionAttribute to allow using any indices in the arrays. You’d use the index (0 or 1) to determine which range you want to process.

2 Likes

If you’re doing the same work in both jobs, you can use an array length of 2 and inner loop batch count of 1 with IJobParallelFor or IJobFor using ScheduleParallel and use NativeDisableParallelForRestrictionAttribute to allow using any indices in the arrays. You’d use the index (0 or 1) to determine which range you want to process.

That is a cool idea, il think about this one thanks!