Sockets and finalisation
Michael Roberts
mike at mjr104.co.uk
Thu Jan 22 21:11:33 UTC 2004
Hi,
I have been playing around with Sockets lately. I was wondering what the best way to handle cleaning them up was? This leads me on to ask whether there is a good reference somewhere for understanding Weak style objects and whether I should be using them.
If I have an object aNode that holds onto aSocket then I can do all sorts of things with the socket. If I forget about aNode, say because it was in an inspector, the socket is still around and survives any number of GCs. I think this is because it is registered externally? or something like that because of the socket plugin. I can clean up orphaned open sockets by doing something like
Socket allInstances do:[:s | s closeAndDestroy]
as long as I'm sure that I've created all the sockets. If I wanted the semantics that after dropping aNode I wanted to send closeAndDestroy to its socket I feel I might want to head in the area of finalisation but I don't know how to do this.
I notice that ConnectionQueue behaves the same way if I have one of those and forget about it. I've looked at the process code for this and have learnt quite a bit.
What is the best, or considered, way to handle processes in objects when you then forget about the object without cleaning up the process. If you have a process blocking on a semaphore I assume that it will never be GCd because, at least, the scheduler has got a hold of it. So should I also be looking at finalisation here?
thanks
Mike
More information about the Squeak-dev
mailing list
|