The code in this project consists of implementation(s) of the Sieve of Eratosthenes using actors.
There are several Ruby implementations here based on various actor implementations. Each version implements the Sieve module which includes Controller and Actor classes as well as a Primes enumerable to facilitate usage and testing. A quick overview of these various implementations can be found below.
- Implemented in src/ruby/akka.rb
- Can be tested with rake test_akka
- Known to work with JRuby 1.6.7 and Akka 1.2
A fairly simple implementation using Akka via JRuby. Calls to Controller.next send candidates to each model (building a collection of futures to represent these ops) and then wait for answers immediately. Using this method Controller.next always returns a value to it’s caller immediately.
Discussed in detail in this blog post.
- Implemented in src/ruby/akka_nb.rb
- Can be tested with rake test_akka_nb
- Known to work with JRuby 1.6.7 and Akka 1.2
A more complex version using Akka and JRuby. Here the Controller no longer waits for responses from all models when handling Controller.next. Instead the controller checks it’s state as results come in, sending a response to the caller only if all models have responded positively. This approach forces each actor to handle only one message at a time, addressing a design flaw in the original implementation and bringing us closer to “pure” actors.
Discussed in detail in this blog post
- Implemented in src/ruby/celluloid_base.rb
- Can be tested with rake test_celluloid_base_jruby
- Known to work with JRuby 1.6.7 and Celluloid 0.11.0
An initial version using Celluloid and JRuby.
To be discussed in a forthcoming blog post.