IDisposable interface (phobos patch)
James Dunne
james.jdunne at gmail.com
Wed Feb 22 21:50:39 PST 2006
A very alpha stage release of my Disposable interface for classes which
want guaranteed destruction on program termination. Currently it is
only for linux. It installs signal handlers before the app main is
called to trap seg faults and other nasty things.
The API needs a bit of work, as you have to call
std.disposable.markForDisposal(Disposable obj) in order to register an
object with the disposal handler. Similarly, unmarkForDisposal
unregisters an object.
Registering an object simply means that it will be put on the dispose
list to be disposed when the program is terminated. The disposal
iteration routine tries to guarantee disposal of all objects. The one
thing it cannot protect against, however, is a signal generated from
within a Dispose() method.
The interface name is Disposable, rather than IDisposable. I think (at
the time) I was worried about conflicts there.
With a bit more work I think it could make a valuable contribution to
Ares or Phobos.
NOTE: the patch modifies linux.mak, internal/dmain2.d, and
std/disposable.d (new file). Unfortunately the modifications to
linux.mak remove recls, since I had trouble compiling it under GCC 4.0.
However, they also add compilation of std/disposable.d to libphobos.
So, I guess beware.
--
Regards,
James Dunne
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: phobos-disposable-0.147.patch
Url: http://lists.puremagic.com/pipermail/digitalmars-d-announce/attachments/20060222/b4435226/attachment.ksh
More information about the Digitalmars-d-announce
mailing list