Re: [Gc] When disappearing links are collecte d before their targets

Ivan Maidanski <ivmai-JGs/[email protected]>
Newsgroups gmane.comp.programming.garbage-collection.boehmgc
Message-ID <[email protected]>
Hi Jim,
Yes, you are right.
It is called dangling link - handled (unregistered) automatically except that if you want to manually free an object with a dissappearing link then you should unregister it manually before free.
Definitely,  documentation should be improved. I'll add info to gc.h.
Thank you
----
Thu, 30 Jan 2014г., 23:37 +04:00 from Jim Pryor <[email protected]>:
I'm just starting to work with the Boehm GC library, and am trying to
add weakref functionality to a project that already uses the main
functions of the library (including finalizers).
I think I've got a basic understanding of how
GC_general_register_disappearing_link and nearby functions work.
However, I wasn't able to tell from the comments or other documentation
what is the answer to this question:
If I create a disappearing link L to another object O, but then L ends
up being collected before O does, when the time comes around for O to be
collected, we obviously don't in that case want L to still be cleared.
So do I have to manually create a finalizer for L to
GC_unregister_disappearing_link it before it gets collected? Or does the
library take care of this automatically.
Looking at the source (finalizer.c): I haven't fully digested everything
here yet, but superficially at least it looks like the answer to my
question is that the library takes care of this automatically, when it
invokes the function GC_remove_dangling_disappearing_links.
I'm writing the list for two reasons: (1) to invite others to correct me
if I've misunderstood, and (2) to make this question and answer
available to others who might search for it. (I wasn't able to find any
explicit discussion of this in my own searches.) Perhaps (3) it'd be
good to add a sentence or two to the comments in gc.h (or finalize.c)
declaring explicitly that this is the designed behavior, and that one
doesn't need to manually unregister weakrefs on one's own, just before
they're collected.
--
[email protected]
_______________________________________________
Gc mailing list
[email protected]
http://www.hpl.hp.com/hosted/linux/mail-archives/gc/

_______________________________________________
Gc mailing list
Gc-V9/[email protected]
http://www.hpl.hp.com/hosted/linux/mail-archives/gc/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.