Open LordSk opened 5 years ago
Hi LordSk, there are two options. One is to deal with it like I do in the demo https://github.com/nem0/lucy_job_system/blob/master/src/main.cpp#L46. Another is the way like I do it Lumix Engine https://github.com/nem0/LumixEngine/blob/ffr/src/engine/job_system.cpp#L565-L579. Both options will block the calling thread, which might be not what you want.
Ideally, such thread should help with jobs while waiting. This is however not possible in fiber-based job system since the thread would have to be converted to a fiber thread, which I can not do since it's user's thread. In Lumix Engine, I have a backup worker threds, which I enable in such cases https://github.com/nem0/LumixEngine/blob/ffr/src/renderer/renderer.cpp#L922
Let me know which option is the best for you.
Hello nem0.
I expected the behaviour of wait to be the one you linked (https://github.com/nem0/LumixEngine/blob/ffr/src/engine/job_system.cpp#L565-L579), a blocking wait. I decided to make my own job system for the time being as lucy does not seem suited for what I intended to make. I want to run jobs sometimes (like loading data in the background for example), and lucy seems very much built towards running a lot of jobs, all the time.
For the time being, I kindly suggest updating the mini docs to make the wait() function's behaviour a bit clearer.
Thank you for the detailed answer nem0, I will definitely come back to lucy when I get around to making an everything is a job program.
First, thank you for sharing your work. I just so happened to want a job system for my project and thought I would start by testing yours.
So in my project, I have 2 threads dedicated to certain tasks and the remaining would be workers. In one of the dedicated thread, I create a few jobs to be run:
lucy::wait()
callsgetWorker()
which is null since we did not create any worker on this thread. I have attached a simple example (based on your main.cpp example code) if you want to reproduce the bug.main.zip