351 |
|
public void realRun() throws InterruptedException { |
352 |
|
for (int i = 0; i < SIZE; ++i) { |
353 |
|
long t0 = System.nanoTime(); |
354 |
< |
threadAssertEquals(i, (int) q.poll(LONG_DELAY_MS, |
355 |
< |
MILLISECONDS)); |
354 |
> |
assertEquals(i, (int) q.poll(LONG_DELAY_MS, MILLISECONDS)); |
355 |
|
long millisElapsed = (System.nanoTime() - t0)/(1024 * 1024); |
356 |
|
assertTrue(millisElapsed < SMALL_DELAY_MS); |
357 |
|
} |
461 |
|
assertTrue(q.remove(one)); |
462 |
|
assertTrue(q.remove(two)); |
463 |
|
assertTrue(q.add(three)); |
464 |
< |
assertTrue(q.take() == three); |
464 |
> |
assertSame(q.take(), three); |
465 |
|
} |
466 |
|
|
467 |
|
/** |
674 |
|
|
675 |
|
executor.execute(new CheckedRunnable() { |
676 |
|
public void realRun() { |
677 |
< |
threadAssertTrue(q.offer(three, MEDIUM_DELAY_MS, |
679 |
< |
MILLISECONDS)); |
677 |
> |
assertTrue(q.offer(three, MEDIUM_DELAY_MS, MILLISECONDS)); |
678 |
|
}}); |
679 |
|
|
680 |
|
executor.execute(new CheckedRunnable() { |
681 |
|
public void realRun() throws InterruptedException { |
682 |
|
Thread.sleep(SMALL_DELAY_MS); |
683 |
< |
threadAssertEquals(one, q.take()); |
683 |
> |
assertEquals(one, q.take()); |
684 |
|
}}); |
685 |
|
|
686 |
|
joinPool(executor); |
695 |
|
|
696 |
|
executor.execute(new CheckedRunnable() { |
697 |
|
public void realRun() throws InterruptedException { |
698 |
< |
threadAssertNull(q.poll()); |
699 |
< |
threadAssertTrue(null != q.poll(MEDIUM_DELAY_MS, |
700 |
< |
MILLISECONDS)); |
703 |
< |
threadAssertTrue(q.isEmpty()); |
698 |
> |
assertNull(q.poll()); |
699 |
> |
assertSame(one, q.poll(MEDIUM_DELAY_MS, MILLISECONDS)); |
700 |
> |
assertTrue(q.isEmpty()); |
701 |
|
}}); |
702 |
|
|
703 |
|
executor.execute(new CheckedRunnable() { |
856 |
|
Thread t = newStartedThread(new CheckedRunnable() { |
857 |
|
public void realRun() throws InterruptedException { |
858 |
|
Thread.sleep(SMALL_DELAY_MS); |
859 |
< |
threadAssertTrue(q.hasWaitingConsumer()); |
860 |
< |
threadAssertEquals(q.getWaitingConsumerCount(), 1); |
861 |
< |
threadAssertTrue(q.offer(new Object())); |
862 |
< |
threadAssertFalse(q.hasWaitingConsumer()); |
863 |
< |
threadAssertEquals(q.getWaitingConsumerCount(), 0); |
859 |
> |
assertTrue(q.hasWaitingConsumer()); |
860 |
> |
assertEquals(q.getWaitingConsumerCount(), 1); |
861 |
> |
assertTrue(q.offer(one)); |
862 |
> |
assertFalse(q.hasWaitingConsumer()); |
863 |
> |
assertEquals(q.getWaitingConsumerCount(), 0); |
864 |
|
}}); |
865 |
|
|
866 |
< |
assertTrue(q.poll(LONG_DELAY_MS, MILLISECONDS) != null); |
866 |
> |
assertSame(one, q.poll(LONG_DELAY_MS, MILLISECONDS)); |
867 |
|
assertEquals(q.getWaitingConsumerCount(), 0); |
868 |
|
assertFalse(q.hasWaitingConsumer()); |
869 |
|
t.join(); |
1016 |
|
threadAssertTrue(q.tryTransfer(hotPotato)); |
1017 |
|
}}); |
1018 |
|
|
1019 |
< |
assertTrue(q.poll(MEDIUM_DELAY_MS, MILLISECONDS) == hotPotato); |
1019 |
> |
assertSame(hotPotato, q.poll(MEDIUM_DELAY_MS, MILLISECONDS)); |
1020 |
|
checkEmpty(q); |
1021 |
|
t.join(); |
1022 |
|
} |
1039 |
|
threadAssertTrue(q.tryTransfer(hotPotato)); |
1040 |
|
}}); |
1041 |
|
|
1042 |
< |
assertTrue(q.take() == hotPotato); |
1042 |
> |
assertSame(q.take(), hotPotato); |
1043 |
|
checkEmpty(q); |
1044 |
|
t.join(); |
1045 |
|
} |
1069 |
|
|
1070 |
|
Thread t = newStartedThread(new CheckedRunnable() { |
1071 |
|
public void realRun() throws InterruptedException { |
1072 |
< |
threadAssertFalse |
1073 |
< |
(q.tryTransfer(new Object(), |
1077 |
< |
SHORT_DELAY_MS, MILLISECONDS)); |
1072 |
> |
assertFalse(q.tryTransfer(new Object(), |
1073 |
> |
SHORT_DELAY_MS, MILLISECONDS)); |
1074 |
|
}}); |
1075 |
|
|
1076 |
|
Thread.sleep(SMALL_DELAY_MS); |
1088 |
|
|
1089 |
|
Thread t = newStartedThread(new CheckedRunnable() { |
1090 |
|
public void realRun() throws InterruptedException { |
1091 |
< |
threadAssertTrue(q.tryTransfer(five, |
1092 |
< |
MEDIUM_DELAY_MS, MILLISECONDS)); |
1097 |
< |
threadAssertTrue(q.isEmpty()); |
1091 |
> |
assertTrue(q.tryTransfer(five, MEDIUM_DELAY_MS, MILLISECONDS)); |
1092 |
> |
assertTrue(q.isEmpty()); |
1093 |
|
}}); |
1094 |
|
|
1095 |
|
Thread.sleep(SHORT_DELAY_MS); |