Author: j16sdiz
Date: 2009-04-14 04:42:10 +0000 (Tue, 14 Apr 2009)
New Revision: 26766
Modified:
trunk/freenet/src/freenet/support/RandomGrabArray.java
Log:
Logging (RandomGrabArray.java)
Profiling show this contribute to 10% of all shouldLog calls
Modified: trunk/freenet/src/freenet/support/RandomGrabArray.java
===================================================================
--- trunk/freenet/src/freenet/support/RandomGrabArray.java 2009-04-14 04:41:50 UTC (rev 26765)
+++ trunk/freenet/src/freenet/support/RandomGrabArray.java 2009-04-14 04:42:10 UTC (rev 26766)
@@ -8,7 +8,17 @@
* An array which supports very fast remove-and-return-a-random-element.
*/
public class RandomGrabArray implements RemoveRandom {
-
+ private static volatile boolean logMINOR;
+
+ static {
+ Logger.registerLogThresholdCallback(new LogThresholdCallback() {
+ @Override
+ public void shouldUpdate() {
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
+ }
+ });
+ }
+
private class Block {
RandomGrabArrayItem[] reqs;
}
@@ -41,7 +51,6 @@
public void add(RandomGrabArrayItem req, ObjectContainer container) {
if(req.persistent() != persistent) throw new IllegalArgumentException("req.persistent()="+req.persistent()+" but array.persistent="+persistent+" item="+req+" array="+this);
- boolean logMINOR = Logger.shouldLog(Logger.MINOR, this);
if(req.isEmpty(container)) {
if(logMINOR) Logger.minor(this, "Is finished already: "+req);
return;
@@ -124,7 +133,6 @@
public RandomGrabArrayItem removeRandom(RandomGrabArrayItemExclusionList excluding, ObjectContainer container, ClientContext context) {
RandomGrabArrayItem ret, oret;
- boolean logMINOR = Logger.shouldLog(Logger.MINOR, this);
if(logMINOR) Logger.minor(this, "removeRandom() on "+this+" index="+index);
synchronized(this) {
int lastActiveBlock = -1;
@@ -359,7 +367,7 @@
}
public void remove(RandomGrabArrayItem it, ObjectContainer container) {
- if(Logger.shouldLog(Logger.MINOR, this))
+ if(logMINOR)
Logger.minor(this, "Removing "+it+" from "+this);
boolean matched = false;
boolean empty = false;
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.