trivial-garbage is a simple library that provides a portable API to finalizers, weak hash-tables and weak pointers.
It is placed in the public domain with absolutely no warranty.
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
— 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 &allow-other-keys
Returns a new weak hash table. In addition to the standard arguments accepted by CL:MAKE-HASH-TABLE, this function an extra keyword :WEAKNESS that determines the kind of weak table it should create. 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.
CLiki pages can be edited by anyone at any time. Imagine a fearsomely comprehensive disclaimer of liability. Now fear, comprehensively