[ANN] Actors for Ruby: The Omnibus Concurrency Library 0.1

M

MenTaLguY

--=-5yjgu/Y04i7mOe3teZpf
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable

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 =3D Struct.new :reply_to
Greeting =3D Struct.new :value

# spawning a new actor
oracle =3D Actor.spawn do
greeting =3D "Hello"
loop do
# guarded receive (does case-like matching via #=3D=3D=3D)
Actor.receive do |f|
f.when Greeting do |m|
greeting =3D 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 =3D 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=3D3690

-mental

--=-5yjgu/Y04i7mOe3teZpf
Content-Type: application/pgp-signature; name=signature.asc
Content-Description: This is a digitally signed message part

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (GNU/Linux)

iD8DBQBGVmG7SuZBmZzm14ERAsTAAJwPR6vYTP7bfo8zgQYIETiTxnfSjACdHbYf
wsYLlDlOhMTPRBGfF50jsqc=
=JqvY
-----END PGP SIGNATURE-----

--=-5yjgu/Y04i7mOe3teZpf--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,152
Members
46,697
Latest member
AugustNabo

Latest Threads

Top