[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ruby-talk
Subject:    Re: newbie: embedding ruby and garbage collection
From:       "Baptiste Lepilleur" <gaiacrtn () free ! fr>
Date:       2002-04-30 16:43:05
[Download RAW message or body]

While struggling with some bugs that appeared during GC, I found the
following functions that do what I wanted (in fact rb_global_variable
forward to rb_gc_register_address() ):

rb_gc_register_address( VALUE *)
rb_gc_register_address( VALUE *)

Baptiste.

----- Original Message -----
From: "Baptiste Lepilleur" <gaiacrtn@free.fr>
To: "ruby-talk ML" <ruby-talk@ruby-lang.org>
Sent: Saturday, April 27, 2002 1:10 PM
Subject: Re: newbie: embedding ruby and garbage collection


> Thanks. After looking at Data_Wrap_Struct implementation, I saw that the
> 'mark' callback was tied with a ruby object, so I went for the global
> variable trick.
>
> Baptiste.
>
> ----- Original Message -----
> From: "ts" <decoux@moulon.inra.fr>
> To: "ruby-talk ML" <ruby-talk@ruby-lang.org>
> Cc: <ruby-talk@ruby-lang.org>
> Sent: Friday, April 26, 2002 5:49 PM
> Subject: Re: newbie: embedding ruby and garbage collection
>
>
> > >>>>> "B" == Baptiste Lepilleur <gaiacrtn@free.fr> writes:
> >
> > B> What I'm looking for is a way to register a 'mark' callback similar
to
> the
> > B> one passed to Data_Wrap_Structure, an unregister it at a later time.
> That
> > B> way, I would be able to register the callback when MyObject is
> instantiated,
> > B> and unregister the same callback when the instance of MyObject is
> destroyed.
> >
> >  Rather than register a callback, you can  just create an object (with
> >  Data_Wrap_struct) and store it in a Hash or Array (declared with
> >  rb_global_variable()).
> >
> >  When the instance of MyObject is destroyed, you just remove this object
> >  from the hash (or the array).
> >
> >
> > Guy Decoux
> >
> >
> >
> >
> >
> >
>
>

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic