Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto-run the Task that is returned from Task.run #34

Open
cpettitt opened this issue Aug 27, 2013 · 0 comments
Open

Auto-run the Task that is returned from Task.run #34

cpettitt opened this issue Aug 27, 2013 · 0 comments

Comments

@cpettitt
Copy link
Contributor

This has been raised as a surprise by several people - most recently by @jhartman. The behavior of ParSeq differs between core ParSeq, Play, and Restli. ParSeq and Play require Tasks to be explicitly run. Restli auto-runs the returned Task.

In an environment where users are using seq / par, the auto-run behavior is most intuitive. In an environment where users are using context.after, the opposite is true. Here's an example where auto-run would do the wrong thing:

    final Task<String> parent = new BaseTask<String>()
    {
      @Override
      protected Promise<? extends String> run(final Context context) throws Exception
      {
        context.after(a).run(b);
        context.after(a).run(c);
        context.after(b, c).run(d);
        context.run(a);
        return d;
      }
    };

With auto run we'd try to run d before b and c. However, context.after is intended as a low-level construct for building up more user friendly tasks, such as the above mentioned seq and par, so it seems better to make run handling special for context.after and not the other way around.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant