Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Accessing ruby 1.9 interpreter from other threads

Reply
Thread Tools

Accessing ruby 1.9 interpreter from other threads

 
 
Bill Kelly
Guest
Posts: n/a
 
      08-28-2007
Hi,

I seem to recall hearing 1.9 is using native threads now.

If so, does that mean it's now safe for multiple OS threads
to call into the 1.9 ruby interpreter, and eval or execute
ruby code? (I'm assuming some sort of interpreter lock would
need to be grabbed.)


Thanks,

Bill



 
Reply With Quote
 
 
 
 
Nobuyoshi Nakada
Guest
Posts: n/a
 
      08-29-2007
Hi,

At Tue, 28 Aug 2007 19:33:02 +0900,
Bill Kelly wrote in [ruby-talk:266532]:
> I seem to recall hearing 1.9 is using native threads now.
>
> If so, does that mean it's now safe for multiple OS threads
> to call into the 1.9 ruby interpreter, and eval or execute
> ruby code? (I'm assuming some sort of interpreter lock would
> need to be grabbed.)


And to bind calling native thread a ruby thread. But still not
provided now.

--
Nobu Nakada

 
Reply With Quote
 
 
 
 
Charles Oliver Nutter
Guest
Posts: n/a
 
      08-29-2007
Nobuyoshi Nakada wrote:
> Hi,
>
> At Tue, 28 Aug 2007 19:33:02 +0900,
> Bill Kelly wrote in [ruby-talk:266532]:
>> I seem to recall hearing 1.9 is using native threads now.
>>
>> If so, does that mean it's now safe for multiple OS threads
>> to call into the 1.9 ruby interpreter, and eval or execute
>> ruby code? (I'm assuming some sort of interpreter lock would
>> need to be grabbed.)

>
> And to bind calling native thread a ruby thread. But still not
> provided now.


A similar mechanism is used in JRuby to "adopt" incoming Java threads as
Ruby threads, allowing them to participate in thread events like kill
and raise. But there's nothing explicit about it; threads that haven't
been adopted are adopted automatically. Can't this be done automatically?

- Charlie

 
Reply With Quote
 
Nobuyoshi Nakada
Guest
Posts: n/a
 
      09-05-2007
Hi,

At Wed, 29 Aug 2007 19:16:00 +0900,
Charles Oliver Nutter wrote in [ruby-talk:266657]:
> A similar mechanism is used in JRuby to "adopt" incoming Java threads as
> Ruby threads, allowing them to participate in thread events like kill
> and raise. But there's nothing explicit about it; threads that haven't
> been adopted are adopted automatically. Can't this be done automatically?


Does that "adopt" occur in any call to ruby? Isn't it
performance overhead?

--
Nobu Nakada

 
Reply With Quote
 
Charles Oliver Nutter
Guest
Posts: n/a
 
      09-05-2007
Nobuyoshi Nakada wrote:
> Hi,
>
> At Wed, 29 Aug 2007 19:16:00 +0900,
> Charles Oliver Nutter wrote in [ruby-talk:266657]:
>> A similar mechanism is used in JRuby to "adopt" incoming Java threads as
>> Ruby threads, allowing them to participate in thread events like kill
>> and raise. But there's nothing explicit about it; threads that haven't
>> been adopted are adopted automatically. Can't this be done automatically?

>
> Does that "adopt" occur in any call to ruby? Isn't it
> performance overhead?


Not really, if the thread hasn't been adopted it just constructs a new
Ruby thread to wrap it and a "thread context" to govern frames, scopes,
etc for Ruby execution. That's a one-time hit that only happens the
first time a normal Java thread enters Ruby code. From then on it
largely just looks like any other Ruby thread.

- Charlie

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Python embedded interpreter: how to initialize the interpreter ? ycollet@freesurf.fr Python 3 01-03-2007 01:00 AM
Threads and Interpreter death Carl J. Van Arsdall Python 2 02-09-2006 09:48 PM
embedded python and interpreter threads Charlie DeTar Python 2 12-07-2004 04:52 PM
Threads in embedded interpreter doesn't run devrim.erdem@gmail.com Python 3 10-21-2004 07:27 PM
Detached interpreter threads The Dark Seraph Python 0 05-27-2004 09:42 PM



Advertisments