home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / pcl / src-16f.lha / code / scavhook.lisp < prev    next >
Encoding:
Text File  |  1992-05-30  |  2.0 KB  |  56 lines

  1. ;;; -*- Package: EXT -*-
  2. ;;;
  3. ;;; **********************************************************************
  4. ;;; This code was written as part of the CMU Common Lisp project at
  5. ;;; Carnegie Mellon University, and has been placed in the public domain.
  6. ;;; If you want to use this code or any part of CMU Common Lisp, please contact
  7. ;;; Scott Fahlman or slisp-group@cs.cmu.edu.
  8. ;;;
  9. (ext:file-comment
  10.   "$Header: scavhook.lisp,v 1.1 91/07/30 00:40:04 wlott Exp $")
  11. ;;;
  12. ;;; **********************************************************************
  13. ;;;
  14. ;;; This file implements the ``Scavenger Hook'' extension.
  15. ;;;
  16. ;;; Written by William Lott
  17. ;;;
  18.  
  19. (in-package "EXT")
  20.  
  21. (export '(scavenger-hook scavenger-hook-p make-scavenger-hook
  22.       scavenger-hook-value scavenger-hook-function))
  23.  
  24. (defun scavenger-hook-p (object)
  25.   "Returns T if OBJECT is a scavenger-hook, and NIL if not."
  26.   (scavenger-hook-p object))
  27.  
  28. (defun make-scavenger-hook (&key value (function (required-argument)))
  29.   "Create a new scavenger-hook with the specified VALUE and FUNCTION.  For
  30.    as long as the scavenger-hook is alive, the scavenger in the garbage
  31.    collector will note whenever VALUE is moved, and arrange for FUNCTION
  32.    to be funcalled."
  33.   (declare (type function function))
  34.   (c::%make-scavenger-hook value function))
  35.  
  36. (defun scavenger-hook-value (scavhook)
  37.   "Returns the VALUE being monitored by SCAVHOOK.  Can be setf."
  38.   (declare (type scavenger-hook scavhook))
  39.   (scavenger-hook-value scavhook))
  40.  
  41. (defun (setf scavenger-hook-value) (value scavhook)
  42.   (declare (type scavenger-hook scavhook))
  43.   (setf (scavenger-hook-value scavhook) value))
  44.  
  45. (defun scavenger-hook-function (scavhook)
  46.   "Returns the FUNCTION invoked when the monitored value is moved.  Can be
  47.    setf."
  48.   (declare (type scavenger-hook scavhook))
  49.   (scavenger-hook-function scavhook))
  50.  
  51. (defun (setf scavenger-hook-function) (function scavhook)
  52.   (declare (type function function)
  53.        (type scavenger-hook scavhook))
  54.   (setf (scavenger-hook-function scavhook) function))
  55.  
  56.