Exploring actors in Ruby (and perhaps other languages) through the Sieve of Eratosthenes
Ruby
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src/ruby
README.org

README.org

Implementing the Sieve of Eratosthenes using actors

The code in this project consists of implementation(s) of the Sieve of Eratosthenes using actors.

Contents

Ruby

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.

Akka

  • 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.

Non-blocking Akka

  • 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

Celluloid

  • 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.