This commit is contained in:
Clebert Suconic 2017-08-01 11:52:28 -04:00
commit 2b64ce4a3d
2 changed files with 3 additions and 3 deletions

View File

@ -395,7 +395,7 @@ public final class TimedBuffer {
} }
//it could wait until the timeout is expired //it could wait until the timeout is expired
final long timeFromTheLastFlush = System.nanoTime() - lastFlushTime; final long timeFromTheLastFlush = System.nanoTime() - lastFlushTime;
final long timeToSleep = timeFromTheLastFlush - timeout; final long timeToSleep = timeout - timeFromTheLastFlush;
if (timeToSleep > 0) { if (timeToSleep > 0) {
sleepIfPossible(timeToSleep); sleepIfPossible(timeToSleep);
} }

View File

@ -385,7 +385,7 @@ public class TimedBufferTest extends ActiveMQTestBase {
@Test @Test
public void timeoutShouldMatchFlushIOPSWithNotBlockingFlush() { public void timeoutShouldMatchFlushIOPSWithNotBlockingFlush() {
//use a large timeout in order to be reactive //use a large timeout in order to be reactive
final long timeout = TimeUnit.SECONDS.toNanos(2); final long timeout = TimeUnit.MILLISECONDS.toNanos(100);
assert ((int) timeout) > 0; assert ((int) timeout) > 0;
//it is optimistic: the timeout and the blockingDeviceFlushTime are a perfect match //it is optimistic: the timeout and the blockingDeviceFlushTime are a perfect match
final long deviceTime = timeout; final long deviceTime = timeout;
@ -426,7 +426,7 @@ public class TimedBufferTest extends ActiveMQTestBase {
@Test @Test
public void timeoutShouldMatchFlushIOPSWithBlockingFlush() { public void timeoutShouldMatchFlushIOPSWithBlockingFlush() {
//use a large timeout in order to be reactive //use a large timeout in order to be reactive
final long timeout = TimeUnit.SECONDS.toNanos(2); final long timeout = TimeUnit.MILLISECONDS.toNanos(100);
assert ((int) timeout) > 0; assert ((int) timeout) > 0;
//it is optimistic: the timeout and the blockingDeviceFlushTime are a perfect match //it is optimistic: the timeout and the blockingDeviceFlushTime are a perfect match
final long deviceTime = timeout; final long deviceTime = timeout;