Ruling out arbitrary cost copy construction?

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Wed Oct 6 13:19:45 PDT 2010


On 10/6/10 14:09 CDT, Michel Fortin wrote:
> On 2010-10-06 12:34:54 -0400, Andrei Alexandrescu
> <SeeWebsiteForEmail at erdani.org> said:
>
>> 2. It would force certain types (such as BigInt) that allocate
>> resources and have value semantics to resort to reference counting.
>
> Also, before asking for more reference counting, perhaps you should
> check that bug and find a nice way to do reference counting correctly
> with no race conditions (unlike what's done in Phobos currently).
> <http://d.puremagic.com/issues/show_bug.cgi?id=4624>

I'm not sure the bug report is valid, but I agree it's a matter to look 
into.

> The most problematic thing with reference-counted memory is that the GC
> can call your struct's destructor from any thread which can cause
> low-level races if the reference counter isn't manipulated with atomic
> operations. And atomic operations slow things down, are you sure you
> want to force this in BigInt?

The GC shouldn't be able to destroy things naively concurrently with 
other threads. Currently all threads are frozen; I'm not sure whether a 
frozen thread commits its writes, so that needs to be verified.


Andrei


More information about the Digitalmars-d mailing list