Destructors and Deterministic Memory Management
    Daniel Keep 
    daniel.keep.lists at gmail.com
       
    Tue May  5 02:13:24 PDT 2009
    
    
  
Sean Kelly wrote:
> ...
> 
> import core.runtime;
> 
> interface Disposable
> {
>     void dispose();
> }
> 
> bool handler( Object o )
> {
>     auto d = cast(Disposable) o;
> 
>     if( d !is null )
>     {
>         d.dispose();
>         return false;
>     }
>     return true;
> }
> 
> static this()
> {
>     Runtime.collectHandler = &handler;
> }
> 
> If you return false from your collectHandler then the runtime won't call
> the object's dtor.
:O
?cookie SeanK
  -- Daniel
    
    
More information about the Digitalmars-d
mailing list