Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
cmucl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Carl Shapiro
cmucl
Commits
4f4dc6af
Commit
4f4dc6af
authored
33 years ago
by
wlott
Browse files
Options
Downloads
Patches
Plain Diff
Initial revision
parent
db5aa3f4
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
code/final.lisp
+60
-0
60 additions, 0 deletions
code/final.lisp
with
60 additions
and
0 deletions
code/final.lisp
0 → 100644
+
60
−
0
View file @
4f4dc6af
;;; -*- Package: EXTENSIONS -*-
;;;
;;; **********************************************************************
;;; This code was written as part of the CMU Common Lisp project at
;;; Carnegie Mellon University, and has been placed in the public domain.
;;; If you want to use this code or any part of CMU Common Lisp, please contact
;;; Scott Fahlman or slisp-group@cs.cmu.edu.
;;;
(
ext:file-comment
"$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/final.lisp,v 1.1 1991/11/16 01:59:18 wlott Exp $"
)
;;;
;;; **********************************************************************
;;;
;;; Finalization based on weak pointers. Written by William Lott, but
;;; the idea really was Chris Hoover's.
;;;
(
in-package
"EXTENSIONS"
)
(
export
'
(
finalize
cancel-finalization
))
(
defvar
*objects-pending-finalization*
nil
)
(
defun
finalize
(
object
function
)
"Arrage for FUNCTION to be called when there are no more references to
OBJECT."
(
declare
(
type
function
function
))
(
system:without-gcing
(
push
(
cons
(
make-weak-pointer
object
)
function
)
*objects-pending-finalization*
))
object
)
(
defun
cancel-finalization
(
object
)
"Cancel any finalization registers for OBJECT."
(
when
object
;; We check to make sure object isn't nil because if there are any
;; broken weak pointers, their value will show up as nil. Therefore,
;; they would be deleted from the list, but not finalized. Broken
;; weak pointers shouldn't be left in the list, but why take chances?
(
system:without-gcing
(
setf
*objects-pending-finalization*
(
delete
object
*objects-pending-finalization*
:key
#'
(
lambda
(
pair
)
(
values
(
weak-pointer-value
(
car
pair
))))))))
nil
)
(
defun
finalize-corpses
()
(
setf
*objects-pending-finalization*
(
delete-if
#'
(
lambda
(
pair
)
(
multiple-value-bind
(
object
valid
)
(
weak-pointer-value
(
car
pair
))
(
declare
(
ignore
object
))
(
unless
valid
(
funcall
(
cdr
pair
))
t
)))
*objects-pending-finalization*
))
nil
)
(
pushnew
'finalize-corpses
*after-gc-hooks*
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment