655 |
|
/** |
656 |
|
* timed offer times out if full and elements not taken |
657 |
|
*/ |
658 |
< |
public void testTimedOffer() throws InterruptedException { |
658 |
> |
public void testTimedOffer() { |
659 |
|
final LinkedBlockingDeque q = new LinkedBlockingDeque(2); |
660 |
|
final CountDownLatch pleaseInterrupt = new CountDownLatch(1); |
661 |
|
Thread t = newStartedThread(new CheckedRunnable() { |
665 |
|
long startTime = System.nanoTime(); |
666 |
|
assertFalse(q.offer(new Object(), timeoutMillis(), MILLISECONDS)); |
667 |
|
assertTrue(millisElapsedSince(startTime) >= timeoutMillis()); |
668 |
+ |
|
669 |
+ |
Thread.currentThread().interrupt(); |
670 |
+ |
try { |
671 |
+ |
q.offer(new Object(), 2 * LONG_DELAY_MS, MILLISECONDS); |
672 |
+ |
shouldThrow(); |
673 |
+ |
} catch (InterruptedException success) {} |
674 |
+ |
assertFalse(Thread.interrupted()); |
675 |
+ |
|
676 |
|
pleaseInterrupt.countDown(); |
677 |
|
try { |
678 |
|
q.offer(new Object(), 2 * LONG_DELAY_MS, MILLISECONDS); |
900 |
|
/** |
901 |
|
* timed offerFirst times out if full and elements not taken |
902 |
|
*/ |
903 |
< |
public void testTimedOfferFirst() throws InterruptedException { |
903 |
> |
public void testTimedOfferFirst() { |
904 |
|
final LinkedBlockingDeque q = new LinkedBlockingDeque(2); |
905 |
|
final CountDownLatch pleaseInterrupt = new CountDownLatch(1); |
906 |
|
Thread t = newStartedThread(new CheckedRunnable() { |
910 |
|
long startTime = System.nanoTime(); |
911 |
|
assertFalse(q.offerFirst(new Object(), timeoutMillis(), MILLISECONDS)); |
912 |
|
assertTrue(millisElapsedSince(startTime) >= timeoutMillis()); |
913 |
+ |
|
914 |
+ |
Thread.currentThread().interrupt(); |
915 |
+ |
try { |
916 |
+ |
q.offerFirst(new Object(), 2 * LONG_DELAY_MS, MILLISECONDS); |
917 |
+ |
shouldThrow(); |
918 |
+ |
} catch (InterruptedException success) {} |
919 |
+ |
assertFalse(Thread.interrupted()); |
920 |
+ |
|
921 |
|
pleaseInterrupt.countDown(); |
922 |
|
try { |
923 |
|
q.offerFirst(new Object(), 2 * LONG_DELAY_MS, MILLISECONDS); |
1235 |
|
pleaseTake.countDown(); |
1236 |
|
q.putLast(86); |
1237 |
|
|
1238 |
+ |
Thread.currentThread().interrupt(); |
1239 |
+ |
try { |
1240 |
+ |
q.putLast(99); |
1241 |
+ |
shouldThrow(); |
1242 |
+ |
} catch (InterruptedException success) {} |
1243 |
+ |
assertFalse(Thread.interrupted()); |
1244 |
+ |
|
1245 |
|
pleaseInterrupt.countDown(); |
1246 |
|
try { |
1247 |
|
q.putLast(99); |
1264 |
|
/** |
1265 |
|
* timed offerLast times out if full and elements not taken |
1266 |
|
*/ |
1267 |
< |
public void testTimedOfferLast() throws InterruptedException { |
1267 |
> |
public void testTimedOfferLast() { |
1268 |
|
final LinkedBlockingDeque q = new LinkedBlockingDeque(2); |
1269 |
|
final CountDownLatch pleaseInterrupt = new CountDownLatch(1); |
1270 |
|
Thread t = newStartedThread(new CheckedRunnable() { |
1274 |
|
long startTime = System.nanoTime(); |
1275 |
|
assertFalse(q.offerLast(new Object(), timeoutMillis(), MILLISECONDS)); |
1276 |
|
assertTrue(millisElapsedSince(startTime) >= timeoutMillis()); |
1277 |
+ |
|
1278 |
+ |
Thread.currentThread().interrupt(); |
1279 |
+ |
try { |
1280 |
+ |
q.offerLast(new Object(), 2 * LONG_DELAY_MS, MILLISECONDS); |
1281 |
+ |
shouldThrow(); |
1282 |
+ |
} catch (InterruptedException success) {} |
1283 |
+ |
|
1284 |
|
pleaseInterrupt.countDown(); |
1285 |
|
try { |
1286 |
|
q.offerLast(new Object(), 2 * LONG_DELAY_MS, MILLISECONDS); |