#| -*-Scheme-*-
-$Id: gcfinal.scm,v 14.5 2003/02/14 18:28:32 cph Exp $
+$Id: gcfinal.scm,v 14.6 2003/06/08 04:07:08 cph Exp $
-Copyright (c) 2000, 2002 Massachusetts Institute of Technology
+Copyright 2000,2002,2003 Massachusetts Institute of Technology
This file is part of MIT/GNU Scheme.
(set-gc-finalizer-items! finalizer next))
(procedure (weak-cdr (car items))))
(loop (cdr items) items)))))))))
-
+\f
(define (remove-all-from-gc-finalizer! finalizer)
(guarantee-gc-finalizer finalizer 'REMOVE-ALL-FROM-GC-FINALIZER!)
(let ((procedure (gc-finalizer-procedure finalizer)))
(if (weak-pair/car? item)
(procedure (weak-cdr item)))
(loop)))))))))
-\f
+
(define (search-gc-finalizer finalizer predicate)
(guarantee-gc-finalizer finalizer 'SEARCH-GC-FINALIZER)
(without-interrupts
objects)))
(reverse! objects))))))
+(define (make-gc-finalized-object finalizer get-context context->object)
+ ;; A bunch of hair to permit microcode descriptors be opened with
+ ;; interrupts turned on, yet not leave a dangling descriptor around
+ ;; if the open is interrupted before the runtime system's data
+ ;; structures are updated.
+ (guarantee-gc-finalizer finalizer 'MAKE-GC-FINALIZED-OBJECT)
+ (let ((p (weak-cons #f #f)))
+ (dynamic-wind
+ (lambda () unspecific)
+ (lambda ()
+ (and (get-context p)
+ (let ((context (weak-cdr p)))
+ (let ((object (context->object context)))
+ (without-interrupts
+ (lambda ()
+ (weak-set-cdr! p object)
+ (set-gc-finalizer-items!
+ finalizer
+ (cons p (gc-finalizer-items finalizer)))))
+ object))))
+ (lambda ()
+ (if (and (not (weak-pair/car? p)) (weak-cdr p))
+ (begin
+ ((gc-finalizer-procedure finalizer) (weak-cdr p))
+ (weak-set-cdr! p #f)))))))
+\f
(define gc-finalizers)
(define (reset-gc-finalizers)
#| -*-Scheme-*-
-$Id: runtime.pkg,v 14.445 2003/04/17 02:52:12 cph Exp $
+$Id: runtime.pkg,v 14.446 2003/06/08 04:07:12 cph Exp $
Copyright 1988,1989,1990,1991,1992,1993 Massachusetts Institute of Technology
Copyright 1994,1995,1996,1997,1998,1999 Massachusetts Institute of Technology
add-to-gc-finalizer!
gc-finalizer-elements
gc-finalizer?
+ make-gc-finalized-object
make-gc-finalizer
remove-all-from-gc-finalizer!
remove-from-gc-finalizer!