fenfire-commits
[Top][All Lists]
Advanced

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

[ff-cvs] fenfire/org/fenfire/swamp CachedNodeFunction.ja...


From: Tuomas J. Lukka
Subject: [ff-cvs] fenfire/org/fenfire/swamp CachedNodeFunction.ja...
Date: Sun, 31 Aug 2003 08:36:16 -0400

CVSROOT:        /cvsroot/fenfire
Module name:    fenfire
Branch:         
Changes by:     Tuomas J. Lukka <address@hidden>        03/08/31 08:36:16

Modified files:
        org/fenfire/swamp: CachedNodeFunction.java 
                           CachedPureNodeFunction.java makeswamp.py 

Log message:
        Trying to fix cvs screwup

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/swamp/CachedNodeFunction.java.diff?tr1=1.9&tr2=1.10&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/swamp/CachedPureNodeFunction.java.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/swamp/makeswamp.py.diff?tr1=1.10&tr2=1.11&r1=text&r2=text

Patches:
Index: fenfire/org/fenfire/swamp/CachedNodeFunction.java
diff -u fenfire/org/fenfire/swamp/CachedNodeFunction.java:1.9 
fenfire/org/fenfire/swamp/CachedNodeFunction.java:1.10
--- fenfire/org/fenfire/swamp/CachedNodeFunction.java:1.9       Sun Aug 17 
10:34:20 2003
+++ fenfire/org/fenfire/swamp/CachedNodeFunction.java   Sun Aug 31 08:36:15 2003
@@ -41,33 +41,12 @@
  */
 public class CachedNodeFunction implements NodeFunction {
 
-    static final private Object DIRTY = new Object();
-
     NodeFunction f;
 
     ConstGraph ourGraph;
 
     CachingMap cache;
 
-    private class CacheEntry implements Obs {
-       Object node;
-       Object value = DIRTY;
-       Set obses;
-       public void addObs(Obs o) {
-           if(obses == null) obses = new HashSet();
-           obses.add(o);
-       }
-       public void chg() {
-           if(obses != null) {
-               for(Iterator i = obses.iterator(); i.hasNext();) {
-                   ((Obs)i.next()).chg();
-               }
-           }
-           value = DIRTY;
-       }
-    }
-
-
     /** Constructor for default set.
      */
     public CachedNodeFunction(int n, ConstGraph graph, NodeFunction f) {
@@ -95,13 +74,12 @@
                throw new IllegalArgumentException("Called with wrong graph");
        }
 
-       CacheEntry cac = (CacheEntry)cache.get(node);
+       NodeFunctionCacheEntry cac = (NodeFunctionCacheEntry)cache.get(node);
        if(cac == null) {
-           cac = new CacheEntry();
-           cac.node = node;
+           cac = new NodeFunctionCacheEntry(node);
            cache.put(node, cac);
        }
-       if(cac.value == DIRTY) {
+       if(cac.value == cac.DIRTY) {
            ConstGraph og = (ourGraph == null ? 
                    null : ourGraph.getObservedConstGraph(cac));
            cac.value = f.f(og, node);
Index: fenfire/org/fenfire/swamp/CachedPureNodeFunction.java
diff -u fenfire/org/fenfire/swamp/CachedPureNodeFunction.java:1.1 
fenfire/org/fenfire/swamp/CachedPureNodeFunction.java:1.2
--- fenfire/org/fenfire/swamp/CachedPureNodeFunction.java:1.1   Sun Aug 17 
10:34:20 2003
+++ fenfire/org/fenfire/swamp/CachedPureNodeFunction.java       Sun Aug 31 
08:36:16 2003
@@ -44,32 +44,12 @@
  */
 public class CachedPureNodeFunction implements PureNodeFunction {
 
-    static final private Object DIRTY = new Object();
-
     PureNodeFunction f;
 
     ConstGraph ourGraph;
 
     CachingMap cache;
 
-    private class CacheEntry implements Obs {
-       Object node;
-       Object value = DIRTY;
-       Set obses;
-       public void addObs(Obs o) {
-           if(obses == null) obses = new HashSet();
-           obses.add(o);
-       }
-       public void chg() {
-           if(obses != null) {
-               for(Iterator i = obses.iterator(); i.hasNext();) {
-                   ((Obs)i.next()).chg();
-               }
-           }
-           value = DIRTY;
-       }
-    }
-
     public CachedPureNodeFunction(int n, ConstGraph g, PureNodeFunction f) {
        cache = new CachingMap(n);
        this.ourGraph = g;
@@ -85,13 +65,12 @@
                throw new IllegalArgumentException("Called with wrong graph");
        }
 
-       CacheEntry cac = (CacheEntry)cache.get(node);
+       NodeFunctionCacheEntry cac = (NodeFunctionCacheEntry)cache.get(node);
        if(cac == null) {
-           cac = new CacheEntry();
-           cac.node = node;
+           cac = new NodeFunctionCacheEntry(node);
            cache.put(node, cac);
        }
-       if(cac.value == DIRTY) {
+       if(cac.value == cac.DIRTY) {
            ConstGraph og = (ourGraph == null ? 
                    null : ourGraph.getObservedConstGraph(cac));
            cac.value = f.f(og, node);
Index: fenfire/org/fenfire/swamp/makeswamp.py
diff -u fenfire/org/fenfire/swamp/makeswamp.py:1.10 
fenfire/org/fenfire/swamp/makeswamp.py:1.11
--- fenfire/org/fenfire/swamp/makeswamp.py:1.10 Sun Aug 17 08:53:18 2003
+++ fenfire/org/fenfire/swamp/makeswamp.py      Sun Aug 31 08:36:16 2003
@@ -148,7 +148,21 @@
  *  remove, but it should not be used, as it may cause unspecified behavior.
  */
 public interface ConstGraph {
+    /** Get a ConstGraph whose queries will return the same
+     * value as the queries for this graph, but will 
+     * set up the Obs for those queries.
+     * When the result of any of those queries changes,
+     * Obs is called immediately.
+     */
     ConstGraph getObservedConstGraph(org.fenfire.Obs o);
+
+    /** This observed graph will not be used any more, and
+     * if desired, may be recycled.
+     * This operation is allowed to be a no-op, and
+     * if the graph this method is called on is not one that
+     * has been returned by getObservedConstGraph, is
+     * defined to be so..
+     */
     void close();
 
     /** If this graph is observed (returned from getObservedConstGraph),




reply via email to

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