#How do you schedule a IJobFor using the Length of a NativeList populated by another job
1 messages · Page 1 of 1 (latest)
you use IJobParallelForDefer instead
and pass the list into the schedule instead of the length
Where do you find that?
I don't see it in Jobs or Collections
it's in collections package now
it was previously in the standalone jobs package but htats been removed
and merged into collections
Wait what version of Unity is that. I am only seeing Collections 1.2.4 in the package manager in 2022.2. I don't see a 2.1.4
are you on entities like 0.51 or something?
Ahh, I see it. Thanks @dusky dawn! I see it also takes a pointer to a int. Is there a way to use the NativeList.Length with it? Like doing NativeList.Length / 2?
you just pass in nativelist
I know, I am asking if there is a way to instead use the length
your problem is you don't know what the length is
How do you schedule a IJobFor using the Length of a NativeList populated by another job
this is exactly what it does
it reads the length once the job starts
not when you schedule it
so the previous job will have finished populating it and it will use the right length value
I mean that there are cases where I don't want to have the job do exactly the same number as there are elements in the list. Instead doing like 50% of the size of the list.
i can't think of any way you could do that
without causing a sync
i guess
insert a job between the 2 and resize the lenght 😄
Hmm, looks like it uses NativeListUnsafeUtility.GetInternalListDataPtrUnchecked(ref list) to get the count, and the int* produces the same thing with var forEachListPtr = (byte*)forEachCount - sizeof(void*);
So looks like there might be a way... maybe... but this is too deep in to the pointer rabbit hole for my current knowlage haha
i don't really understand how the code you posted there would help
you could allocate a pointer randomly and give it a value
but at that point you're doing nothing different than just ijobfor