- Home /
Jobs running over multiple frames
It's not clear for me whether allowing jobs to run over multiple frames is their intended design. I have a couple of computation intensive methods I'd like to run on separathe threads as to not block the main one. I initially settled on using C# Task library, but I would also like to benefit from Burst Compiler which seems to be made with Jobs integration in mind.
Currently I schedule jobs, store handlers in an array, then in Update method I check whether each job is completed and complete it if true (very convenient naming). Could I run into any problems with this method? And if yes, what would be right way? The documentation is not specific about it.
Answer by andrew-lukasik · Dec 08, 2021 at 10:39 AM
It's not clear for me whether allowing jobs to run over multiple frames is their intended design.
It is. If that was not the case then the engine would communicate it by terminating jobs older than a single frame - which is not what we observe.
Could I run into any problems with this method?
There is just one major requirement you need to comply with: some allocation types have lifespan limits.
Temp
is valid for just a 1 frame (but it's allocation call is most performant one)TempJob
is valid for 4 frames max (doc)Persistent
is valid indefinitely (but it's allocation call is most costly one)
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
How do I run a method in another thread? 1 Answer
get_version can only be called from the main thread. 0 Answers
Unity3D and C# - Coroutines vs threading 4 Answers