- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
acting like a thread pool
Wed, 2010-05-19, 13:41
Is this the equivalent of the classic thread pool + work requests in the
actor model or is there an off-the-shelf load-balancer thing?
class Engine {
import Actor._
// load balancer
val processor : Actor = actor {
var i = 0
loop {
react {
case Exit => {
exit ();
processors foreach (_ ! Exit)
}
case m @ _=> { processors(i) ! m; i = (i+1) % 5 }
}}
}
val processors : Array[Actor] = Array.fill (5) {actor {
loop { react {
...
}
-----
Razvan Cojocaru,
Work: http://www.sigma-systems.com
Playground: http://wiki.homecloud.ca
Latest cool toy: http://scripster.codewitter.com
Follow me: http://feeds.razie.com/RazvanTech RSS Feed ,
http://twitter.com/razie Twitter , http://github.com/razie GitHub .
The Akka-framework has this for you:
Code:
http://github.com/jboner/akka/blob/master/akka-core/src/main/scala/routing/Routers.scala#L33
And if you want a brief intro:
http://klangism.tumblr.com/
On Wed, May 19, 2010 at 2:40 PM, Razvan Cojocaru <razie@razie.com> wrote:
--
Viktor Klang
| "A complex system that works is invariably
| found to have evolved from a simple system
| that worked." - John Gall
Akka - the Actor Kernel: Akkasource.org
Twttr: twitter.com/viktorklang