Accessing ruby 1.9 interpreter from other threads

Discussion in 'Ruby' started by Bill Kelly, Aug 28, 2007.

  1. Bill Kelly

    Bill Kelly Guest

    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
     
    Bill Kelly, Aug 28, 2007
    #1
    1. Advertising

  2. 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
     
    Nobuyoshi Nakada, Aug 29, 2007
    #2
    1. Advertising

  3. 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
     
    Charles Oliver Nutter, Aug 29, 2007
    #3
  4. 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
     
    Nobuyoshi Nakada, Sep 5, 2007
    #4
  5. 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
     
    Charles Oliver Nutter, Sep 5, 2007
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. The Dark Seraph

    Detached interpreter threads

    The Dark Seraph, May 27, 2004, in forum: Python
    Replies:
    0
    Views:
    304
    The Dark Seraph
    May 27, 2004
  2. Replies:
    3
    Views:
    394
    Jeff Shannon
    Oct 21, 2004
  3. Charlie DeTar

    embedded python and interpreter threads

    Charlie DeTar, Dec 7, 2004, in forum: Python
    Replies:
    2
    Views:
    671
    Charlie DeTar
    Dec 7, 2004
  4. Carl J. Van Arsdall

    Threads and Interpreter death

    Carl J. Van Arsdall, Feb 9, 2006, in forum: Python
    Replies:
    2
    Views:
    277
    Bryan Olson
    Feb 9, 2006
  5. Replies:
    3
    Views:
    773
    Ziga Seilnacht
    Jan 3, 2007
Loading...

Share This Page