Java Code Examples for java.util.concurrent.LinkedBlockingDeque#getFirst()
The following examples show how to use
java.util.concurrent.LinkedBlockingDeque#getFirst() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PaxosTests.java From rapid with Apache License 2.0 | 6 votes |
/** * Wait and then verify all consensus decisions * * @param expectedSize expected size of each cluster * @param maxTries number of tries to checkSubject if the cluster has stabilized. * @param intervalInMs the time duration between checks. * @param decisions the reported consensus decisions */ private void waitAndVerifyAgreement(final int expectedSize, final int maxTries, final int intervalInMs, final LinkedBlockingDeque<List<Endpoint>> decisions) throws InterruptedException { int tries = maxTries; while (--tries > 0) { if (decisions.size() != expectedSize) { Thread.sleep(intervalInMs); } else { break; } } assertEquals(expectedSize, decisions.size()); if (expectedSize > 0) { final List<Endpoint> first = decisions.getFirst(); assertAll(first, decisions); } }
Example 2
Source File: LinkedBlockingDequeTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * getFirst() returns first element, or throws NSEE if empty */ public void testFirstElement() { LinkedBlockingDeque q = populatedDeque(SIZE); for (int i = 0; i < SIZE; ++i) { assertEquals(i, q.getFirst()); assertEquals(i, q.pollFirst()); } try { q.getFirst(); shouldThrow(); } catch (NoSuchElementException success) {} assertNull(q.peekFirst()); }
Example 3
Source File: LinkedBlockingDequeTest.java From j2objc with Apache License 2.0 | 5 votes |
/** * getFirst() returns first element, or throws NSEE if empty */ public void testFirstElement() { LinkedBlockingDeque q = populatedDeque(SIZE); for (int i = 0; i < SIZE; ++i) { assertEquals(i, q.getFirst()); assertEquals(i, q.pollFirst()); } try { q.getFirst(); shouldThrow(); } catch (NoSuchElementException success) {} assertNull(q.peekFirst()); }