From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Marius Vollmer Newsgroups: gmane.lisp.guile.user,gmane.lisp.guile.devel Subject: Re: The order of objects returned from a guardian Date: Mon, 01 Aug 2005 00:25:43 +0300 Message-ID: <87iryqacrs.fsf@zagadka.de> References: <873bq1gn15.fsf@zagadka.de> <42E95E34.10903@ossau.uklinux.net> <87oe8iai2h.fsf@zagadka.de> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1122845332 3287 80.91.229.2 (31 Jul 2005 21:28:52 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 31 Jul 2005 21:28:52 +0000 (UTC) Cc: guile-user@gnu.org, guile-devel@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Sun Jul 31 23:28:44 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1DzLMQ-0005xD-Rt for guile-user@m.gmane.org; Sun, 31 Jul 2005 23:28:43 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DzLP3-0001fQ-3r for guile-user@m.gmane.org; Sun, 31 Jul 2005 17:31:25 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1DzLNe-0001Bt-QU for guile-user@gnu.org; Sun, 31 Jul 2005 17:29:59 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1DzLNR-00014N-LK for guile-user@gnu.org; Sun, 31 Jul 2005 17:29:47 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DzLNR-00013a-C8 for guile-user@gnu.org; Sun, 31 Jul 2005 17:29:45 -0400 Original-Received: from [213.243.153.37] (helo=smtp1.pp.htv.fi) by monty-python.gnu.org with esmtp (Exim 4.34) id 1DzLVV-0002yb-Ht for guile-user@gnu.org; Sun, 31 Jul 2005 17:38:06 -0400 Original-Received: from zagadka.ping.de (cs181072157.pp.htv.fi [82.181.72.157]) by smtp1.pp.htv.fi (Postfix) with SMTP id 9249C7FC25 for ; Mon, 1 Aug 2005 00:25:42 +0300 (EEST) Original-Received: (qmail 4550 invoked by uid 1000); 31 Jul 2005 21:25:43 -0000 Original-To: Neil Jerram In-Reply-To: <87oe8iai2h.fsf@zagadka.de> (Marius Vollmer's message of "Sun, 31 Jul 2005 22:31:18 +0300") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:4667 gmane.lisp.guile.devel:5178 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.devel:5178 Marius Vollmer writes: > (I am a bit worried right now that the 'obvious' approach of putting > FOO and BAR into a weak key hashtable with FOO as the key and BAR as > the value does conflict a bit with my original goal of breaking up > cycles from strong values to weak keys. With the code that I have > now, both FOO and BAR are not considered accessible just by virtue of > being in the hashtable. Thus, once FOO is considered inaccessible, > BAR might be inaccessible as well; both could be returned from > guardians in any order. Hmm.) I have now thought a bit more about this, and am no longer worried. This is now the reference documentation of make-guardian: -- Scheme Procedure: make-guardian -- C Function: scm_make_guardian () Create a new guardian. A guardian protects a set of objects from garbage collection, allowing a program to apply cleanup or other actions. `make-guardian' returns a procedure representing the guardian. Calling the guardian procedure with an argument adds the argument to the guardian's set of protected objects. Calling the guardian procedure without an argument returns one of the protected objects which are ready for garbage collection, or `#f' if no such object is available. Objects which are returned in this way are removed from the guardian. You can put a single object into a guardian more than once and you can put a single object into more than one guardian. The object will then be returned multiple times by the guardian procedures. A object is eligible to be returned from a guardian when it is no longer referenced from outside any guardian. There is no guarantee about the order in which objects are returned from a guardian. If you want to impose an order on finalization actions, for example, you can do that by keeping objects alive in some global data structure until they are no longer needed for finalizing other objects. Being an element in a weak vector, a key in a hash table with weak keys, or a value in a hash table with weak value does not prevent an object from being returned by a guardian. But as long as an object can be returned from a guardian will it not be removed from such a weak vector or hash table. In other words, a weak link does not prevent an object from being considered collectable, but being inside a guardian prevents a weak link from being broken. A key in a weak key hash table can be though of as having a strong reference to its associated value as long as the key is accessible. Consequently, when the key only accessible from within a guardian, the reference from the key to the value is also considered to be coming from within a guardian. Thus, if there is no other reference to the value, it is eligible to be returned from a guardian. -- GPG: D5D4E405 - 2F9B BCCC 8527 692A 04E3 331E FAF8 226A D5D4 E405 _______________________________________________ Guile-user mailing list Guile-user@gnu.org http://lists.gnu.org/mailman/listinfo/guile-user