there is no race condition, because it's a single process. first the
forEach will be done, before any exec-callback is fired, no matter how long
in takes. when forEach returnes, the eventloop goes further and takes care
of the callbacks. every exec callback fired does it's job atomically as
var filesInProgress = 0,
fancyCallback =
allDone = function(){ // boom}
files.forEach( function(filename){
filesInProgress++
exec('ls '+filename,function(err, stdout, stderr){
filesInProgress--;
//do something with it
if(filesInProgress === 0) allDone();
But, what should you do if you can't serve anything after all sub-processes
have completed their work?
Am Donnerstag, 14. März 2013 22:02:11 UTC+1 schrieb Mikeal Rogers:
That's a great oppertunity? but it's not in line with the structure and
goals of node.js.
Node has synchronous file
https://github.com/joyent/node/issues/1167 - stdio options need to be
specced out still.
--
--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups
OMG, so old and nobody has done something yet.
Am Donnerstag, 14. März 2013 22:48:46 UTC+1 schrieb Bradley Meck:
https://github.com/joyent/node/issues/1167 - stdio options need to be
specced out still.
--
--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
Callbacks are easy (*). Sync calls are an abomination in node.js.
Unfortunately we cannot get rid of the ones that are already there. But we
should not add more.
(*) Some claim that they are easy for us humans. I find them too painful
for humans but still easy because they can be mechanically
Hope that no process completes before fileInProgress is set to two!
Race-Conditions...
Am Donnerstag, 14. März 2013 22:05:10 UTC+1 schrieb greelgorke:
var filesInProgress = 0,
fancyCallback =
allDone = function(){ // boom}
files.forEach( function(filename){
filesInProgress++