[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

strong ref from weak ref?

Navindra Umanee

2/12/2005 4:04:00 PM

Hi,

I would like to have a lookup table with WeakRefs to various
structures so that they can be GC'ed if Ruby is low on space.

However, when I look up a structure, I want to get a strong ref from
the WeakRef so that I don't have to worry about it being collected
while being used.

I can seem to find any methods to get the strong ref from the WeakRef.
Maybe this can be done by having a second lookup table with WeakRefs
pointing to strong refs. I don't know if that will mess up the GC
though.

Any ideas?

Thanks,
Navin.


2 Answers

Florian Gross

2/12/2005 4:58:00 PM

0

Navindra Umanee wrote:

> I would like to have a lookup table with WeakRefs to various
> structures so that they can be GC'ed if Ruby is low on space.
>
> However, when I look up a structure, I want to get a strong ref from
> the WeakRef so that I don't have to worry about it being collected
> while being used.

I think WeakRef#__getobj__ will do what you want.

Navindra Umanee

2/12/2005 5:06:00 PM

0

Florian Gross <flgr@ccan.de> wrote:
> I think WeakRef#__getobj__ will do what you want.

Oh... ooops. Thanks, I should have seen that.

Cheers,
Navin.