Java BlockingQueue with batching?

前端 未结 5 1575
有刺的猬
有刺的猬 2021-01-01 16:00

I am interested in a data structure identical to the Java BlockingQueue, with the exception that it must be able to batch objects in the queue. In other words, I would like

5条回答
  •  误落风尘
    2021-01-01 16:18

    This sounds like how the RingBuffer works in the LMAX Disruptor pattern. See http://code.google.com/p/disruptor/ for more.

    A very rough explanation is your main data structure is the RingBuffer. Producers put data in to the ring buffer in sequence and consumers can pull off as much data as the producer has put in to the buffer (so essentially batching). If the buffer is full, the producer blocks until the consumer has finished and freed up slots in the buffer.

提交回复
热议问题