[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ff-cvs] fenfire/org/fenfire swamp/SuperLazyPureNodeFunc...
From: |
Tuomas J. Lukka |
Subject: |
[ff-cvs] fenfire/org/fenfire swamp/SuperLazyPureNodeFunc... |
Date: |
Sun, 07 Sep 2003 08:55:46 -0400 |
CVSROOT: /cvsroot/fenfire
Module name: fenfire
Branch:
Changes by: Tuomas J. Lukka <address@hidden> 03/09/07 08:55:46
Modified files:
org/fenfire/swamp: SuperLazyPureNodeFunction.java
org/fenfire/util: FunctionCacheEntry.java
SuperLazyPureFunction.java
Added files:
org/fenfire/util: SuperLazyBase.java
Log message:
Arch: abstracting superlazy + twids
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/swamp/SuperLazyPureNodeFunction.java.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/util/SuperLazyBase.java?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/util/FunctionCacheEntry.java.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/util/SuperLazyPureFunction.java.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
Patches:
Index: fenfire/org/fenfire/swamp/SuperLazyPureNodeFunction.java
diff -u fenfire/org/fenfire/swamp/SuperLazyPureNodeFunction.java:1.2
fenfire/org/fenfire/swamp/SuperLazyPureNodeFunction.java:1.3
--- fenfire/org/fenfire/swamp/SuperLazyPureNodeFunction.java:1.2 Mon Sep
1 06:20:58 2003
+++ fenfire/org/fenfire/swamp/SuperLazyPureNodeFunction.java Sun Sep 7
08:55:46 2003
@@ -14,14 +14,10 @@
* This function only caches pure node functions but is not a pure
* node function itself as it returns the placeholder value.
*/
-public class SuperLazyPureNodeFunction implements NodeFunction {
+public class SuperLazyPureNodeFunction extends SuperLazyBase implements
NodeFunction {
- CachingMap cache;
ConstGraph ourGraph;
PureNodeFunction f;
- Object placeHolder;
- Background background;
- ObjObs recalcObs;
/** Create a new SuperLazyPureNodeFunction.
* @param n The number of cache entries to use
@@ -39,26 +35,19 @@
Background background,
ObjObs recalcObs
) {
- cache = new CachingMap(n);
+ super(n, placeHolder, background, recalcObs);
this.ourGraph = g;
this.f = f;
- this.placeHolder = placeHolder;
- this.background = background;
- this.recalcObs = recalcObs;
}
private class SuperLazyNodeFunctionCacheEntry
- extends FunctionCacheEntry
- implements Runnable {
+ extends CacheEntry {
public SuperLazyNodeFunctionCacheEntry(Object input) {
super(input);
}
-
- public void schedule() {
- background.addTask(this, 0);
- }
public void run() {
+ if(this.value != DIRTY) return;
synchronized(this) {
ConstGraph og = (ourGraph == null ?
null : ourGraph.getObservedConstGraph(this));
@@ -88,11 +77,7 @@
synchronized(cac) {
if(o != null)
cac.addObs(o);
- if(cac.value == cac.DIRTY) {
- cac.schedule();
- return placeHolder;
- }
- return cac.value;
+ return cac.getValueAndSchedule();
}
}
}
Index: fenfire/org/fenfire/util/FunctionCacheEntry.java
diff -u fenfire/org/fenfire/util/FunctionCacheEntry.java:1.1
fenfire/org/fenfire/util/FunctionCacheEntry.java:1.2
--- fenfire/org/fenfire/util/FunctionCacheEntry.java:1.1 Mon Sep 1
06:20:58 2003
+++ fenfire/org/fenfire/util/FunctionCacheEntry.java Sun Sep 7 08:55:46 2003
@@ -29,7 +29,7 @@
/** The set of Obs object that observe this cache entry.
*/
- private Set obses;
+ protected Set obses;
public FunctionCacheEntry(Object input) {
this.input = input;
Index: fenfire/org/fenfire/util/SuperLazyPureFunction.java
diff -u fenfire/org/fenfire/util/SuperLazyPureFunction.java:1.1
fenfire/org/fenfire/util/SuperLazyPureFunction.java:1.2
--- fenfire/org/fenfire/util/SuperLazyPureFunction.java:1.1 Mon Sep 1
06:20:58 2003
+++ fenfire/org/fenfire/util/SuperLazyPureFunction.java Sun Sep 7 08:55:46 2003
@@ -14,13 +14,9 @@
* This function only caches pure functions but is not a pure
* node function itself as it returns the placeholder value.
*/
-public class SuperLazyPureFunction implements Function {
+public class SuperLazyPureFunction extends SuperLazyBase implements Function {
- CachingMap cache;
PureFunction f;
- Object placeHolder;
- Background background;
- ObjObs recalcObs;
/** Create a new SuperLazyPureNodeFunction.
* @param n The number of cache entries to use
@@ -38,25 +34,18 @@
Background background,
ObjObs recalcObs
) {
- cache = new CachingMap(n);
+ super(n, placeHolder, background, recalcObs);
this.f = f;
- this.placeHolder = placeHolder;
- this.background = background;
- this.recalcObs = recalcObs;
}
private class SuperLazyFunctionCacheEntry
- extends FunctionCacheEntry
- implements Runnable {
+ extends CacheEntry {
public SuperLazyFunctionCacheEntry(Object input) {
super(input);
}
-
- public void schedule() {
- background.addTask(this, 0);
- }
public void run() {
+ if(this.value != DIRTY) return;
synchronized(this) {
this.value = f.f(this.input);
}
@@ -74,11 +63,7 @@
cache.put(node, cac);
}
synchronized(cac) {
- if(cac.value == cac.DIRTY) {
- cac.schedule();
- return placeHolder;
- }
- return cac.value;
+ return cac.getValueAndSchedule();
}
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [ff-cvs] fenfire/org/fenfire swamp/SuperLazyPureNodeFunc...,
Tuomas J. Lukka <=