FAM-Ruby, Other

Released version 0.1.3 of FAM-Ruby. This release consists entirely of a small one line patch from Jon Bernard, so I took the opportunity to import FAM-Ruby into CVS under the module fam-ruby.

Raggle now has a half-assed (but working!) implementation of parallel feed grabbing. Basically each feed grab is forked off in it's own thread, which means you can grab an arbitrary number of feeds in parallel (limited by CPU speed and bandwidth, of course). This implementation is in CVS, but don't rush to try it just yet; it seems to have dug up some intermittent concurrency issue in either REXML, Ruby, or Raggle. I've marked all the "destructive" regions of feed grabbing threads as critical regions, but I haven't narrowed down the problem just yet. My hunch is that it's either a subtle error in the Ruby GC, or a concurrency issue in REXML. The latter seems strange to me, since REXML is written in pure Ruby and, as far as I know, doesn't use threads internally. I guess we'll see.

Richard (richlowe) and I were talking about passing events between machines, and he suggested that I use DRb. I've played around with DRb a bit before, but for some reason using RMI for mundane things — in this case, a /whatsPlaying alias in Irssi which queries the XMMS process on my workstation — never occurred to me. What I really love about this solution is how absurdly simple it is. Here's the code for the "server":

require 'drb'
require 'xmms'

DRb::start_service('druby://picard:2345', Xmms::Remote::new)

The "client" is ridiculously simple as well. Here it is:

require 'drb'

if r = DRbObject.new(nil, 'druby://picard:2345')
  puts "Playing \"#{r.title}\"."

Finally, the one-liner in Irssi to tie the whole thing together:

/alias whatsPlaying exec - -o bin/whatsPlaying.rb

In case anyone is wondering, this is one of the things I really like about Ruby; solutions tend to be simple, short, and legible. Okay, </advocacy>. I'm out for now.