Examples of drainTo()


Examples of java.util.concurrent.BlockingQueue.drainTo()

     * drainTo(this, n) throws IllegalArgumentException
     */
    public void testDrainToSelfN() {
        final BlockingQueue q = emptyCollection();
        try {
            q.drainTo(q, 0);
            shouldThrow();
        } catch (IllegalArgumentException success) {
        }
    }

View Full Code Here

Examples of java.util.concurrent.BlockingQueue.drainTo()

     */
    public void testDrainToNonPositiveMaxElements() {
        final BlockingQueue q = emptyCollection();
        final int[] ns = {0, -1, -42, Integer.MIN_VALUE};
        for (int n : ns)
            assertEquals(0, q.drainTo(new ArrayList(), n));
        if (q.remainingCapacity() > 0) {
            // Not SynchronousQueue, that is
            Object one = makeElement(1);
            q.add(one);
            ArrayList c = new ArrayList();
View Full Code Here

Examples of java.util.concurrent.BlockingQueue.drainTo()

            // Not SynchronousQueue, that is
            Object one = makeElement(1);
            q.add(one);
            ArrayList c = new ArrayList();
            for (int n : ns)
                assertEquals(0, q.drainTo(new ArrayList(), n));
            assertEquals(1, q.size());
            assertSame(one, q.poll());
            assertTrue(c.isEmpty());
        }
    }
View Full Code Here

Examples of java.util.concurrent.BlockingQueue.drainTo()

        BlockingQueue q = new SharedConcurrentBlockingObjectQueue<Integer>(SIZE * 2, Integer.class);
        for (int i = 0; i < SIZE + 2; ++i) {
            for (int j = 0; j < SIZE; j++)
                assertTrue(q.offer(new Integer(j)));
            ArrayList l = new ArrayList();
            q.drainTo(l, i);
            int k = (i < SIZE) ? i : SIZE;
            assertEquals(k, l.size());
            assertEquals(SIZE - k, q.size());
            for (int j = 0; j < k; ++j)
                assertEquals(l.get(j), new Integer(j));
View Full Code Here

Examples of java.util.concurrent.BlockingQueue.drainTo()

    BlockingQueue newQueue = QueuesHolder.getQueue(queueName);
    task.start();

    List list = new ArrayList();
    newQueue.drainTo(list);

    assertEquals(2, list.size());
    assertEquals(date1, list.get(0));

    //判断存在持久化文件
View Full Code Here

Examples of net.openhft.chronicle.sandbox.queue.LocalConcurrentBlockingObjectQueue.drainTo()

        BlockingQueue q = new LocalConcurrentBlockingObjectQueue(SIZE * 2);
        for (int i = 0; i < SIZE + 2; ++i) {
            for (int j = 0; j < SIZE; j++)
                assertTrue(q.offer(new Integer(j)));
            ArrayList l = new ArrayList();
            q.drainTo(l, i);
            int k = (i < SIZE) ? i : SIZE;
            assertEquals(k, l.size());
            assertEquals(SIZE - k, q.size());
            for (int j = 0; j < k; ++j)
                assertEquals(l.get(j), new Integer(j));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.