trivial-garbage
trivial-garbage provides a portable API to finalizers, weak hash-tables and weak pointers.

It is placed in the public domain with absolutely no warranty.

ASDF-install package (obsolete) http://common-lisp.net/~loliveira/tarballs/trivial-garbage/trivial-garbage_latest.tar.gz

A darcs tree is available:
darcs get http://common-lisp.net/~loliveira/darcs/trivial-garbage/

Comments, suggestions and patches are welcome and can be sent to loliveira at common-lisp dot net

Documentation

— Function: tg:cancel-finalization object

Cancels all of OBJECT's finalizers, if any.

— Function: tg:finalize object function

Pushes a new FUNCTION to the OBJECT's list of finalizers. FUNCTION should take no arguments. Returns OBJECT.

For portability reasons, FUNCTION should not attempt to look at OBJECT by closing over it because, in some lisps, OBJECT will already have been garbage collected and is therefore not accessible when FUNCTION is invoked.

— Function: tg:gc &key full verbose

Initiates a garbage collection.

— Function: tg:hash-table-weakness ht

Returns one of NIL, :KEY, :VALUE, :KEY-OR-VALUE or :KEY-AND-VALUE.

— Function: tg:make-weak-hash-table &rest args &key weakness (weakness-matters t) &allow-other-keys

Returns a new weak hash table. In addition to the standard arguments accepted by CL:MAKE-HASH-TABLE, this function adds extra keywords: :WEAKNESS being the kind of weak table it should create, and :WEAKNESS-MATTERS being whether an error should be signalled when that weakness isn't available (the default is to signal an error). WEAKNESS can be one of :KEY, :VALUE, :KEY-OR-VALUE, :KEY-AND-VALUE.

TG::MAKE-HASH-TABLE is available as an alias for this function should you wish to import it into your package and shadow CL:MAKE-HASH-TABLE.

— Function: tg:make-weak-pointer object

Creates a new weak pointer which points to OBJECT. For portability reasons, OBJECT most not be NIL.

— Function: tg:weak-pointer-p object

Returns true if OBJECT is a weak pointer and NIL otherwise.

— Function: tg:weak-pointer-value weak-pointer

If WEAK-POINTER is valid, returns its value. Otherwise, returns NIL.


system programming