Comments (4)
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.
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.
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.
This is solved by withSideEffect in parseq 2.x:
t1.withSideEffect(t2).andThen(t2)
from parseq.
Related Issues (20)
- Use long instead Long in ShallowTraceBuilder to avoid memory over-use for parseq tracing. HOT 2
- Broken link in Wiki regarding parsec-exec HOT 1
- Flaky test in TestExecutionMonitor HOT 2
- Getting the output of side effect HOT 2
- Possible to cancel a running task? HOT 2
- Issue in parallel execution HOT 8
- Introduce `Task.fromTry` to convert `Try` to `Task` with success/failure semantics HOT 5
- runAndWaitException doesn't wait for plan to complete HOT 3
- parseq-lambda-names does not work with Java 11 HOT 1
- linkedin-agent-loader is not compatible with Java 11 HOT 1
- andThen overloading is confusing HOT 4
- Should deprecate(rename)Task.blocking() HOT 2
- Typo in wiki Par vs Seq example code HOT 1
- Base Test Classes are inefficient HOT 1
- GOT a NPE when use TraceUtil.getJsonTrace function HOT 3
- parseq-lambda-names test failed for JDK8.0.322 Zulu
- Bump vulnerable dependency on jackson-mapper-asl (CVE-2019-10172) HOT 5
- Proper logging for `withSafeSideEffect`
- Allow Task.par(Iterable) to fail-fast
- Too many memory occupied when raise exceptions
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from parseq.