/[cmucl]/src/code/weak.lisp
ViewVC logotype

Contents of /src/code/weak.lisp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (show annotations)
Mon Oct 31 04:11:27 1994 UTC (19 years, 5 months ago) by ram
Branch: MAIN
CVS Tags: RELEASE_18a, RELEASE_18b
Branch point for: RELENG_18
Changes since 1.3: +2 -4 lines
Fix headed boilerplate.
1 ;;; -*- Mode: Lisp; Package: EXTENSIONS; Log: code.log -*-
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 ;;;
7 (ext:file-comment
8 "$Header: /tiger/var/lib/cvsroots/cmucl/src/code/weak.lisp,v 1.4 1994/10/31 04:11:27 ram Exp $")
9 ;;;
10 ;;; **********************************************************************
11 ;;;
12 ;;; $Header: /tiger/var/lib/cvsroots/cmucl/src/code/weak.lisp,v 1.4 1994/10/31 04:11:27 ram Exp $
13 ;;;
14 ;;; Weak Pointer Support.
15 ;;;
16 ;;; Written by Christopher Hoover.
17 ;;;
18
19 (in-package "EXTENSIONS")
20
21 (export '(weak-pointer weak-pointer-p make-weak-pointer weak-pointer-value))
22
23 (defun make-weak-pointer (object)
24 "Allocates and returns a weak pointer which points to OBJECT."
25 (declare (values weak-pointer))
26 (make-weak-pointer object))
27
28 (declaim (inline weak-pointer-value))
29 (defun weak-pointer-value (weak-pointer)
30 "If WEAK-POINTER is valid, returns the value of WEAK-POINTER and T.
31 If the referent of WEAK-POINTER has been garbage collected, returns
32 the values NIL and NIL."
33 (declare (type weak-pointer weak-pointer)
34 (values t (member t nil)))
35 ;; We don't need to wrap this with a without-gcing, because once we have
36 ;; extracted the value, our reference to it will keep the weak pointer
37 ;; from becoming broken. We just have to make sure the compiler won't
38 ;; reorder these primitives.
39 (let ((value (c::%weak-pointer-value weak-pointer))
40 (broken (c::%weak-pointer-broken weak-pointer)))
41 (values value (not broken))))

  ViewVC Help
Powered by ViewVC 1.1.5