Author: j16sdiz
Date: 2009-04-14 04:41:50 +0000 (Tue, 14 Apr 2009)
New Revision: 26765

Modified:
   trunk/freenet/src/freenet/support/SectoredRandomGrabArray.java
Log:
Logging (SectoredRandomGrabArray.java)

Profiling show this contribute to 10% of all shouldLog() calls

Modified: trunk/freenet/src/freenet/support/SectoredRandomGrabArray.java
===================================================================
--- trunk/freenet/src/freenet/support/SectoredRandomGrabArray.java      
2009-04-14 04:41:29 UTC (rev 26764)
+++ trunk/freenet/src/freenet/support/SectoredRandomGrabArray.java      
2009-04-14 04:41:50 UTC (rev 26765)
@@ -9,6 +9,17 @@
  * returned.
  */
 public class SectoredRandomGrabArray implements RemoveRandom, 
RemoveRandomParent {
+       private static volatile boolean logMINOR;
+       
+       static {
+               Logger.registerLogThresholdCallback(new LogThresholdCallback() {
+                       @Override
+                       public void shouldUpdate() {
+                               logMINOR = Logger.shouldLog(Logger.MINOR, this);
+                       }
+               });
+       }
+       
 
        /*
         * Yes, this is O(n). No, I don't care.
@@ -45,7 +56,6 @@
         * Add directly to a RandomGrabArrayWithClient under us. */
        public synchronized void add(Object client, RandomGrabArrayItem item, 
ObjectContainer container) {
                if(item.persistent() != persistent) throw new 
IllegalArgumentException("item.persistent()="+item.persistent()+" but 
array.persistent="+persistent+" item="+item+" array="+this);
-               boolean logMINOR = Logger.shouldLog(Logger.MINOR, this);
                RandomGrabArrayWithClient rga;
                int clientIndex = haveClient(client);
                if(clientIndex == -1) {
@@ -119,7 +129,6 @@
        }
 
        public synchronized RandomGrabArrayItem 
removeRandom(RandomGrabArrayItemExclusionList excluding, ObjectContainer 
container, ClientContext context) {
-               boolean logMINOR = Logger.shouldLog(Logger.MINOR, this);
                /** Count of arrays that have items but didn't return anything 
because of exclusions */
                int excluded = 0;
                final int MAX_EXCLUDED = 10;

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

Reply via email to