[Issue 4621] Destructors are inherently un- at safe

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Aug 12 07:46:24 PDT 2010


http://d.puremagic.com/issues/show_bug.cgi?id=4621



--- Comment #14 from Michel Fortin <michel.fortin at michelf.com> 2010-08-12 10:46:23 EDT ---
(In reply to comment #13)
> This isn't so much of a problem if you assume objects with finalizers are rare.
> They can be collected in the next GC cycle.

I'm not sure we can make this assumption.

Beside, is it worth it? I mean, what is the use of a resurrected object beyond
providing a little more safety? Given the multithreading model, we know
finalizers can't be made safe; them being half-safer doesn't bring us much.

> Good point. By definition, if the object is not shared(), the finalizer (or
> anything) must not run on a different thread. It doesn't matter if you access
> references or not. I wonder how D2 can have finalizers at all with this.

Well, the object's memory block itself is no longer referenced by other threads
(otherwise it would not be collected), so I guess as long as you only access
values inside this memory block you're safe. You can probably also access
non-GC memory you're the sole owner of, or non-GC shared memory. But you
shouldn't access non-shared globals, or non-shared memory that someone else
could have a reference to. This is starting to be really complicated, but
except for the non-GC memory part it looks quite similar to the restrictions
applied to methods of a synchronized class.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list