Douglass Turner
2006-Jun-16 14:59 UTC
[Backgroundrb-devel] Need to call C++ processing beast from backgroudrb
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 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20060616/0f3e9567/attachment.htm
Ezra Zygmuntowicz
2006-Jun-16 15:34 UTC
[Backgroundrb-devel] Need to call C++ processing beast from backgroudrb
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 listWelcome 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: http://www.onlamp.com/pub/a/onlamp/2004/11/18/extending_ruby.html Cheers- -Ezra
Douglass Turner
2006-Jun-16 17:09 UTC
[Backgroundrb-devel] Need to call C++ processing beast from backgroudrb
Thanks. Got some reading to do. Cheers, Doug On 6/16/06, Ezra Zygmuntowicz <ezmobius at gmail.com> wrote:> > > 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: > > http://www.onlamp.com/pub/a/onlamp/2004/11/18/extending_ruby.html > > Cheers- > -Ezra >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20060616/4c84609e/attachment.htm