Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Type safe Scala actors

Tags:

scala

actor

Is there any way to specify what type of message an actor can accept and give a compile error if anything tries to send it some other type?

like image 611
mentics Avatar asked Apr 27 '11 20:04

mentics


1 Answers

Not sure whether it answers your question, but I hope it will give you some ideas. Maybe you are searching for something like Typed Actors from Akka project:

The Typed Actors are implemented through Typed Actors. It uses AOP through AspectWerkz to turn regular POJOs into asynchronous non-blocking Actors with semantics of the Actor Model. E.g. each message dispatch is turned into a message that is put on a queue to be processed by the Typed Actor sequentially one by one.

So you define interface and implementation and then register them as actor. Akka will create proxy for your interface that still use actor model under the hood. And you still able to use following message passing styles:

  • fire-and-forget
  • request-reply
  • request-reply-with-future
like image 88
tenshi Avatar answered Oct 26 '22 09:10

tenshi