Charles Oliver Nutter
9/5/2007 6:43:00 PM
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