This page is no longer maintained — Please continue to the home page at

Chaining asynchronous operations

No replies
Bill La Forge
Joined: 2011-07-13,
User offline. Last seen 42 years 45 weeks ago.

Had a major breakthrough this morning. I've been asking AsyncFP
developers to code like this, which is a bit absurd:

simpleActor(Prnt(1)) {
rsp1 => {
simpleActor(Prnt(2)) {
rsp2 => {
simpleActor(Prnt(3)) {
rsp3 => {

Yesterday I worked out how to chain simple operations:

val chain = new Chain
chain.add(simpleActor, Prnt(1))
chain.add(simpleActor, Prnt(2))
chain.add(simpleActor, Prnt(3))
chain.add(simpleActor, Prnt("scadoo!"))
Future(simpleActor, chain)

Now that helped a little, but to often you need the results of one
operation to define the next one:

simpleActor(UltimateAnswer()) {
rsp => {

This morning I extended Chain to handle this case:

val results = new Results
val chain = new Chain(results)
val simpleActor = new SimpleActor
chain.add(simpleActor, UltimateAnswer(), "ultimateAnswer")
Unit => simpleActor,
Unit => Prnt("The Ultimate Answer to Everything: " +

OK, so using chains is not always the best answer, but when there are
a lot of operations to be performed, it can be a real God send.

Now I just need to go through all the IncDes examples and rework them
to use chaining, at least where it makes sense.


Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland