[jboss-cvs] JBossCache/src/org/jboss/cache/eviction ...
Manik Surtani
msurtani at jboss.com
Mon Jan 29 07:41:08 EST 2007
User: msurtani
Date: 07/01/29 07:41:08
Modified: src/org/jboss/cache/eviction EvictionTimerTask.java
Log:
Fixed TimerTask creation/reuse bug
Revision Changes Path
1.12 +41 -41 JBossCache/src/org/jboss/cache/eviction/EvictionTimerTask.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: EvictionTimerTask.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/eviction/EvictionTimerTask.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- EvictionTimerTask.java 27 Nov 2006 04:49:46 -0000 1.11
+++ EvictionTimerTask.java 29 Jan 2007 12:41:08 -0000 1.12
@@ -27,9 +27,9 @@
*
* @author Ben Wang 2-2004
* @author Daniel Huang (dhuang at jboss.org)
- * @version $Revision: 1.11 $
+ * @version $Revision: 1.12 $
*/
-public class EvictionTimerTask extends TimerTask
+public class EvictionTimerTask
{
private Log log = LogFactory.getLog(EvictionTimerTask.class);
@@ -73,6 +73,21 @@
processedRegions.remove(region);
}
+ public boolean isRegionRegisteredForProcessing(Region region)
+ {
+ return processedRegions.contains(region);
+ }
+
+ class EvictionListener extends AbstractCacheListener
+ {
+ private Log log = LogFactory.getLog(EvictionListener.class);
+ private Timer evictionThread;
+
+ public void cacheStarted(CacheSPI cache)
+ {
+ evictionThread = new Timer("EvictionTimer-" + tcount.getAndIncrement());
+ TimerTask tt = new TimerTask()
+ {
/**
* Run the eviction thread.
* <p/>
@@ -83,10 +98,8 @@
{
synchronized (processedRegions)
{
- Iterator it = processedRegions.iterator();
- while (it.hasNext())
+ for (Region region : processedRegions)
{
- final Region region = (Region) it.next();
final EvictionPolicy policy = region.getEvictionPolicy();
synchronized (region)
@@ -109,21 +122,8 @@
}
}
}
-
- public boolean isRegionRegisteredForProcessing(Region region)
- {
- return processedRegions.contains(region);
- }
-
- class EvictionListener extends AbstractCacheListener
- {
- private Log log = LogFactory.getLog(EvictionListener.class);
- private Timer evictionThread;
-
- public void cacheStarted(CacheSPI cache)
- {
- evictionThread = new Timer("EvictionTimer-" + tcount.getAndIncrement());
- evictionThread.schedule(EvictionTimerTask.this, wakeupIntervalSeconds * 1000, wakeupIntervalSeconds * 1000);
+ };
+ evictionThread.schedule(tt, wakeupIntervalSeconds * 1000, wakeupIntervalSeconds * 1000);
}
public void cacheStopped(CacheSPI cache)
More information about the jboss-cvs-commits
mailing list