scriby/asyncblock — Issue #1: Request support for n parallel threads
Author: wampleek
Created: 2011-12-21 22:05:44+00:00
State: open

Hey, I've been using asyncblock for a couple weeks now, and I love the concise syntax. Recently I ran into a situation where I would like to have n parallel execution threads going at once. I've settled on something like:

for(var i = 0; i < numberOfExecutions; i++) {
doTask(flow.add());
if(i % 10 === 0) {
flow.wait();
}
}
flow.wait();

This works somewhat well. It will kick off 10 tasks at once, but will wait for all 10 to complete before issuing new tasks. It would be nice if I could have 10 tasks going at once until they all complete. What do you think?