Open mpickering opened 2 years ago
The reasoning for step spawning a new thread was to free up any used stack that might be on the thread already, and to make sure the exceptions didn't have any chance of bubbling up. Whether those are legitimate reasons is probably something you are most qualified to answer than me! Does that sound sensible or silly?
@ndmitchell Spawning a new thread is fine but the question is why two actions are run in the spawned thread rather than one thread per action.
When there is more work to do
step
spawns a new thread and runs the actionnew >> worker pool
. I can't understand what exactly is going on with theworker pool
call.How I understand the code sequence:
now
)worker pool
runs, which callswithPool
, and so will block untilstep
finishes (because the thread is forked whilststep
owns thePool
variable.step
finishes and the spawned thread is added to the pool.worker pool
, which then unqueues another task? (This is the part I don't get) and runs it.Pool
.Step 4 is the part I don't understand, why does each spawned thread get two actions run in it?
Code in question: