r26765 - trunk/freenet/src/freenet/support

[email protected]
Newsgroups gmane.network.freenet.cvs
Message-ID <[email protected]>
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;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.