Search Unity

Question Scheduling IJobFor jobs reading AsDeferredJobArray

Discussion in 'C# Job System' started by felbj694, May 8, 2023.

  1. felbj694

    felbj694

    Joined:
    Oct 23, 2016
    Posts:
    35
    I know that you can populate a NativeList in a first job. Then in a second job that is depending on the first job read the list. The lists size is unknown at schedule time so you need to use AsDeferredJobArray when passing the list/array into the second job.
    This is working, in the execute of the second job the array length is correct.

    But if I want to have the second job as an IJobFor, to be able to e.g. schedule the job as parallel i need to provide the Schedule function with an array size, which wont work since it is not known at schedule time... and the deferred array size is always 0 at scheduled time so it cant be used.

    I have read about a Schedule signature that uses a list as first argument instead of array size. But that seems to have been deprecated many versions ago?

    I am using Unity 2022.2.11 with unity.collections 1.2.4
     
  2. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    4,270
    Use IJobParallelForDefer.
     
  3. felbj694

    felbj694

    Joined:
    Oct 23, 2016
    Posts:
    35
    That has also been removed as far as i can see...?
    I see some references to it in the jobs package, but since the jobs package is replaced with the collections package i cant find it anymore.
     
  4. felbj694

    felbj694

    Joined:
    Oct 23, 2016
    Posts:
    35
    I had to manually add com.unity.collections by name using to plus sign in the package manager, I then got collections 1.4.0 . The collections package i got per default from the package manager was apparently missing stuff.