722 |
|
* returning timeout status |
723 |
|
*/ |
724 |
|
public void testInterruptedTimedPoll() throws InterruptedException { |
725 |
< |
Thread t = new ThreadShouldThrow(InterruptedException.class) { |
725 |
> |
Thread t = new Thread(new CheckedRunnable() { |
726 |
|
public void realRun() throws InterruptedException { |
727 |
|
LinkedBlockingDeque q = populatedDeque(SIZE); |
728 |
|
for (int i = 0; i < SIZE; ++i) { |
729 |
< |
threadAssertEquals(i, ((Integer)q.poll(SHORT_DELAY_MS, MILLISECONDS)).intValue()); |
729 |
> |
assertEquals(i, ((Integer)q.poll(SHORT_DELAY_MS, MILLISECONDS)).intValue()); |
730 |
|
} |
731 |
< |
q.poll(SMALL_DELAY_MS, MILLISECONDS); |
732 |
< |
}}; |
731 |
> |
try { |
732 |
> |
q.poll(SMALL_DELAY_MS, MILLISECONDS); |
733 |
> |
shouldThrow(); |
734 |
> |
} catch (InterruptedException success) {} |
735 |
> |
}}); |
736 |
|
|
737 |
|
t.start(); |
738 |
|
Thread.sleep(SHORT_DELAY_MS); |
746 |
|
*/ |
747 |
|
public void testTimedPollWithOffer() throws InterruptedException { |
748 |
|
final LinkedBlockingDeque q = new LinkedBlockingDeque(2); |
749 |
< |
Thread t = new ThreadShouldThrow(InterruptedException.class) { |
749 |
> |
Thread t = new Thread(new CheckedRunnable() { |
750 |
|
public void realRun() throws InterruptedException { |
751 |
< |
threadAssertNull(q.poll(SHORT_DELAY_MS, MILLISECONDS)); |
752 |
< |
q.poll(LONG_DELAY_MS, MILLISECONDS); |
753 |
< |
q.poll(LONG_DELAY_MS, MILLISECONDS); |
754 |
< |
}}; |
751 |
> |
assertNull(q.poll(SHORT_DELAY_MS, MILLISECONDS)); |
752 |
> |
assertSame(zero, q.poll(LONG_DELAY_MS, MILLISECONDS)); |
753 |
> |
try { |
754 |
> |
q.poll(LONG_DELAY_MS, MILLISECONDS); |
755 |
> |
shouldThrow(); |
756 |
> |
} catch (InterruptedException success) {} |
757 |
> |
}}); |
758 |
|
|
759 |
|
t.start(); |
760 |
|
Thread.sleep(SMALL_DELAY_MS); |
936 |
|
* returning timeout status |
937 |
|
*/ |
938 |
|
public void testInterruptedTimedPollFirst() throws InterruptedException { |
939 |
< |
Thread t = new ThreadShouldThrow(InterruptedException.class) { |
939 |
> |
Thread t = new Thread(new CheckedRunnable() { |
940 |
|
public void realRun() throws InterruptedException { |
941 |
|
LinkedBlockingDeque q = populatedDeque(SIZE); |
942 |
|
for (int i = 0; i < SIZE; ++i) { |
943 |
< |
threadAssertEquals(i, ((Integer)q.pollFirst(SHORT_DELAY_MS, MILLISECONDS)).intValue()); |
943 |
> |
assertEquals(i, ((Integer)q.pollFirst(SHORT_DELAY_MS, MILLISECONDS)).intValue()); |
944 |
|
} |
945 |
< |
q.pollFirst(SMALL_DELAY_MS, MILLISECONDS); |
946 |
< |
}}; |
945 |
> |
try { |
946 |
> |
q.pollFirst(SMALL_DELAY_MS, MILLISECONDS); |
947 |
> |
shouldThrow(); |
948 |
> |
} catch (InterruptedException success) {} |
949 |
> |
}}); |
950 |
|
|
951 |
|
t.start(); |
952 |
|
Thread.sleep(SHORT_DELAY_MS); |
960 |
|
*/ |
961 |
|
public void testTimedPollFirstWithOfferFirst() throws InterruptedException { |
962 |
|
final LinkedBlockingDeque q = new LinkedBlockingDeque(2); |
963 |
< |
Thread t = new ThreadShouldThrow(InterruptedException.class) { |
963 |
> |
Thread t = new Thread(new CheckedRunnable() { |
964 |
|
public void realRun() throws InterruptedException { |
965 |
< |
threadAssertNull(q.pollFirst(SHORT_DELAY_MS, MILLISECONDS)); |
966 |
< |
q.pollFirst(LONG_DELAY_MS, MILLISECONDS); |
967 |
< |
q.pollFirst(LONG_DELAY_MS, MILLISECONDS); |
968 |
< |
}}; |
965 |
> |
assertNull(q.pollFirst(SHORT_DELAY_MS, MILLISECONDS)); |
966 |
> |
assertSame(zero, q.pollFirst(LONG_DELAY_MS, MILLISECONDS)); |
967 |
> |
try { |
968 |
> |
q.pollFirst(LONG_DELAY_MS, MILLISECONDS); |
969 |
> |
shouldThrow(); |
970 |
> |
} catch (InterruptedException success) {} |
971 |
> |
}}); |
972 |
|
|
973 |
|
t.start(); |
974 |
|
Thread.sleep(SMALL_DELAY_MS); |
1149 |
|
* returning timeout status |
1150 |
|
*/ |
1151 |
|
public void testInterruptedTimedPollLast() throws InterruptedException { |
1152 |
< |
Thread t = new ThreadShouldThrow(InterruptedException.class) { |
1152 |
> |
Thread t = new Thread(new CheckedRunnable() { |
1153 |
|
public void realRun() throws InterruptedException { |
1154 |
|
LinkedBlockingDeque q = populatedDeque(SIZE); |
1155 |
|
for (int i = 0; i < SIZE; ++i) { |
1156 |
< |
threadAssertEquals(SIZE-i-1, ((Integer)q.pollLast(SHORT_DELAY_MS, MILLISECONDS)).intValue()); |
1156 |
> |
assertEquals(SIZE-i-1, ((Integer)q.pollLast(SHORT_DELAY_MS, MILLISECONDS)).intValue()); |
1157 |
|
} |
1158 |
< |
q.pollLast(SMALL_DELAY_MS, MILLISECONDS); |
1159 |
< |
}}; |
1158 |
> |
try { |
1159 |
> |
q.pollLast(SMALL_DELAY_MS, MILLISECONDS); |
1160 |
> |
shouldThrow(); |
1161 |
> |
} catch (InterruptedException success) {} |
1162 |
> |
}}); |
1163 |
|
|
1164 |
|
t.start(); |
1165 |
|
Thread.sleep(SHORT_DELAY_MS); |