#Schedule second job after first job completed without blocking main thread (await job?)

1 messages · Page 1 of 1 (latest)

topaz meteor
#

I have a IJobFor that I want to schedule after another job has finished (the results of the first are required to know the number of iterations to schedule the second for).
I do not want it to block the main thread. My first thought was to pass the handle and a Action to a ticking component that just checks the IsCompeted bool of the handle. But that seems not great.

My second thought was to use async and await to wait until it is completed. I found this implementation on github. But it seems to still block the main thread.
https://gist.github.com/distantcam/64cf44d84441e5c45e197f7d90c6df3e

Any thoughts? Am I just doing something wrong? Thanks!

woeful swift
#

jobs return a job handle, simply pass it to the next and it will not run until first is complete

#

IJobParallelForDefer is designed to handle the case of unknown iterations when chaining jobs

topaz meteor
woeful swift
#

you can use an int*

topaz meteor
# woeful swift you can use an int*

Tbh I am not sure how you would use a pointer for this. Like, how do you set it? Would you need a third job that runs in between the two IJobFor jobs that sets the int pointer using the data from the first job?

woeful swift
#

depends entirely what you're doing

#

you could increment pointer using interlocked from your job

#

you could have an IJob in between that calculates the the value

#

for this you could use a nativereference for the ptr which you set from this IJob