[freenet-cvs] r13137 - trunk/freenet/src/freenet/support

toad at freenetproject.org toad at freenetproject.org
Thu May 3 22:02:36 UTC 2007


Author: toad
Date: 2007-05-03 22:02:35 +0000 (Thu, 03 May 2007)
New Revision: 13137

Modified:
   trunk/freenet/src/freenet/support/RandomGrabArray.java
Log:
Deal more efficiently with a bunch of items getting cancelled simultaneously.
(Looping in SectoredRGA locking Yarrow causing contention observed...)

Modified: trunk/freenet/src/freenet/support/RandomGrabArray.java
===================================================================
--- trunk/freenet/src/freenet/support/RandomGrabArray.java	2007-05-03 22:01:55 UTC (rev 13136)
+++ trunk/freenet/src/freenet/support/RandomGrabArray.java	2007-05-03 22:02:35 UTC (rev 13137)
@@ -69,10 +69,13 @@
 					ret.setParentGrabArray(null);
 					return ret;
 				}
-				reqs[i] = reqs[--index];
-				reqs[index] = null;
-				if(oret != null)
-					contents.remove(oret);
+				do {
+					reqs[i] = reqs[--index];
+					reqs[index] = null;
+					if(oret != null)
+						contents.remove(oret);
+					oret = reqs[i];
+				} while (index > i && (oret == null || oret.isCancelled()));
 				// Shrink array
 				if((index < reqs.length / 4) && (reqs.length > MIN_SIZE)) {
 					// Shrink array




More information about the cvs mailing list