Author: nextgens
Date: 2009-02-02 18:54:00 +0000 (Mon, 02 Feb 2009)
New Revision: 25471

Modified:
   trunk/freenet/src/freenet/support/WouldBlockException.java
Log:
Major optimization when we create an often thrown exception...
See 
http://blogs.sun.com/jrose/entry/longjumps_considered_inexpensive?resubmit=damnit

Modified: trunk/freenet/src/freenet/support/WouldBlockException.java
===================================================================
--- trunk/freenet/src/freenet/support/WouldBlockException.java  2009-02-02 
07:54:36 UTC (rev 25470)
+++ trunk/freenet/src/freenet/support/WouldBlockException.java  2009-02-02 
18:54:00 UTC (rev 25471)
@@ -6,14 +6,33 @@
  * Thrown when we would have to block but have been told not to.
  */
 public class WouldBlockException extends IncomingPacketFilterException {
-       private static final long serialVersionUID = -1;
 
-       public WouldBlockException(String string) {
-               super(string);
-       }
+    private static final long serialVersionUID = -1;
+    private static volatile boolean logDEBUG;
 
-       public WouldBlockException() {
-               super();
-       }
+    static {
+        Logger.registerLogThresholdCallback(new LogThresholdCallback() {
 
+            @Override
+            public void shouldUpdate() {
+                logDEBUG = Logger.shouldLog(Logger.DEBUG, this);
+            }
+        });
+    }
+
+    public WouldBlockException(String string) {
+        super(string);
+    }
+
+    public WouldBlockException() {
+        super();
+    }
+
+    // Optimization :
+    // 
http://blogs.sun.com/jrose/entry/longjumps_considered_inexpensive?resubmit=damnit
+    public final synchronized Throwable fillInStackTrace() {
+        if(logDEBUG)
+            return super.fillInStackTrace();
+        return null;
+    }
 }

_______________________________________________
cvs mailing list
[email protected]
http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs

Reply via email to