当前位置: 首页>>代码示例>>Java>>正文


Java ArrayBlockingQueue.addAll方法代码示例

本文整理汇总了Java中java.util.concurrent.ArrayBlockingQueue.addAll方法的典型用法代码示例。如果您正苦于以下问题:Java ArrayBlockingQueue.addAll方法的具体用法?Java ArrayBlockingQueue.addAll怎么用?Java ArrayBlockingQueue.addAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.concurrent.ArrayBlockingQueue的用法示例。


在下文中一共展示了ArrayBlockingQueue.addAll方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: pushEvent

import java.util.concurrent.ArrayBlockingQueue; //导入方法依赖的package包/类
private void pushEvent(ApsDvsEvent ev) {
    if(imuLagMs==0){
        heldEvent=ev;
        return;
    }
    ApsDvsEvent ne = new ApsDvsEvent();
    ne.copyFrom(ev);
    if (!eventQueue.offer(ne)) {
        // increase queue size
        ArrayBlockingQueue<ApsDvsEvent> newQueue = new ArrayBlockingQueue<ApsDvsEvent>(eventQueue.size() * 2);
        log.info("increased event queue to " + newQueue.remainingCapacity() + " events");
        newQueue.addAll(eventQueue);
        eventQueue = newQueue;
        eventQueue.offer(ne);
    };
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:17,代码来源:Steadicam.java

示例2: testAddAllSelf

import java.util.concurrent.ArrayBlockingQueue; //导入方法依赖的package包/类
/**
 * addAll(this) throws IllegalArgumentException
 */
public void testAddAllSelf() {
    ArrayBlockingQueue q = populatedQueue(SIZE);
    try {
        q.addAll(q);
        shouldThrow();
    } catch (IllegalArgumentException success) {}
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:ArrayBlockingQueueTest.java

示例3: testAddAll3

import java.util.concurrent.ArrayBlockingQueue; //导入方法依赖的package包/类
/**
 * addAll of a collection with any null elements throws NPE after
 * possibly adding some elements
 */
public void testAddAll3() {
    ArrayBlockingQueue q = new ArrayBlockingQueue(SIZE);
    Integer[] ints = new Integer[SIZE];
    for (int i = 0; i < SIZE - 1; ++i)
        ints[i] = new Integer(i);
    try {
        q.addAll(Arrays.asList(ints));
        shouldThrow();
    } catch (NullPointerException success) {}
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:15,代码来源:ArrayBlockingQueueTest.java

示例4: testAddAll_insufficientSpace

import java.util.concurrent.ArrayBlockingQueue; //导入方法依赖的package包/类
/**
 * addAll throws IllegalStateException if not enough room
 */
public void testAddAll_insufficientSpace() {
    int size = ThreadLocalRandom.current().nextInt(1, SIZE);
    ArrayBlockingQueue q = populatedQueue(0, size, size, false);
    // Just fits:
    q.addAll(populatedQueue(size, size, 2 * size, false));
    assertEquals(0, q.remainingCapacity());
    assertEquals(size, q.size());
    assertEquals(0, q.peek());
    try {
        q = populatedQueue(0, size, size, false);
        q.addAll(Collections.nCopies(size + 1, 42));
        shouldThrow();
    } catch (IllegalStateException success) {}
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:ArrayBlockingQueueTest.java

示例5: run

import java.util.concurrent.ArrayBlockingQueue; //导入方法依赖的package包/类
void run() throws Throwable {
//         System.out.printf(
//             "iterations=%d size=%d, warmup=%1g, filter=\"%s\"%n",
//             iterations, size, warmupSeconds, filter);

        final ArrayList<Integer> al = new ArrayList<>(size);

        // Populate collections with random data
        final ThreadLocalRandom rnd = ThreadLocalRandom.current();
        for (int i = 0; i < size; i++)
            al.add(rnd.nextInt(size));

        final ArrayDeque<Integer> ad = new ArrayDeque<>(al);
        final ArrayBlockingQueue<Integer> abq = new ArrayBlockingQueue<>(al.size());
        abq.addAll(al);

        // shuffle circular array elements so they wrap
        for (int i = 0, n = rnd.nextInt(size); i < n; i++) {
            ad.addLast(ad.removeFirst());
            abq.add(abq.remove());
        }

        ArrayList<Job> jobs = new ArrayList<>(Arrays.asList());

        List.of(al, ad, abq,
                new LinkedList<>(al),
                new PriorityQueue<>(al),
                new Vector<>(al),
                new ConcurrentLinkedQueue<>(al),
                new ConcurrentLinkedDeque<>(al),
                new LinkedBlockingQueue<>(al),
                new LinkedBlockingDeque<>(al),
                new LinkedTransferQueue<>(al),
                new PriorityBlockingQueue<>(al))
            .stream()
            .forEach(x -> {
                         jobs.addAll(collectionJobs(x));
                         if (x instanceof Deque)
                             jobs.addAll(dequeJobs((Deque<Integer>)x));
                     });

        if (reverse) Collections.reverse(jobs);
        if (shuffle) Collections.shuffle(jobs);

        time(filter(filter, jobs));
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:47,代码来源:IteratorMicroBenchmark.java


注:本文中的java.util.concurrent.ArrayBlockingQueue.addAll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。