0

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 ?

2
  • If you don't want to share the global variable then make it a local variable or change it to a serial processing. Commented Aug 12, 2015 at 7:44
  • Show your code or explain exactly what you want to do. Commented Aug 12, 2015 at 7:44

1 Answer 1

1

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} }); 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.