[#1816] Ruby 1.5.3 under Tru64 (Alpha)? — Clemens Hintze <clemens.hintze@...>

Hi all,

17 messages 2000/03/14

[#1989] English Ruby/Gtk Tutorial? — schneik@...

18 messages 2000/03/17

[#2241] setter() for local variables — ts <decoux@...>

18 messages 2000/03/29

[ruby-talk:01658] Ruby: GC control and thread safety

From: Yukihiro Matsumoto <matz@...>
Date: 2000-03-01 08:22:47 UTC
List: ruby-talk #1658
The following message is a courtesy copy of an article
that has been posted to comp.lang.misc as well.

Hi,

Dave Thomas <Dave@Thomases.com> writes:

|I was playing with weak references, and came up with a problem with
|garbage collection control. It goes something like this:
|
|There are two ways to check for the validity of a weak reference.
|
|1. Use it, and rescue a WeakRef::RefError exception
|
|2. Check that it is valid using weakref_valid?
|
|If I wanted to use weakref_valid?, and not exceptions, it seems to me
|I'd have to disable GC around the use. In a single threaded program, I 
|could use something like:

weakref_valid? cannot assure more than validness at the specific moment.
In such racy condition, I think you have to rely on exceptions.

|So... Am I making this too complicated? Is there an easier/better way
|to control GC in a multi-threaded application? Or, alternatively,
|should the nesting count be added to the existing GC module?

I don't want to be under such circumstance where several threads need
to disable GC, which I think should be avoided.  Let's discuss about
it.  If it is needed, adding nesting count to GC.{enable,disable} is
pretty easy.

							matz.

In This Thread