- Don't delay the refiller if we need more (don't limit max output)
   - Add FortunaRandomSource.main() to output to stdout for testing e.g. with dieharder
This commit is contained in:
zzz
2013-07-19 21:31:25 +00:00
parent 8505e8a1ca
commit 554a3a6b0e
3 changed files with 32 additions and 26 deletions

View File

@@ -139,13 +139,18 @@ public class AsyncFortunaStandalone extends FortunaStandalone implements Runnabl
long before = System.currentTimeMillis();
doFill(aBuff.buffer);
long after = System.currentTimeMillis();
boolean shouldWait = _fullBuffers.size() > 1;
_fullBuffers.offer(aBuff);
_context.statManager().addRateData("prng.bufferFillTime", after - before, 0);
Thread.yield();
long waitTime = (after-before)*5;
if (waitTime <= 0) // somehow postman saw waitTime show up as negative
waitTime = 50;
try { Thread.sleep(waitTime); } catch (InterruptedException ie) {}
if (shouldWait) {
Thread.yield();
long waitTime = (after-before)*5;
if (waitTime <= 0) // somehow postman saw waitTime show up as negative
waitTime = 50;
else if (waitTime > 5000)
waitTime = 5000;
try { Thread.sleep(waitTime); } catch (InterruptedException ie) {}
}
}
}