gzz-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gzz-commits] libvob org/nongnu/libvob/util/RefValueMap.java ...


From: Tuomas J. Lukka
Subject: [Gzz-commits] libvob org/nongnu/libvob/util/RefValueMap.java ...
Date: Sun, 22 Jun 2003 08:08:39 -0400

CVSROOT:        /cvsroot/libvob
Module name:    libvob
Branch:         
Changes by:     Tuomas J. Lukka <address@hidden>        03/06/22 08:08:39

Modified files:
        org/nongnu/libvob/util: RefValueMap.java 
        test/vob/util  : maps.test 

Log message:
        Purge queued references from the map - now it works.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/org/nongnu/libvob/util/RefValueMap.java.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/test/vob/util/maps.test.diff?tr1=1.2&tr2=1.3&r1=text&r2=text

Patches:
Index: libvob/org/nongnu/libvob/util/RefValueMap.java
diff -u libvob/org/nongnu/libvob/util/RefValueMap.java:1.1 
libvob/org/nongnu/libvob/util/RefValueMap.java:1.2
--- libvob/org/nongnu/libvob/util/RefValueMap.java:1.1  Sun Jun 22 07:55:11 2003
+++ libvob/org/nongnu/libvob/util/RefValueMap.java      Sun Jun 22 08:08:39 2003
@@ -72,7 +72,15 @@
 
     protected abstract Object makeValue(Object key, Object value, 
ReferenceQueue queue);
 
+
+    protected void clean() {
+       Map.Entry o;
+       while((o = (Map.Entry)queue.poll()) != null)
+           map.remove(o.getKey());
+    }
+
     public Object put(Object key, Object value) {
+       clean();
        Map.Entry ret = (Map.Entry)map.put(key, makeValue(key, value, queue));
        if(ret == null) return null;
        return ret.getValue();
@@ -104,6 +112,7 @@
     };
 
     public Set entrySet() {
+       clean();
        return entrySet;
     }
 
Index: libvob/test/vob/util/maps.test
diff -u libvob/test/vob/util/maps.test:1.2 libvob/test/vob/util/maps.test:1.3
--- libvob/test/vob/util/maps.test:1.2  Sun Jun 22 08:04:38 2003
+++ libvob/test/vob/util/maps.test      Sun Jun 22 08:08:39 2003
@@ -20,13 +20,18 @@
 # 
 # 
 
+from __future__ import nested_scopes
+
 import java, vob
 
+dbg = 0
+
 class C:
     def __init__(self, n):
        self.n = n
     def __del__(self):
-       print "FINALIZING: ",self.n
+       if dbg:
+           print "FINALIZING: ",self.n
 
 def createCS(start):
     return [ C(i) for i in range(start, start + 1000) ]




reply via email to

[Prev in Thread] Current Thread [Next in Thread]