Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question about the new job system

Discussion in 'C# Job System' started by R1PFake, Dec 7, 2017.

  1. R1PFake

    R1PFake

    Joined:
    Aug 7, 2015
    Posts:
    533
    Hello, i watched the video about the new job system and i have some questions.


    He said that a job can last multiple frames, but in the example the jobs are started in the DoUpdate method (which i assume is still called every frame?). Wouldn't that mean that the same job could be started again before the previous job is done (if the previous job needs multiple frames to finish)? (With "same job" i mean a job which does the same thing, for example handle raycasting)

    And he said that virtual methods should be avoided yet the DoUpdate method is virtual, can you explain why?
     
    Last edited: Dec 7, 2017
  2. dadude123

    dadude123

    Joined:
    Feb 26, 2014
    Posts:
    789
    There are methods that wait on a job. Similar to how "Thread.Join" works when dealing with traditional threads.
    So the jobs finishing is probably enforced through that.

    As for the virtual method, I don't know.

    I have a question I'd like to add though:
    In order to maximize the "effective" time in each frame, the jobs would have to be started as soon as possible.
    So they run while other updates are going on, for example all the Update() and LateUpdate() of all the MonoBehaviours.
    So how will that be done? Will they take care that the "job-starting" stuff is ran really really early in each frame?
    I mean if you would be starting your jobs when you're already 10ms into a frame that'd normally take 16ms to complete, and then you have to wait for your jobs to complete... that won't really help much.