Handmade Hero»Forums»Code
14 posts
Work queue dependencies
I was wondering if there could be a good method to specify dependencies in the work queue. For example let's say that we want to push work entries 1,2,3,4,5,6,7,8. If entries 7 and 8 had to wait for entries 1-4 to complete how could we achieve this in the current work queue implementation without having to wait for entries 1-6 to complete?
511 posts
Work queue dependencies
Make each of the tasks 1 through 4 count down a shared variable and when 0 the last one will queue up 7 and 8.

Allen Webster
476 posts / 6 projects
Heyo
Work queue dependencies
If you want to think about a fully configurable dependency system, I recall that this (and the previous post it links to) are fascinating reads: http://cbloomrants.blogspot.com/2...11-worker-thread-system-with.html

Although that's from 2011, I would be curious if the author still uses a solution like this.
9 posts
Work queue dependencies
I haven't read the article Mr4thDimension posted, so I don't know if what I am going to say is redundant or not, but you could have each job have an array of dependencies. When the system finishes a job and needs to decide which one to start next, it could check a pending job to make sure all of the jobs it is dependent on have finished before inserting it.

There are some ups and downs to this system, but setting up the job chain becomes very easy to do and visualize in code.
Allen Webster
476 posts / 6 projects
Heyo
Work queue dependencies
thebeast33
I haven't read the article Mr4thDimension posted, so I don't know if what I am going to say is redundant or not, but you could have each job have an array of dependencies. When the system finishes a job and needs to decide which one to start next, it could check a pending job to make sure all of the jobs it is dependent on have finished before inserting it.

There are some ups and downs to this system, but setting up the job chain becomes very easy to do and visualize in code.


The blog post is a follow up to an idea based on what you're saying. The author basically inverts the dependence, so instead of saying job B depends on job A, the system instead encodes job A permits job B. Then he sets up a thing where you declare your dependencies in the more natural way, and internally it inverts it to the permits system. It also explains why the permits system makes a superior job system.
14 posts
Work queue dependencies
Thanks for the link, it's interesting.

I was wondering whether it's worth implementing something like this on top of the current handmade hero work queue system or adding it to it.

What I had in mind was some kind of push buffer list for jobs, that are eventually added to a work-queue.