# Actors for Ruby: The Omnibus Concurrency Library 0.1

**URL:** <https://www.ruby-forum.com/t/actors-for-ruby-the-omnibus-concurrency-library-0-1/105038>\
**Category:** Ruby\
**Created:** [May 25, 2007, 6:12am UTC](https://www.ruby-forum.com/t/actors-for-ruby-the-omnibus-concurrency-library-0-1/105038 "2007-05-25T06:12:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![MenTaLguY](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/439d5e/32.png) [@MenTaLguY](https://www.ruby-forum.com/u/MenTaLguY)\
**Post date:** [May 25, 2007, 6:12am UTC](https://www.ruby-forum.com/t/actors-for-ruby-the-omnibus-concurrency-library-0-1/105038/1 "2007-05-25T06:12:01Z")

</div>

With all the recent interest in Erlang, I’ve decided to bump up the  
release schedule of my Omnibus Concurrency Library. It provides a  
Ruby-esque implementation of actors, as well as a few other concurrency  
approaches (data-parallel programming and futures, to begin with).

This first release is a very rough cut, featuring an MRI port of the  
Actors implementation I wrote for the Rubinius core. I’m afraid there’s  
no documentation yet, so I’ll give some brief examples:

require ‘concurrent/actors’  
include Concurrent::Actors

RequestGreeting = Struct.new :reply\_to  
Greeting = Struct.new :value

# spawning a new actor

oracle = Actor.spawn do  
greeting = “Hello”  
loop do  
# guarded receive (does case-like matching via #===)  
Actor.receive do |f|  
f.when Greeting do |m|  
greeting = m.value.dup.freeze  
end  
# callback part 1  
f.when RequestGreeting do |m|  
m.reply\_to \<\< Greeting[greeting]  
end  
end  
end  
end

# sending a message to an actor

oracle \<\< Greeting[“Howdy”]

# getting a reference to the current actor

current = Actor.current

# callback part 2

oracle \<\< RequestGreeting[current]  
Actor.receive do |f|  
f.when Greeting do |m|  
puts “#{ m.value }, Bill!”  
end  
end

Linked processes, distributed actors, and possible integration with  
Erlang/Erlectricity are planned for the future.

The Omnibus Concurrency Library is available via RubyGems as the  
“concurrent” gem, and downloads are also available from the RubyForge  
download page:

[http://rubyforge.org/frs/?group\_id=3690](http://rubyforge.org/frs/?group_id=3690)

-mental
