Reputation: 1928
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
Upvotes: 1
Views: 361
Reputation: 10328
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.
Upvotes: 1
Reputation: 5301
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.
Upvotes: 1