draft proposal for ref counting in D

Walter Bright newshound2 at digitalmars.com
Wed Oct 9 19:34:04 PDT 2013


Steven Schveighoffer wrote:

On Jul 1, 2013, at 3:11 AM, Walter Bright wrote:

 >
 > On 6/30/2013 7:36 PM, Steven Schveighoffer wrote:
 >> I think that's a tall order presently.  For instance, on linux, the threads 
are all stopped using a signal.  It's a very bad idea to run destructors in a 
signal handler.
 >>
 >> What it seems like you are saying is that a prerequisite for ref counting is 
to have thread-local GC working.  If that is the case, we need to start a 
thread-local GC "thread" before this goes any further.
 >
 > Not really. This doesn't make anything worse. Also, the proposed solution to 
this issue is to post the "destruct" list to the appropriate thread, and that 
thread runs it next time it calls the GC.

I really urge you to make this a separate project.  It's not trivial. 
Logically, it's sound, but the implementation will be very difficult.  I also 
think Sean (and probably others) should be involved for that discussion.

 >>
 >> Pragmatically, I think if D targets x86 variants and ARM, it is 
well-situated in the mainstream of existing devices.  Yes, it would be nice if 
it could target other obscure platforms, but if we are talking ref counting 
works poorly on those, I don't think we are any worse off than today.  Note that 
we can keep the options open, and implement atomic RC now without many headaches.
 >>
 >
 > We don't need to require atomic RC for these.

I didn't say that.  I said we could implement atomic RC without any changes to 
the GC, and worry about optimizing with non-atomic RC later.  As long as we make 
it *possible*.

-Steve


More information about the Digitalmars-d mailing list