Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,14 @@ private int getDelay(long millisSinceLastSecond) {
if (log.isDebugEnabled()) {
log.debug("Calculating {} {} {}", millisSinceLastSecond, cntSent * msecPerReq, cntSent);
}
if (millisSinceLastSecond < (cntSent * msecPerReq)) {
// TODO : Explain this for other maintainers


if (millisSinceLastSecond < (cntSent * msecPerReq) || msecPerReq > 1000) {
//this code allows for very big number of threads to be fired each second (at most 1 divided by how much time "delay" runs because it's synchronized)
//each second has number of requests to fire
//this condition evaluates to true if threads have been firing (executing "sample" and then executing "delay") quickly enough since the second started
//otherwise next thread should be fired instantly

// cntDelayed + 1 : Current threads waiting + this thread
return (int) (1 + 1000.0 * (cntDelayed + 1) / rps);
}
Expand Down