#1694 Feature request: Actor.sendResultWhenDone(Future)

qualidafial Fri 11 Nov 2011

Breaking this out from #1693.

It would be nice to have a method Actor#sendResultWhenDone(Future).

Without this, we have to send the future as the message to the next actor:

resultA := ActorA(pool).send(a)
resultB := ActorB(pool).sendWhenDone(resultA, resultA)

class ActorB : Actor
{
  override Obj? receive(Obj? msg)
  {
    Future f := msg
    unwrappedMsg := f.get
    // do stuff with unwrapped message
  }
}

This means that actor B has expect a Future as its message, instead of a more natural type as the situation demands.

I propose adding a new method sendResultWhenDone, which sends the result of resultA.get as the message to actor B:

Future sendResultWhenDone(Future f)

Thus:

resultA := ActorA(pool).send(a)
resultB := ActorB(pool).sendResultWhenDone(resultA)

class ActorB : Actor
{
  override Obj? receive(Obj? msg)
  {
    // do stuff with message
  }
}

Edit: fix summary

brian Fri 11 Nov 2011

Promoted to ticket #1694 and assigned to brian

Good idea to break it out, it got lost in the discussion.

I think this makes sense, it is basically just a convenience to "unwrap" the future once it is ready the message to the next actor in line.

qualidafial Fri 11 Nov 2011

@brian: If you haven't started on this, I'd like to take a stab at it.

brian Fri 11 Nov 2011

That would be great - you can email me your patch

qualidafial Sat 12 Nov 2011

I set up a patch queue here.

brian Wed 15 Feb 2012

Ticket cancelled

During prototype of this feature, uncovered a major problem in that there is no good way to handle exceptions since you only have the result and not the entire Future. So despite being awkward seems safer to actually pass the whole future using sendWhenDone.

Login or Signup to reply.