Closed AlexSabourinDev closed 4 years ago
I'm considering that we can make each worker thread have it's own lock-free job queue. Seems like an interesting and fun challenge.
I'm not sure yet if work stealing is worthwhile. It could be something we can consider in the future.
Split job chaining to issue #22
Is your feature request related to a problem? Please describe. Ice Box will require a job system for a variety of systems such as rendering, loading and more.
Describe the solution you'd like I expect this job system to have a few features to get started and we can add to it as we discover needs.
The approach I suggest is to store a queue per thread and allow for lock free work stealing. (See [1]) A queue per thread will allow the jobs to advance and hopefully allow for a reduced use of atomics and contention.
The API should be simple:
Consider not adding a blocking "wait" call until a system requires it. It could hopefully push the system designer to consider not having blocking calls.
For "OnJobComplete" callbacks, consider leaving this to the appropriate system. There is no clear thread where it would be "thread safe" to trigger an OnJobComplete event and as a result it would be much simpler for the owning system to decide how to handle it.
Resources [1] https://blog.molecular-matters.com/tag/job-system/ [2] http://danglingpointers.com/post/job-system/