LockQueue and putAll

Does anyone know why java BlockingQueue doesn't have putAll method? Is there a problem with this method? Any good ways to solve this problem without fully reimplementing BlockingQueue?

+3
source share
2 answers
for (Item item : items) {
    queue.put(item);
}

3 lines, not sure if it completely repeats the implementation of the lock queue.

I assume that he wants you to put 1 on 1 in the case when the threads are waiting for reading, they are not waiting for you to finish reading all of them.

+2
source

I found the same problem with ArrayBlockingQueue. We need additional methods that were missing:

  • void putAll(Collection<? extends E> c) throws InterruptedException
  • int drainAtLeastOneTo(@OutputParam Collection<? super E> c) throws InterruptedException
  • int drainAtLeastOneTo(@OutputParam Collection<? super E> c, int maxElements) throws InterruptedException

BlockingQueue<List<E>>, malloc'ing. . , , "".

: , . , . drainTo() , drainAtLeastOneTo() .

ArrayBlockingQueue . , , , BlockingQueue.

( ?) LMAX Disruptor, BlockingQueue, , .

0

Source: https://habr.com/ru/post/1752742/


All Articles