Forum: Ruby Actors for Ruby: The Omnibus Concurrency Library 0.1

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
912c61d9da47754de7039f4271334a9f?d=identicon&s=25 MenTaLguY (Guest)
on 2007-05-25 06:12
(Received via mailing list)
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

-mental
This topic is locked and can not be replied to.