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

Contents of /src/code/weak.lisp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4.2.1 - (show annotations)
Tue May 23 16:36:57 2000 UTC (13 years, 10 months ago) by pw
Branch: RELENG_18
CVS Tags: RELEASE_18d, RELEASE_18c
Changes since 1.4: +13 -2 lines
This set of revisions brings the RELENG_18 branch up to HEAD in preparation
for an 18c release.
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.2.1 2000/05/23 16:36:57 pw Exp $")
9 ;;;
10 ;;; **********************************************************************
11 ;;;
12 ;;; $Header: /tiger/var/lib/cvsroots/cmucl/src/code/weak.lisp,v 1.4.2.1 2000/05/23 16:36:57 pw 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))))
42
43 ;;; For the interpreter..
44
45 (defun c::%weak-pointer-value (w)
46 (declare (type weak-pointer w))
47 (c::%weak-pointer-value w))
48
49 (defun c::%weak-pointer-broken (w)
50 (declare (type weak-pointer w))
51 (c::%weak-pointer-broken w))
52

  ViewVC Help
Powered by ViewVC 1.1.5