#Jobs that don't complete immediately - how do you manage?

1 messages · Page 1 of 1 (latest)

paper storm
#

I've got a few burst-compiled jobs in my game for various tasks, some of which take ~0.5ms when fully parallel. I'm looking for the cleanest way to organise them so that they start at the start of each frame, but are only completed towards the end.
I've tried:
-Coroutines -> Generate garbage/not optimal
-Awaitables -> Still generates garbage every few frames even though they are apparently 'pooled'

Ideally I'm looking for a solution where the whole job scheduling + completion can still sit in one method to keep things nice and readable, if such a thing exists.

daring hare
#

As long as you schedule them at the beginning of the frame and don't cause any steuctural changes or read from them until the end it'll work the way you want. No need for async code whatsoever. You can even schedule it at the end of the thread and have work across frames until the next time you do structural changes / read from the data it writes

#

ah wait, you mean jobs without entities. In that case just save the jobhandle after you schedule it, and call .Complete() on it before reading the data from it on the next frame. That'll probably be easier than trying to mess with start of frame end of frame stuff. At most you'll be one frame behind