All Manuals > LispWorks User Guide and Reference Manual > 38 The HCL Package

NextPrevUpTopContentsIndex

add-special-free-action

Function
Summary

Adds a function to perform a special action during garbage collection.

Package

hcl

Signature

add-special-free-action function => function-list

Arguments

function

A function designator for a function of one argument.

Values

function-list

A list of the functions currently called to perform special actions, including the one just added.

Description

When some objects are garbage collected, you may require a "special action" to be performed as well. add-special-free-action adds the function function to perform the special action. Note that the function is applied to all objects flagged for special-free-action, so the function function should check for the object's type, so that it only affects relevant objects. Also, it should be fast when called with other objects.

The functions flag-special-free-action and flag-not-special-free-action flag and unflag objects for action.

When function is called, the object is still alive but is no longer flagged for special free action. Normally, the object will be collected on the next garbage collection cycle, but you can also store it somewhere which will prevent this. It may even be passed to flag-special-free-action again.

Example
(defun free-my-app (object)
  (when (my-app-p object)
    (free-some-external-resources object)))
 
(add-special-free-action 'free-my-app)
See also

remove-special-free-action
flag-special-free-action
flag-not-special-free-action


LispWorks User Guide and Reference Manual - 20 Sep 2017

NextPrevUpTopContentsIndex