Git Product home page Git Product logo

Comments (4)

brikis98 avatar brikis98 commented on July 27, 2024

Out of curiosity, what happens if you do:

Tasks.seq(t1, Tasks.par(t2, t3), t2)

Does it run t2 again? Or do you get an error that t2 already executed? Or does it immediately return the value in t2?

from parseq.

cpettitt avatar cpettitt commented on July 27, 2024

The current behavior of seq is that it is resolved as soon as the last element in the sequence is resolved. Since t2 will be resolved early in the sequence, the whole sequence with finish early with or without task t3 being run at all. Coming back to parseq a bit fresh, I don't think this is a very intuitive behavior. We do need early finish for use cases with timeouts and such, but it seems that the intuitive behavior for seq would probably be to run the whole sequence to completion and then return the result.

In general, if you try to run a task twice in parseq it will only actually be run once. The second time is a no-op. If you add a listener for the task after it has been resolved the listener is notified immediately.

seq(t1, par(t2, t3), t2) was my first intuitive approach to this problem as well, but I discarded it given the behavior we have in place. It's worth a closer examination.

from parseq.

brikis98 avatar brikis98 commented on July 27, 2024

Agreed on a closer examination. From a "principle of least surprise", I'd expect seq(t1, par(t2, t3), t2) to only return after t1, t2, and t3 are all done.

from parseq.

jodzga avatar jodzga commented on July 27, 2024

This is solved by withSideEffect in parseq 2.x:
t1.withSideEffect(t2).andThen(t2)

from parseq.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.