use of java.util.concurrent.BlockingDeque in project mapdb by jankotek.
the class LinkedBlockingDequeTest method testTakeLastFromEmptyBlocksInterruptibly.
/**
* takeLast() blocks interruptibly when empty
*/
public void testTakeLastFromEmptyBlocksInterruptibly() {
final BlockingDeque q = new LinkedBlockingDeque();
final CountDownLatch threadStarted = new CountDownLatch(1);
Thread t = newStartedThread(new CheckedRunnable() {
public void realRun() {
threadStarted.countDown();
try {
q.takeLast();
shouldThrow();
} catch (InterruptedException success) {
}
assertFalse(Thread.interrupted());
}
});
await(threadStarted);
assertThreadStaysAlive(t);
t.interrupt();
awaitTermination(t);
}
use of java.util.concurrent.BlockingDeque in project mapdb by jankotek.
the class LinkedBlockingDequeTest method testTakeLastFromEmptyAfterInterrupt.
/**
* takeLast() throws InterruptedException immediately if interrupted
* before waiting
*/
public void testTakeLastFromEmptyAfterInterrupt() {
final BlockingDeque q = new LinkedBlockingDeque();
Thread t = newStartedThread(new CheckedRunnable() {
public void realRun() {
Thread.currentThread().interrupt();
try {
q.takeLast();
shouldThrow();
} catch (InterruptedException success) {
}
assertFalse(Thread.interrupted());
}
});
awaitTermination(t);
}
use of java.util.concurrent.BlockingDeque in project mapdb by jankotek.
the class LinkedBlockingDequeTest method testTakeFirstFromEmptyAfterInterrupt.
/**
* takeFirst() throws InterruptedException immediately if interrupted
* before waiting
*/
public void testTakeFirstFromEmptyAfterInterrupt() {
final BlockingDeque q = new LinkedBlockingDeque();
Thread t = newStartedThread(new CheckedRunnable() {
public void realRun() {
Thread.currentThread().interrupt();
try {
q.takeFirst();
shouldThrow();
} catch (InterruptedException success) {
}
assertFalse(Thread.interrupted());
}
});
awaitTermination(t);
}
use of java.util.concurrent.BlockingDeque in project mapdb by jankotek.
the class LinkedBlockingDequeTest method testTakeFirstFromEmptyBlocksInterruptibly.
/**
* takeFirst() blocks interruptibly when empty
*/
public void testTakeFirstFromEmptyBlocksInterruptibly() {
final BlockingDeque q = new LinkedBlockingDeque();
final CountDownLatch threadStarted = new CountDownLatch(1);
Thread t = newStartedThread(new CheckedRunnable() {
public void realRun() {
threadStarted.countDown();
try {
q.takeFirst();
shouldThrow();
} catch (InterruptedException success) {
}
assertFalse(Thread.interrupted());
}
});
await(threadStarted);
assertThreadStaysAlive(t);
t.interrupt();
awaitTermination(t);
}
Aggregations