I am trying to build a project with async.parallel but all the parallel functions are modifying the same global variable. How can I put a mutex or some kind of lock on that variable ?
- If you don't want to share the global variable then make it a local variable or change it to a serial processing.Subham– Subham2015-08-12 07:44:31 +00:00Commented Aug 12, 2015 at 7:44
- Show your code or explain exactly what you want to do.ralh– ralh2015-08-12 07:44:51 +00:00Commented Aug 12, 2015 at 7:44
Add a comment |
1 Answer
Can you not handel that in the finish function?
async.parallel({ one: function(callback){ setTimeout(function(){ callback(null, 1); }, 200); }, two: function(callback){ setTimeout(function(){ callback(null, 2); }, 100); } }, function(err, results) { // results is now equals to: {one: 1, two: 2} });