RetroZilla/extensions/xmlterm/doc/FinalizeXPCOM
2015-10-20 23:03:22 -04:00

32 lines
1.5 KiB
Plaintext

"Finalize tree" to break XPCOM cycles and have clean shutdowns
--------------------------------------------------------------
XMLterm class embedding hierarchy
=================================
mozXMLTermShell (or ../geckoterm/mozGeckoTerm)
|
|
mozXMLTerminal
+-----------------+----------------+
| | |
mozXMLTermSession mozLineTermAux mozXMLTermListeners
| |
| |
mozXMLTermStream... (lineterm)
We would like to have clean shutdowns of an XMLterm, since we are using
external resources, e.g., a shell process or an rlogin process. However, the
XPCOM reference counting can hinder shutdowns, if there cycles. To avoid
that, the XMLterm interfaces have a Finalize or Close method. A shutdown
event triggers a call to the Finalize method of the root interface in the
"Finalize tree". When the Finalize method of any interface is called, it
first calls the Finalize methods of any child nodes in the Finalize tree, then
releases all the XPCOM references it owns, de-initializes itself and quietly
waits for its reference count to go to zero. In this "closed" state of the
interface, any attempts use it result in an error return.
The destructor of an object simply checks if all its interfaces have been
finalized, and calls the Finalize methods for any that have not been.
--