1

I am working on a cross-platform GUI desktop application, written in Ruby. The application will use MacRuby to provide the GUI on Mac OS X, and will use Qt for the GUI on other platforms. The application is a multimedia tool that will allow for such things as ripping CDs or DVDs and encoding them to various formats, or transcoding multimedia files from one format to another.

These tasks are time consuming and therefore must be run in the background so as not to freeze the GUI while they are executing. Furthermore, the background jobs should be able to be canceled and/or paused, and be able to report status and progress to the GUI. There may also be a need to assign priorities to the jobs, so that higher priority jobs run before lower priority jobs, and also to have dependencies between jobs so that a job does not start executing until all of its dependencies have completed.

My question is: what tools or techniques would be best for handling these kinds of background jobs in a Ruby GUI/desktop application? I'd prefer not to "roll my own" job manager to spawn processes or threads and manage the starting and stopping of jobs, etc.

Edit: after posting this question I realized I had asked a very similar question for a C++ solution a while back. My requirements for this Ruby solution are the same as what I had posted for the C++ solution here: C++ master/worker

Community
  • 1
  • 1
Jason Voegele
  • 1,918
  • 1
  • 19
  • 18
  • Isn't one of the benefits of MacRuby that you get to use all the Cocoa stuff like Grand Central Dispatch? http://en.wikipedia.org/wiki/Grand_Central_Dispatch – coreyward Sep 08 '11 at 18:18
  • Grand Central Dispatch provides a mechanism for Mac OS X but doesn't help for the other deployment platforms. – Jason Voegele Sep 08 '11 at 18:28
  • So you're looking for a single tool that'll do that cross-platform. I don't know how likely you are to find that, especially since Ruby isn't as popular as a desktop application language. – coreyward Sep 08 '11 at 18:31
  • Yes, if there is something that works cross-platform that would be my preference. If not, I would at least like to be able to layer a single API on top of platform-specific solutions. (See the link I added to my edited post above.) – Jason Voegele Sep 08 '11 at 18:42

2 Answers2

1

Unfortunately most of the Ruby background job runners I've run across are intended for Rails.

This might be a little lower-level than you're looking for, but EventMachine comes to mind. If you're up for writing your own high-level Job/Dependency code, you could use EM to power it and handle the dirty work of threading (or forking, if you prefer). Not sure about pausing...

I would recommend looking at EventMachine::Deferrable and EventMachine::DeferrableChildProcess to see if they might work.

bioneuralnet
  • 5,283
  • 1
  • 24
  • 30
  • EventMachine looks like it might provide a good low-level mechanism. I've already been experimenting with writing my own high-level API for managing jobs, dependencies, and progress notification. On Mac OS X, Grand Central Dispatch provides a good low-level mechanism for this, but perhaps EventMachine could do the job for other platforms. I'll do some experimentation. Thanks! – Jason Voegele Sep 10 '11 at 11:09
1

I recently used resque for doing background jobs in a ruby project. Granted, it was a Rails app, but as far as I know, there's nothing preventing someone from using it in a desktop app, provided it's compatible with MacRuby and you don't mind installing Redis.

mportiz08
  • 10,206
  • 12
  • 40
  • 42
  • Thanks. Resque looks like a good solution for server applications, but for a desktop application I'm hesitant to use something that requires installation of Redis on the end user's machine. – Jason Voegele Sep 10 '11 at 11:05