2

I have some async tasks to do, like task1, task2, task3, ..., and their relationships is like the graph below.

enter image description here

This is a directed acyclic graph so I can use topological sorting to figure out one possible execution route.

But it is still non trivial task for human, maybe like this.

task7.start().done(check_if_5_is_done_then_start_11, check_if_3_is_done_then_start_8);
task5.start().done(check_if_7_is_done_then_start_11);
task3.start().done(check_if_7_is_doen_then_start_8, check_if_11_is_doen_then_start_10);

....

I'd prefer a more elegant solution, like:

var Tasks = new Tasks({
  task7:  [func7,  []],
  task11: [func11, ["task7", "task5"]],
  task5:  [func5, []],
  task8:  [func8, ["task3"]]
  ...
});

Tasks.start().alldone(function () { // done  });
2
  • take a look at q github.com/kriskowal/q Commented Sep 5, 2013 at 5:19
  • @vinayr Well, I gave a quick glance at that, it seems I should use the .all() method, would you please post some examples? Commented Sep 5, 2013 at 5:32

1 Answer 1

2

Looks like pretty much exactly the use case async.auto is designed for.

Sign up to request clarification or add additional context in comments.

1 Comment

And have a look at async in general, its quite epic.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.