-class Receiver:
- def __init__(self, *args):
- if len(args) != 1: # Receiver actor expects 1 argument: its ID
- raise AssertionError("Actor receiver requires 1 parameter, but got {:d}".format(len(args)))
- self.mbox = Mailbox.by_name("receiver-{:s}".format(args[0]))
-
- def __call__(self):
- this_actor.info("Wait for my first message")
- while True:
- received = self.mbox.get()
- this_actor.info("I got a '{:s}'.".format(received))
- if received == "finalize":
- break # If it's a finalize message, we're done.
+def receiver(id):
+ mbox = Mailbox.by_name("receiver-{:d}".format(id))
+ this_actor.info("Wait for my first message")
+ while True:
+ received = mbox.get()
+ this_actor.info("I got a '{:s}'.".format(received))
+ if received == "finalize":
+ break # If it's a finalize message, we're done.