Author: toad
Date: 2007-03-16 22:08:53 +0000 (Fri, 16 Mar 2007)
New Revision: 12159

Modified:
   trunk/freenet/src/freenet/client/async/BackgroundBlockEncoder.java
   trunk/freenet/src/freenet/client/async/SingleBlockInserter.java
Log:
Weak -> Soft - try to keep the encoded blocks if possible

Modified: trunk/freenet/src/freenet/client/async/BackgroundBlockEncoder.java
===================================================================
--- trunk/freenet/src/freenet/client/async/BackgroundBlockEncoder.java  
2007-03-16 21:47:28 UTC (rev 12158)
+++ trunk/freenet/src/freenet/client/async/BackgroundBlockEncoder.java  
2007-03-16 22:08:53 UTC (rev 12159)
@@ -1,6 +1,6 @@
 package freenet.client.async;

-import java.lang.ref.WeakReference;
+import java.lang.ref.SoftReference;
 import java.util.ArrayList;

 import freenet.support.Logger;
@@ -21,7 +21,7 @@
        public void queue(SingleBlockInserter sbi) {
                if(sbi.isCancelled()) return;
                if(sbi.resultingURI != null) return;
-               WeakReference ref = new WeakReference(sbi);
+               SoftReference ref = new SoftReference(sbi);
                synchronized(this) {
                        queue.add(ref);
                        Logger.minor(this, "Queueing encode of "+sbi);
@@ -36,7 +36,7 @@
                                if(sbis[i].isCancelled()) continue;
                                if(sbis[i].resultingURI != null) continue;
                                Logger.minor(this, "Queueing encode of 
"+sbis[i]);
-                               WeakReference ref = new WeakReference(sbis[i]);
+                               SoftReference ref = new SoftReference(sbis[i]);
                                queue.add(ref);
                        }
                        notifyAll();
@@ -55,7 +55,7 @@
                                        }
                                }
                                while(!queue.isEmpty()) {
-                                       WeakReference ref = (WeakReference) 
queue.remove(queue.size()-1);
+                                       SoftReference ref = (SoftReference) 
queue.remove(queue.size()-1);
                                        sbi = (SingleBlockInserter) ref.get();
                                        if(sbi != null) break;
                                }

Modified: trunk/freenet/src/freenet/client/async/SingleBlockInserter.java
===================================================================
--- trunk/freenet/src/freenet/client/async/SingleBlockInserter.java     
2007-03-16 21:47:28 UTC (rev 12158)
+++ trunk/freenet/src/freenet/client/async/SingleBlockInserter.java     
2007-03-16 22:08:53 UTC (rev 12159)
@@ -4,7 +4,7 @@
 package freenet.client.async;

 import java.io.IOException;
-import java.lang.ref.WeakReference;
+import java.lang.ref.SoftReference;
 import java.net.MalformedURLException;

 import freenet.client.FailureCodeTracker;
@@ -40,7 +40,7 @@
        private final FailureCodeTracker errors;
        private boolean finished;
        private final boolean dontSendEncoded;
-       private WeakReference refToClientKeyBlock;
+       private SoftReference refToClientKeyBlock;
        final int token; // for e.g. splitfiles
        private final Object tokenObject;
        final boolean isMetadata;
@@ -113,7 +113,7 @@
                        }
                        block = innerEncode();
                        refToClientKeyBlock = 
-                               new WeakReference(block);
+                               new SoftReference(block);
                        shouldSend = (resultingURI == null);
                        resultingURI = block.getClientKey().getURI();
                }


Reply via email to