[jboss-cvs] JBoss Messaging SVN: r5033 - in trunk: tests/src/org/jboss/messaging/tests/unit/util and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Sep 26 15:58:12 EDT 2008
Author: clebert.suconic at jboss.com
Date: 2008-09-26 15:58:12 -0400 (Fri, 26 Sep 2008)
New Revision: 5033
Modified:
trunk/src/main/org/jboss/messaging/util/TimeAndCounterIDGenerator.java
trunk/tests/src/org/jboss/messaging/tests/unit/util/TimeAndCounterIDGeneratorTest.java
Log:
Changing TimeAndCounterIDGenerator to not need a synchronized block
Modified: trunk/src/main/org/jboss/messaging/util/TimeAndCounterIDGenerator.java
===================================================================
--- trunk/src/main/org/jboss/messaging/util/TimeAndCounterIDGenerator.java 2008-09-26 19:41:39 UTC (rev 5032)
+++ trunk/src/main/org/jboss/messaging/util/TimeAndCounterIDGenerator.java 2008-09-26 19:58:12 UTC (rev 5033)
@@ -26,16 +26,18 @@
/**
* A TimeAndCounterIDGenerator
- *
+ * <p>
+ * Note: This sequence generator is valid as long as you generate less than 268435455 (fffffff) IDs per millisecond
+ * </p>
+ * <p>
+ * (what is impossible at this point, This class alone will probably take a few seconds to generate this many IDs)
+ * </p>
+ *
* @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- *
- * Created Sep 24, 2008 11:54:10 AM
- *
- *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a> Created Sep 24, 2008 11:54:10 AM
*/
public class TimeAndCounterIDGenerator implements IDGenerator
-{
+{
// Constants ----------------------------------------------------
/**
@@ -93,6 +95,7 @@
{
return counter.get();
}
+
// for use in testcases
public void setInternalID(final long id)
{
@@ -112,9 +115,9 @@
long newTm = newTM();
// To avoid quick restarts on testcases.
- // In a real scenario this will never happen, as refresh is called only on constructor or when the first bit on the counter explodes
- // And that would happen only at one specific millisecond every 368 days, and that would never hit a situation where
- // newTM == oldTM
+ // In a real scenario this will never happen, as refresh is called only on constructor or when the first bit on
+ // the counter explodes
+ // And that would happen only at one specific millisecond every 368 days, and that would never hit this case
while (newTm == oldTm)
{
try
Modified: trunk/tests/src/org/jboss/messaging/tests/unit/util/TimeAndCounterIDGeneratorTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/util/TimeAndCounterIDGeneratorTest.java 2008-09-26 19:41:39 UTC (rev 5032)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/util/TimeAndCounterIDGeneratorTest.java 2008-09-26 19:58:12 UTC (rev 5033)
@@ -30,12 +30,8 @@
/**
* A TimeAndCounterIDGeneratorTest
- *
- * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
*
- * Created 24-Sep-08 3:42:25 PM
- *
- *
+ * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a> Created 24-Sep-08 3:42:25 PM
*/
public class TimeAndCounterIDGeneratorTest extends UnitTestCase
{
@@ -155,7 +151,7 @@
hashSet.clear();
}
-
+
public void testEdgeCaseOnDate()
{
long date = 0x117FFFFFFFFl;
@@ -181,5 +177,4 @@
return String.format("%1$X", value);
}
-
}
More information about the jboss-cvs-commits
mailing list