GC for pure functions -- implementation ideas

Steven Schveighoffer schveiguy at yahoo.com
Mon Apr 18 05:33:40 PDT 2011


On Mon, 18 Apr 2011 08:27:25 -0400, Steven Schveighoffer  
<schveiguy at yahoo.com> wrote:

> On Sun, 17 Apr 2011 14:08:29 -0400, Michel Fortin  
> <michel.fortin at michelf.com> wrote:
>
>> On 2011-04-17 05:22:10 -0400, Fawzi Mohamed <fawzi at gmx.ch> said:
>>
>>> All this comes back again to having several pools, showing how useful
>>> such a primitive is.
>>
>> Speaking of rethinking the GC and its primitives, is there a way  
>> currently to tell the GC to track pointers to a manually allocated  
>> block and assign a callback for when the GC wants that block to be  
>> finalized and deallocated? I'm kinda going to need that if I am to  
>> bring decent garbage-collected Objective-C objects in D.
>>
>
> It's coarsely grained, but you can intercept all finalization calls:
>
> http://www.digitalmars.com/d/2.0/phobos/core_runtime.html#collectHandler
>
> You'd have to figure out some way to filter only the ones you care about.


Also, there's an undocumented, non-published (i.e. not in object.di)  
function that allows you to attach an event handler when an object is  
disposed:

https://github.com/D-Programming-Language/druntime/blob/master/src/object_.d#L2394

I think Bill Baxter's WeakRef object used it.  I'm not sure how supported  
it is, or why it isn't public.

-Steve


More information about the Digitalmars-d mailing list