Project

actress

0.0
No commit activity in last 3 years
No release in over 3 years
|Provides Future and Actors. Actors are sharing Thread pool so |as many actors as you need can be spawned.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

 Project Readme

NOTE: Actress gem was merged into concurrent-ruby. It's no longer maintained.

Actress

Actor model library.

Provides Future and Actors. Actors are sharing Thread pool so as many actors as needed can be spawned allowing to better structure your code without caring about number of threads or recycling of actors. Architecture inspired by Erlang and Akka. (AFAIK This is not possible with any other gem providing Actor model.)

Quick peak

require 'actress'

Message = Algebrick.type do
  variants Plus     = type { fields a: Numeric, b: Numeric },
           Subtract = type { fields a: Numeric, b: Numeric }
end

class Counter < Actress::Abstract

  def on_message(message)
    Type! message, Message
    match message,
          (on ~Plus do |(a, b)|
            a + b
          end),
          (on Subtract.(~any, ~any) do |a, b|
            a - b
          end)
  end
end

world   = Actress::World.new
counter = world.spawn Counter, 'counter'

operations = [Plus[1, 2],
              Subtract[2, 1]]
results    = operations.map { |o| counter.ask o } # futures
p results.map(&:value) # => [3,1]

world.terminate

Note

This is still only version 0.0.x please keep that in mind when something breaks ;)