From: Luiz Angelo Daros de Luca Date: 2011-07-16T08:25:19+09:00 Subject: Re: Ruby embed called from a pthread Wow Peter, what a pretty hack :-) It really works! Thanks again. Shouldn't ruby provide something like this? (but not hacky) After a long period of developing, I finally soved all my ruby problems. As a shared library, I receive call from many threads. So, when the first thread needs ruby, I spaws a new pthread dedicated to ruby and initialize all its stuff. I created some wrapper for each of my C methods. When my method is called, I write its arguments to a global variable, asks my ruby pthread (not a ruby thread) to run it and it wakes me when it is done. All ruby calls uses the Peter's Hack. Again, maybe ruby could already provide something similar to my solution. Anyway, it now works! ---      Luiz Angelo Daros de Luca, Me.             luizluca@gmail.com 2011/6/23 Peter Zotov : > On Thu, 23 Jun 2011 16:37:44 +0900, Luiz Angelo Daros de Luca wrote: >> >> Hello guys, >> >> I'm writing a opensync metamodule in order to allow opensync modules >> written in ruby. >> It already exists for python but I am a ruby guy. It is almost >> complete except to the fact >>  that is segfalts :-) I'm using ruby 1.9.1. >> >> Opensync is multithreaded by design. So, my module must accept this >> behavior. >> I mutexed all ruby access in order to avoid concurrent access of ruby env. > > We've solved this problem, which arised while trying to launch MRI as a > thread > in NodeJS. You can take a look at the code: > https://github.com/whitequark/coldruby/blob/master/libcoldruby/MRIRubyCompiler.cpp > > -- >  WBR, Peter Zotov. > >