On 10/23/07, <b class="gmail_sendername">Alan Sobel</b> <<a href="mailto:alansobel@earthnet.net">alansobel@earthnet.net</a>> wrote:<div><span class="gmail_quote"></span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
- there was a post a while back on this list about implementing<br>actors in Ruby;<br> I'd be interested in hearing more about that as well.<br></blockquote></div><br>I did a simple Actor implementation on top of the Fibers mechanism in Ruby
1.9. You can check it out here:<br><br><a href="http://pastie.caboo.se/97050">http://pastie.caboo.se/97050</a><br><br>Here's a quick demo of it in use:<br><br><a href="http://pastie.caboo.se/pastes/97049">http://pastie.caboo.se/pastes/97049
</a><br><br>This will define actor1 and actor2. Provided you have a build of Ruby 1.9 sitting around, you can send messages to them like this:<br><br>actor1 << :cat<br>actor1 << "A string"<br>actor2 << :cat
<br>actor2 << :dog<br><br>This implementation works by adding a mailbox to Fibers, as well as a receive method that takes a filter set (similar to Erlang). When you call receive, it scans over all messages in the mailbox, and if none match, the Fiber yields and lets others run.
<br><br>I later found this, which is quite a bit more developed:<br><br><a href="http://rubyforge.org/projects/concurrent/">http://rubyforge.org/projects/concurrent/</a><br><br>This uses its own thread-based scheduler and runs on top of Ruby
1.8.<br><br>-- <br>Tony Arcieri<br>ClickCaster, Inc.<br><a href="mailto:tony@clickcaster.com">tony@clickcaster.com</a><br>720-227-0129 ext. 202