[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Destructors & CLOS?

I'm wondering if there's anything in CLOS that's equivalent to the
destructor functions found in C++. I have a library which connects to
a remote service and allocates several context areas on the server. I
have CLOS objects that represent the connection and context areas.
Each connection object maintains a list of all the associated context
objects. Both the connection objects and context area objects contain
macptrs that reference non-relocatable data in the Mac heap.

Is there any way to insure that when an application that uses my
library quits all context areas are freed properly and all connections
closed gracefully? What kind of a monkey wrench does garbage
collection throw into this whole problem? If a program "forgets" about
a connection, will the connection and context area objects get garbage
collected? This would leave me with open network connections and
unreachable objects in the Mac heap :-(

One obvious solution to the garbage collection problem is for my
library to keep at list of all open connections. If a user calls my
close connection function, I can clean up properly and remove the
object from the list. Is there any way to run through the list an
close all the connections before an application exits? Something like
the on_exit() or atexit() functions provided in C?

Thanks for any help!

							-- Scott
"The only thing necessary for the triumph	"DOS is proof that there *is*
 of evil is for good men to do nothing."	 Evil in the world."
			-- Edmund Burke			-- James Plamondon