Update of /cvsroot/freenet/freenet/src/freenet/node/rt
In directory sc8-pr-cvs1:/tmp/cvs-serv12670/src/freenet/node/rt

Modified Files:
        ResponseTimeEstimator.java 
Log Message:
Modify synchronization. Add some, remove some other.

Index: ResponseTimeEstimator.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/node/rt/ResponseTimeEstimator.java,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -w -r1.26 -r1.27
--- ResponseTimeEstimator.java  1 Nov 2003 21:15:27 -0000       1.26
+++ ResponseTimeEstimator.java  1 Nov 2003 22:49:23 -0000       1.27
@@ -467,7 +467,7 @@
        return guess(convert(k));
     }
    
-    public synchronized int guess(BigInteger n) {
+    public int guess(BigInteger n) {
                RoutingPointStore.NeighbourRoutingPointPair b = 
store.findKeyBeforeAndAfter(n);
 
        if(b.includesKeyspaceWrap)
@@ -480,38 +480,9 @@
             .divide(b.right.key.subtract(b.left.key))
             .add(BigInteger.valueOf(b.left.time));
        
-       //System.out.println("\n"+key[pos]+"="+time[pos]);
-       //System.out.println(n+"="+i.intValue());
-       //System.out.println(key[pos+1]+"="+time[pos+1]);
-       
         // 2^31 microseconds is 36 minutes.
         return i.intValue();
     }
-/*
-    public byte[] serialize() {
-        byte[] b = new byte[key.length * BYTES];
-
-        for (int n = 0, i = 0; n < key.length; n++, i += BYTES) {
-            byte[] tmp = key[n].toByteArray();
-            int len = tmp.length;
-            int off = 0;
-
-            // There may be a bogus first word for the sign bit.
-            if (tmp.length > KEYBYTES) {
-                len--;
-                off++;
-            }
-
-            System.arraycopy(tmp, off, b, i + BYTES - len, len);
-            b[i] = (byte) (time[n] >> 24);
-            b[i+1] = (byte) (time[n] >> 16);
-            b[i+2] = (byte) (time[n] >> 8);
-            b[i+3] = (byte) time[n];
-        }
-
-        return b;
-    }
-    */
     
     public static TimeEstimatorFactory factory() {
        return factory(DEFAULT_ACCURACY);
@@ -626,7 +597,7 @@
                                throw ioe;
                        }
                }
-               void report(BigInteger n, int usec) {
+               synchronized void report(BigInteger n, int usec) {
                        recentKeys[recentPtr] = n;
                        recentTimes[recentPtr] = usec;
                        recentCount++;
@@ -634,7 +605,7 @@
                        if (recentPtr >= RECENT_LENGTH)
                                recentPtr = 0;
                }
-               LowestHighestPair getLowestAndHighest(boolean dontClipPoints) {
+               synchronized LowestHighestPair getLowestAndHighest(boolean 
dontClipPoints) {
                        LowestHighestPair l = new LowestHighestPair();
                        int x = recentPtr;
                        if (recentCount > RECENT_LENGTH)
@@ -650,7 +621,7 @@
                        return l;
                }
 
-               public void writeTo(DataOutputStream o) throws IOException {
+               public synchronized void writeTo(DataOutputStream o) throws 
IOException {
                        o.writeInt(recentPtr);
                        o.writeInt(recentCount);
                        for (int i = 0; i < recentTimes.length; i++) {
@@ -731,17 +702,6 @@
                                   "</td></tr>");
                        // I hope there is an optimized toString(16) ...
                        pw.println("</table>");
-               //      if(recentCount > 0) {
-               //          pw.println("<p>Recent points</p>");
-               //          pw.println("<table border=\"0\">");
-               //          int l = recentPtr;
-               //          if(recentCount > RECENT_LENGTH) l = RECENT_LENGTH;
-               //          for(int i=0;i<l;i++) {
-               //              
pw.println("<tr><td>"+i+"</td><td>"+recentKeys[i].toString(16)+
-               //                         "</td><td>"+recentTimes[i]+"</td></tr>");
-               //          }
-               //          pw.println("</table>");
-               //      }
                    }
 
                public String formatFromRaw(long x, int type) {
@@ -793,6 +753,8 @@
 
                        // Now plot the recent points
                        if (crossCol != null) {
+                               synchronized(recent)
+                               {
                                bmp.setPenColor(crossCol);
                                Enumeration e = recent.enumeration();
                                while (e.hasMoreElements()) {
@@ -806,6 +768,7 @@
                                }
                        }
                }
+               }
 
                public void drawGraphBMP(int width, int height, boolean 
dontClipPoints, OutputStream os) throws IOException {
                        Bitmap bmp = new Bitmap(width, height);
@@ -832,9 +795,6 @@
           }
        
        protected class RoutingPointStore {
-               //BigInteger key[];
-               //double sensitivity[];
-               //int time[];
                RoutingPoint points[];
                final RoutingPointStore.RoutingPointKeySorter ms = new 
RoutingPointKeySorter();
                

_______________________________________________
cvs mailing list
[EMAIL PROTECTED]
http://dodo.freenetproject.org/cgi-bin/mailman/listinfo/cvs

Reply via email to