incubator-droids-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thors...@apache.org
Subject svn commit: r939624 - /incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/delay/GaussianRandomDelayTimer.java
Date Fri, 30 Apr 2010 10:33:41 GMT
Author: thorsten
Date: Fri Apr 30 10:33:40 2010
New Revision: 939624

URL: http://svn.apache.org/viewvc?rev=939624&view=rev
Log:
droids-86
Reporter:   Bertil Chapuis
Patch:   Bertil Chapuis
Review: Thorsten Scherler

Modified:
    incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/delay/GaussianRandomDelayTimer.java

Modified: incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/delay/GaussianRandomDelayTimer.java
URL: http://svn.apache.org/viewvc/incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/delay/GaussianRandomDelayTimer.java?rev=939624&r1=939623&r2=939624&view=diff
==============================================================================
--- incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/delay/GaussianRandomDelayTimer.java
(original)
+++ incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/delay/GaussianRandomDelayTimer.java
Fri Apr 30 10:33:40 2010
@@ -30,7 +30,12 @@ public class GaussianRandomDelayTimer ex
     super( min, range );
   }
 
-  public long getDelayMillis() {
-    return (Math.abs((long)(random.nextGaussian() * delaySpread))) + minimumDelay;
+  public long getDelayMillis() 
+  {
+    double delay;
+    do {
+      delay = ( random.nextGaussian() + 1 ) / 2;
+    } while (delay < 0 || delay > 1);
+    return (long) delay * delaySpread + minimumDelay;
   }
 }



Mime
View raw message