Reputation: 11686
i've been working with Scala for some time and i've started to take a deeper look into concurrency. With my knowldege of Java concurrency i've achieved the simple things I had to do, but i'm trying to dig a little bit more into the Actors world.
The problem is that i can't find any advanced tutorial or docs rather than this one:
http://docs.scala-lang.org/overviews/core/actors.html (pretty good BTW)
Of course i've read the API, but i'd like to have some code examples, good practices, recommendations, etc.
NOTE: I'm talking of documentation about things not covered in the mainstream docs. I know the core concepts of actors. Also, i've read these books:
Programming in Scala: A Comprehensive Step-by-Step Guide, 2nd Edition
Programming Scala: Scalability = Functional Programming + Objects
EDIT: Thank you for all the answers. I'm aware of the books about actors, but i'm looking for free sutff.
Upvotes: 2
Views: 674
Reputation: 13137
Here is a small code example I wrote that solves one of the Project Euler problems using Akka actors. It uses actors sort of like a map/reduce operation, where workers are processing pieces of data in parallel and sending their results to a collector. The whole thing is asynchronous and could (hypothetically) scale out to thousands or millions of nodes.
The code has gone through several iterations as I've learned more about how to use Actors (and I'm still learning!), so looking at earlier revisions might give you some insight into how I arrived at the current design.
Upvotes: 1
Reputation: 10927
There is also this book. It's pretty well written, although when I read it, it didn't talk about Akka at all, which is a little awkward, since Akka is used a lot. In fact, I wouldn't be surprised if there was some convergence between Scala's own actors and Akka's actors in the near future (towards Akka's model).
Upvotes: 2
Reputation: 32392
My starting point was to read some Erlang tutorials such as Learn You Some Erlang for Great Good. Erlang has been around for a while and there are lots of tutorials, books, presentations. At the core of Erlang is the actor model, i.e. message passing between shared nothing actors (called processes in Erlang) so it is a good way to get the concepts down.
Then when you turn to Scala for the syntax, use Akka because it's API is much closer to Erlang that the basic Scala actors. Fundamentally, actors in Scala using Akka are very simple. The real challenge is to take a design and to recast it in terms of actors with NO shared data whatsoever. There is a temptation with Scala to just use some Java libraries and to some object-oriented design and end up with something that is not quite compatible with actors.
I suggest starting from an actors point of view, hash out a workable design, and then enhance that with Java classes and object-oriented techniques. For instance in my first Akka-based application, I used the ordinary Java AMQP library to consume messages rather than the Akka abstraction, because the Java class was simple and I was already intimately familiar with AMQP.
Upvotes: 3