[Backgroundrb-devel] Need to call C++ processing beast from backgroudrb

Ezra Zygmuntowicz ezmobius at gmail.com
Fri Jun 16 11:34:28 EDT 2006

On Jun 16, 2006, at 7:59 AM, Douglass Turner wrote:

> Hello,
> Bravo Ezra for Backgroundrb! What an elegant piece of engineering.  
> I envision many folks like myself looking at our CPU hogging  
> executables and finally seeing a clean path to the Web.
> I was wondering if any folks have a good strategy for calling out  
> to a C++ (or any other compiled) executable from a worker. Is the  
> only option to call system() from a worker? That feels a bit  
> unsatisfying. How for example is the Ruby binding of ImageMagick  
> (RMagick) done and is that perhaps a strategy for a cleaner more  
> Ruby-ish solution.
> For context, I intend to call an image manipulation engine written  
> in C++ (yacc + lex + pixel wrangler) from a worker which receives  
> and uploaded photo from a user. My plan is to mail the processed  
> photo back to said user using ActionMailer.
> Anyway, happy days Ezra.
> Regards,
> Doug Turner
> skype: dduuggllaa
> _______________________________________________
> Backgroundrb-devel mailing list

Welcome Doug!

	Thanks for the kind words. THe quick and easy way to call your c++  
binary is with system. OR even better IO.popen. IO.popen allows you  
to open the binary and connect to stdin and stdout so you can read  
and write to the binary. But both of these are hacks compared to the  
better way to do it. Ruby is extremely easy ot write C or C++  
extensions for, its one of the best features of the language. So I  
would suggest that you write a ruby/C++ extension for your imaging  
module and use that. There are a few ways to go about it. One way is  
swig, another way is just straight ruby/C++ extension and a third way  
is via DL. Google around and you will find much info on all three of  
these. I'm not familiar with your binary and I am not much of a C  
coder so I don't think I will be too much help but here's a nice link  
to get you started:



More information about the Backgroundrb-devel mailing list