#642 Actor message forwarding

brian Thu 18 Jun 2009

One of the things I've discovered myself wanting is the ability for an actor to forward a message to another actor. Consider this:

  1. X sends message M to actor A
  2. Actor A forwards M to actor B
  3. Actor B responds directly to future held by X

To support this functionality, I propose a new forward method on Actor:

**
** Forward a message to the specified actor.  The result of the forwarded
** message is used as the response of the current request.
**
Obj forward(Actor a, Obj? msg)

For example here is how it would work:

future := a.send(msg)

// in a's receive
Obj receive(Obj msg, Context cx) { return forward(b, msg) }

// in b's receive
Obj receive(Obj msg, Context cx) { return result }

future.get // original future now contains result of b

Comments welcome

Login or Signup to reply.