Resource Management... Howto?
downs
default_357-line at yahoo.de
Fri Jul 6 15:37:49 PDT 2007
I've been thinking about a better way to do this.
How about we (ab)use the GC? That is, each returned resource with the
same index contains a pointer to some throwaway object. This object's
address is stored together with the AA itself, but encoded somehow
(negative? xor with a constant?) so that the GC doesn't find this relation.
Now, whenever all resources of that type have been deleted, and the GC
runs, the object will not have anything obvious pointing towards it
anymore; thus, the GC will delete it. Before that, it will call the
object's destructor, which, in turn, will delete the object's entry from
the AA :)
--downs
PS: I have no idea if that could work; also, you'd be relying on the GC
which the spec says _not_ to rely upon. Evil :)
PPS: Not guaranteed to work. Use at own risk.
More information about the Digitalmars-d-learn
mailing list