# HG changeset patch # User michaels # Date 1059228083 0 # Node ID 75b8038f720e16154aab5b7da4d2d3fb4964f5aa # Parent 03009473262aa0848333ab288d028f3d2f9182fe [xemacs-hg @ 2003-07-26 14:01:23 by michaels] 2003-07-24 Mike Sperber * post-gc.el (simple-finalizer-ephemerons): (add-finalizer): (cleanup-simple-finalizers): Implement simple object finalization. diff -r 03009473262a -r 75b8038f720e lisp/ChangeLog --- a/lisp/ChangeLog Sat Jul 26 14:00:28 2003 +0000 +++ b/lisp/ChangeLog Sat Jul 26 14:01:23 2003 +0000 @@ -1,3 +1,9 @@ +2003-07-24 Mike Sperber + + * post-gc.el (simple-finalizer-ephemerons): + (add-finalizer): + (cleanup-simple-finalizers): Implement simple object finalization. + 2003-07-19 Stephen Turnbull * etags.el: Change `\\s ' in comments to `\\s-'. diff -r 03009473262a -r 75b8038f720e lisp/post-gc.el --- a/lisp/post-gc.el Sat Jul 26 14:00:28 2003 +0000 +++ b/lisp/post-gc.el Sat Jul 26 14:01:23 2003 +0000 @@ -45,5 +45,26 @@ (add-hook 'post-gc-hook 'run-finalizers) +(defvar simple-finalizer-ephemerons '() + "List of ephemerons for objects that have a finalizer attached..") - +(defun add-finalizer (object func) + "Add FUNC as a finalizer for object OBJECT." + (setq simple-finalizer-ephemerons + (cons (make-ephemeron object object func) + simple-finalizer-ephemerons))) + +(defun cleanup-simple-finalizers (alist) + "Clean up `simple-finalizer-ephemerons'." + ;; We have to do this by hand because DELETE-IF isn't defined yet. + (let ((current simple-finalizer-ephemerons) + (prev nil)) + (while (not (null current)) + (if (not (ephemeron-ref (car current))) + (if (null prev) + (setq simple-finalizer-ephemerons (cdr current)) + (setcdr prev (cdr current))) + (setq prev current)) + (setq current (cdr current))))) + +(add-hook 'post-gc-hook 'cleanup-simple-finalizers)