Ruby interpreter thread safety

  • Thread starter Thomas Sondergaard
  • Start date
T

Thomas Sondergaard

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
 
N

nobu.nokada

Hi,

At Thu, 4 Sep 2003 19:45:24 +0900,
Thomas said:
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.
 
J

Jim Weirich

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.
 
T

Thomas Sondergaard

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
 
T

Thomas Sondergaard

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top