Ruby interpreter thread safety

Discussion in 'Ruby' started by Thomas Sondergaard, Sep 4, 2003.

  1. I have a scenario where a ruby extension module starts real/os/heavy-weight
    threads that may call back to ruby. As far as I understand the ruby
    interpreter itself is not thread safe. How can I handle this thread-safety
    problem?

    Cheers,

    Thomas
     
    Thomas Sondergaard, Sep 4, 2003
    #1
    1. Advertising

  2. Thomas Sondergaard

    Guest

    Hi,

    At Thu, 4 Sep 2003 19:45:24 +0900,
    Thomas Sondergaard wrote:
    > I have a scenario where a ruby extension module starts real/os/heavy-weight
    > threads that may call back to ruby. As far as I understand the ruby
    > interpreter itself is not thread safe. How can I handle this thread-safety
    > problem?


    Run the ruby interpreter in a particular os-thread, and use
    system provided queue.

    --
    Nobu Nakada
     
    , Sep 4, 2003
    #2
    1. Advertising

  3. Thomas Sondergaard

    Jim Weirich Guest

    On Thu, 2003-09-04 at 06:45, Thomas Sondergaard wrote:
    > I have a scenario where a ruby extension module starts real/os/heavy-weight
    > threads that may call back to ruby. As far as I understand the ruby
    > interpreter itself is not thread safe. How can I handle this thread-safety
    > problem?


    The general solution for any threaded code making calls to a non-thread
    safe library is to do one of the following:

    (a) Make calls into the library (callbacks in your case) from
    only a single thread.
    or (b) Serialize calls to the library by using a mutex of some type.

    --
    -- Jim Weirich http://onestepback.org
    -----------------------------------------------------------------
    "Beware of bugs in the above code; I have only proved it correct,
    not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)
     
    Jim Weirich, Sep 4, 2003
    #3
  4. > The general solution for any threaded code making calls to a non-thread
    > safe library is to do one of the following:
    >
    > (a) Make calls into the library (callbacks in your case) from
    > only a single thread.
    > or (b) Serialize calls to the library by using a mutex of some type.


    Got it!

    Thomas
     
    Thomas Sondergaard, Sep 4, 2003
    #4

  5. > Run the ruby interpreter in a particular os-thread, and use
    > system provided queue.


    Could you give me an example of such a system provided queue?

    Cheers,

    Thomas
     
    Thomas Sondergaard, Sep 4, 2003
    #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. Hans

    What is thread safety?

    Hans, Oct 11, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    585
    Sahil Malik
    Oct 12, 2004
  2. Replies:
    3
    Views:
    762
    Ziga Seilnacht
    Jan 3, 2007
  3. Thomas Sondergaard
    Replies:
    5
    Views:
    143
    Simon Kitching
    Sep 24, 2003
  4. Replies:
    4
    Views:
    98
    Robert Klemme
    Jan 23, 2006
  5. -= Ko =- Black Ninja
    Replies:
    1
    Views:
    317
    -= Ko =- Black Ninja
    Apr 5, 2011
Loading...

Share This Page