Search in sources :

Example 41 with SynchronousQueue

use of java.util.concurrent.SynchronousQueue in project j2objc by google.

the class SynchronousQueueTest method testTimedPoll.

public void testTimedPoll(boolean fair) {
    final SynchronousQueue q = new SynchronousQueue(fair);
    long startTime = System.nanoTime();
    try {
        assertNull(q.poll(timeoutMillis(), MILLISECONDS));
    } catch (InterruptedException e) {
        threadUnexpectedException(e);
    }
    assertTrue(millisElapsedSince(startTime) >= timeoutMillis());
}
Also used : SynchronousQueue(java.util.concurrent.SynchronousQueue)

Example 42 with SynchronousQueue

use of java.util.concurrent.SynchronousQueue in project j2objc by google.

the class SynchronousQueueTest method testAdd.

public void testAdd(boolean fair) {
    SynchronousQueue q = new SynchronousQueue(fair);
    assertEquals(0, q.remainingCapacity());
    try {
        q.add(one);
        shouldThrow();
    } catch (IllegalStateException success) {
    }
}
Also used : SynchronousQueue(java.util.concurrent.SynchronousQueue)

Example 43 with SynchronousQueue

use of java.util.concurrent.SynchronousQueue in project j2objc by google.

the class SynchronousQueueTest method testSerialization.

/**
 * a deserialized serialized queue is usable
 */
public void testSerialization() {
    final SynchronousQueue x = new SynchronousQueue();
    final SynchronousQueue y = new SynchronousQueue(false);
    final SynchronousQueue z = new SynchronousQueue(true);
    assertSerialEquals(x, y);
    assertNotSerialEquals(x, z);
    SynchronousQueue[] qs = { x, y, z };
    for (SynchronousQueue q : qs) {
        SynchronousQueue clone = serialClone(q);
        assertNotSame(q, clone);
        assertSerialEquals(q, clone);
        assertTrue(clone.isEmpty());
        assertEquals(0, clone.size());
        assertEquals(0, clone.remainingCapacity());
        assertFalse(clone.offer(zero));
    }
}
Also used : SynchronousQueue(java.util.concurrent.SynchronousQueue)

Example 44 with SynchronousQueue

use of java.util.concurrent.SynchronousQueue in project j2objc by google.

the class SynchronousQueueTest method testToString.

public void testToString(boolean fair) {
    final SynchronousQueue q = new SynchronousQueue(fair);
    String s = q.toString();
    assertNotNull(s);
}
Also used : SynchronousQueue(java.util.concurrent.SynchronousQueue)

Example 45 with SynchronousQueue

use of java.util.concurrent.SynchronousQueue in project j2objc by google.

the class SynchronousQueueTest method testPoll.

public void testPoll(boolean fair) {
    final SynchronousQueue q = new SynchronousQueue(fair);
    assertNull(q.poll());
}
Also used : SynchronousQueue(java.util.concurrent.SynchronousQueue)

Aggregations

SynchronousQueue (java.util.concurrent.SynchronousQueue)117 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)61 ExecutorService (java.util.concurrent.ExecutorService)20 ThreadFactory (java.util.concurrent.ThreadFactory)14 ArrayList (java.util.ArrayList)12 LinkedBlockingQueue (java.util.concurrent.LinkedBlockingQueue)12 IOException (java.io.IOException)9 RejectedExecutionHandler (java.util.concurrent.RejectedExecutionHandler)9 Test (org.junit.Test)9 ScheduledThreadPoolExecutor (java.util.concurrent.ScheduledThreadPoolExecutor)8 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)8 InputStream (java.io.InputStream)7 OutputStream (java.io.OutputStream)7 BlockingQueue (java.util.concurrent.BlockingQueue)7 XMPPException (org.jivesoftware.smack.XMPPException)7 Future (java.util.concurrent.Future)6 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)6 CountDownLatch (java.util.concurrent.CountDownLatch)5 XMPPConnection (org.jivesoftware.smack.XMPPConnection)5 List (java.util.List)4