Hello, there must be a document or tutorial about this somewhere, but I
can't find it... How do Actors implement message polymorphism?
I want to make a system where some Actors are "Producers", some are
"Consumers" and some are both "Producers and Consumers"
My actual code is more complicated, so here is a stripped down version to
concentrate on my question
Producers accept the message "GimmeStuff" and respond by sending "Stuff".
Consumers send the message "GimmeStuff" and accept "Stuff"
Here they are
abstract class Producer[WORK] extends Actor {
def receive = {
case GimmeStuff =>
if(stuffAvailable) sender ! Stuff(nextStuff)
abstract class Consumer[WORK] extends Actor {
def receive = {
case Stuff(stuff) =>
doStuff(stuff)
sender ! GImmeStuff
How do I implement ProducerAndConsumer without duplicating the receive code?
Thanks
P
--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ: http://akka.io/faq/
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/groups/opt_out.