Ruling out arbitrary cost copy construction?
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Thu Nov 4 12:55:07 PDT 2010
On 11/4/10 2:45 PM, Steven Schveighoffer wrote:
> On Thu, 04 Nov 2010 14:38:59 -0400, Andrei Alexandrescu
> <SeeWebsiteForEmail at erdani.org> wrote:
>> I think this can be made to work and has good properties, although a
>> fair amount of details need to be figured out. Please share any
>> thoughts you may have.
>
> What if a thread no longer exists? Would there be a way to mark such
> dtors that need this feature?
Probably a thread that dies (by crashing) will never call its destructors.
> I don't know, because it seems to me like
> a lot of band-aiding for something that is infrequently used (I've
> gotten along fine in D without reference counting for as long as I've
> used it).
If you use File, you use reference counting. We do need to define a
policy for copying expensive objects.
> You also need to provide a pointer in the object for a linked list for
> the work-list.
I think it's enough if the thread has the list, but I may as well be wrong.
> I'm thinking I would prefer to have the destructor and finalizer split,
> so the 'destructor' can tell whether it's being called synchronously or
> from the GC. Then the dtor itself can handle the whole worklist
> implementation.
>
> I guess the only extra thing you would need in addition to that is a
> hook so memory allocation from a given thread can be hooked to process
> the worklist. Or maybe the worklist becomes a standard feature of the
> thread class, and you manually add the task from the destructor instead
> of the GC doing it for you.
These are all interesting options. At the end of the day, what we want
to guarantee is no races in non-shared objects.
Andrei
More information about the Digitalmars-d
mailing list