GC object finalization not guaranteed
Leandro Lucarella
llucax at gmail.com
Sat Apr 18 15:45:59 PDT 2009
Leandro Lucarella, el 18 de abril a las 19:36 me escribiste:
> Rainer Deyke, el 18 de abril a las 16:18 me escribiste:
> > Leandro Lucarella wrote:
> > > You missed the point. I'm not talking about freeing the memory. I'm
> > > talking about finalizers. A finalizer could send a "bye" packet throgh the
> > > net. That can't be handled by the OS.
> >
> > It can't be handled by the GC either, because:
> > - This would require a high-level wrapper that knows about the "bye"
> > packet around a low-level socket that doesn't know. By the time the
> > high-level wrapper is finalized, the low-level socket may already have
> > been collected.
>
> I don't know what you are talking about, I'm talking about this:
>
> class X {
>
> //...
>
> ~this()
> {
> socket.send(bye_packet);
> socket.close();
> }
Ok, socket can be collected when the destructor of X is called. Now I get
you point.
I still think having guaranteed finalization make the language much more
robust, though. And it's easily doable, I don't see why it's not done.
--
Leandro Lucarella (luca) | Blog colectivo: http://www.mazziblog.com.ar/blog/
----------------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145 104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------------
DONAN UN PENE EN NICARAGUA
-- Crónica TV
More information about the Digitalmars-d
mailing list