Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Ruby interpreter thread safety

Reply
Thread Tools

Ruby interpreter thread safety

 
 
Thomas Sondergaard
Guest
Posts: n/a
 
      09-04-2003
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


 
Reply With Quote
 
 
 
 
nobu.nokada@softhome.net
Guest
Posts: n/a
 
      09-04-2003
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

 
Reply With Quote
 
 
 
 
Jim Weirich
Guest
Posts: n/a
 
      09-04-2003
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)

 
Reply With Quote
 
Thomas Sondergaard
Guest
Posts: n/a
 
      09-04-2003
> 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


 
Reply With Quote
 
Thomas Sondergaard
Guest
Posts: n/a
 
      09-04-2003

> 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


 
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
How to call Ruby from non-interpreter native thread? -= Ko =- Black Ninja Ruby 1 04-05-2011 07:31 AM
Python embedded interpreter: how to initialize the interpreter ? ycollet@freesurf.fr Python 3 01-03-2007 01:00 AM
Ruby Extensions and Thread Safety kapil.surlaker@gmail.com Ruby 4 01-23-2006 08:32 AM
What is thread safety? Hans ASP .Net 1 10-12-2004 03:15 PM
Thread safety: Serializing access to ruby interpreter- again Thomas Sondergaard Ruby 5 09-24-2003 10:06 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57