The trivial-garbage Reference Manual

This is the trivial-garbage Reference Manual, generated automatically by Declt version 4.0 beta 2 "William Riker" on Mon Feb 26 18:07:35 2024 GMT+0.

Table of Contents


1 Introduction


2 Systems

The main system appears first, followed by any subsystem dependency.


2.1 trivial-garbage

Portable finalizers, weak hash-tables and weak pointers.

Author

Luis Oliveira <>

License

Public Domain

Source

trivial-garbage.asd.

Child Component

trivial-garbage.lisp (file).


3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


3.1 Lisp


3.1.1 trivial-garbage/trivial-garbage.asd

Source

trivial-garbage.asd.

Parent Component

trivial-garbage (system).

ASDF Systems

trivial-garbage.


3.1.2 trivial-garbage/trivial-garbage.lisp

Source

trivial-garbage.asd.

Parent Component

trivial-garbage (system).

Packages

trivial-garbage.

Public Interface
Internals

4 Packages

Packages are listed by definition order.


4.1 trivial-garbage

@a[http://common-lisp.net/project/trivial-garbage]{trivial-garbage}
provides a portable API to finalizers, weak hash-tables and weak
pointers on all major implementations of the Common Lisp
programming language. For a good introduction to these
data-structures, have a look at @a[http://www.haible.de/bruno/papers/cs/weak/WeakDatastructures-writeup.html]{Weak
References: Data Types and Implementation} by Bruno Haible.

Source code is available at
@a[https://github.com/trivial-garbage/trivial-garbage]{github},
which you are welcome to use for submitting patches and/or @a[https://github.com/trivial-garbage/trivial-garbage/issues]{bug
reports}. Discussion takes place on @a[http://lists.common-lisp.net/cgi-bin/mailman/listinfo/trivial-garbage-devel]{trivial-garbage-devel at common-lisp.net}.

@a[http://common-lisp.net/project/trivial-garbage/releases/]{Tarball
releases} are available, but the easiest way to install this
library is via @a[http://www.quicklisp.org/]{Quicklisp}:
@code{(ql:quickload :trivial-garbage)}.

@begin[Weak Pointers]{section}
A @em{weak pointer} holds an object in a way that does not prevent
it from being reclaimed by the garbage collector. An object
referenced only by weak pointers is considered unreachable (or
"weakly reachable") and so may be collected at any time. When
that happens, the weak pointer’s value becomes @code{nil}.

@aboutfun{make-weak-pointer}
@aboutfun{weak-pointer-value}
@aboutfun{weak-pointer-p}
@end{section}

@begin[Weak Hash-Tables]{section}
A @em{weak hash-table} is one that weakly references its keys
and/or values. When both key and value are unreachable (or weakly
reachable) that pair is reclaimed by the garbage collector.

@aboutfun{make-weak-hash-table}
@aboutfun{hash-table-weakness}
@end{section}

@begin[Finalizers]{section}
A @em{finalizer} is a hook that is executed after a given object
has been reclaimed by the garbage collector.

@aboutfun{finalize}
@aboutfun{cancel-finalization}
@end{section}

Source

trivial-garbage.lisp.

Nickname

tg

Use List

common-lisp.

Public Interface
Internals

5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


5.1 Public Interface


5.1.1 Ordinary functions

Function: cancel-finalization (object)

Cancels all of @code{object}’s finalizers, if any.

Package

trivial-garbage.

Source

trivial-garbage.lisp.

Function: finalize (object function)

Pushes a new @code{function} to the @code{object}’s list of finalizers. @code{function} should take no arguments. Returns @code{object}.

@b{Note:} @code{function} should not attempt to look at @code{object} by closing over it because that will prevent it from being garbage collected.

Package

trivial-garbage.

Source

trivial-garbage.lisp.

Function: gc (&key full verbose)

Initiates a garbage collection. @code{full} forces the collection of all generations, when applicable. When @code{verbose} is @em{true}, diagnostic information about the collection is printed if possible.

Package

trivial-garbage.

Source

trivial-garbage.lisp.

Function: hash-table-weakness (ht)

Returns one of @code{nil}, @code{:key}, @code{:value}, @code{:key-or-value} or @code{:key-and-value}.

Package

trivial-garbage.

Source

trivial-garbage.lisp.

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

Returns a new weak hash table. In addition to the standard arguments accepted by @code{cl:make-hash-table}, this function adds extra keywords: @code{:weakness} being the kind of weak table it should create, and @code{:weakness-matters} being whether an error should be signalled when that weakness isn’t available (the default is to signal an error). @code{weakness} can be one of @code{:key}, @code{:value}, @code{:key-or-value}, @code{:key-and-value}.

If @code{weakness} is @code{:key} or @code{:value}, an entry is kept as long as its key or value is reachable, respectively. If @code{weakness} is @code{:key-or-value} or @code{:key-and-value}, an entry is kept if either or both of its key and value are reachable, respectively.

@code{tg::make-hash-table} is available as an alias for this function should you wish to import it into your package and shadow @code{cl:make-hash-table}.

Package

trivial-garbage.

Source

trivial-garbage.lisp.

Function: make-weak-pointer (object)

Creates a new weak pointer which points to @code{object}. For portability reasons, @code{object} must not be @code{nil}.

Package

trivial-garbage.

Source

trivial-garbage.lisp.

Function: weak-pointer-p (object)

Returns @em{true} if @code{object} is a weak pointer and @code{nil} otherwise.

Package

trivial-garbage.

Source

trivial-garbage.lisp.

Function: weak-pointer-value (weak-pointer)

If @code{weak-pointer} is valid, returns its value. Otherwise, returns @code{nil}.

Package

trivial-garbage.

Source

trivial-garbage.lisp.


5.2 Internals


5.2.1 Special variables

Special Variable: *weakness-warnings*

List of weaknesses that have already been warned about this session. Used by ‘weakness-missing’.

Package

trivial-garbage.

Source

trivial-garbage.lisp.


5.2.2 Ordinary functions

Function: make-hash-table (&rest args)
Package

trivial-garbage.

Source

trivial-garbage.lisp.

Function: weakness-keyword-arg (weakness)
Package

trivial-garbage.

Source

trivial-garbage.lisp.

Function: weakness-keyword-opt (weakness errorp)
Package

trivial-garbage.

Source

trivial-garbage.lisp.

Function: weakness-missing (weakness errorp)

Signal an error or warning, depending on ERRORP, about lack of Lisp support for WEAKNESS.

Package

trivial-garbage.

Source

trivial-garbage.lisp.


Appendix A Indexes


A.1 Concepts


A.3 Variables

Jump to:   *  
S  
Index Entry  Section

*
*weakness-warnings*: Private special variables

S
Special Variable, *weakness-warnings*: Private special variables