changeset 1591:75b8038f720e

[xemacs-hg @ 2003-07-26 14:01:23 by michaels] 2003-07-24 Mike Sperber <mike@xemacs.org> * post-gc.el (simple-finalizer-ephemerons): (add-finalizer): (cleanup-simple-finalizers): Implement simple object finalization.
author michaels
date Sat, 26 Jul 2003 14:01:23 +0000
parents 03009473262a
children edff412c6744
files lisp/ChangeLog lisp/post-gc.el
diffstat 2 files changed, 28 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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  <mike@xemacs.org>
+
+	* post-gc.el (simple-finalizer-ephemerons): 
+	(add-finalizer):
+	(cleanup-simple-finalizers): Implement simple object finalization.
+
 2003-07-19  Stephen Turnbull  <stephen@xemacs.org>
 
 	* etags.el: Change `\\s ' in comments to `\\s-'.
--- 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)