Question

Now I am using disruptor,I get a simple example of consumer-productor.It runs perfect,But I don't know the meaning of buffersize,which size should I set to it?

private static final int BUFFER_SIZE = 4;

private final RingBuffer<StockEvent> ringBuffer =
    new RingBuffer<StockEvent>(StockEvent.EVENT_FACTORY,
                               new MultiThreadedLowContentionClaimStrategy(BUFFER_SIZE),
                               new YieldingWaitStrategy());
private final SequenceBarrier sequenceBarrier = ringBuffer.newBarrier();

what's the meaning of BUFFER_SIZE?

Was it helpful?

Solution

RingBuffer has a fixed array allocation size. It needs a pre-set buffer size to initiate the needed allocation. It's recommended keep this size more than 11 (keeping in mind that bufferSize should be a power of 2), yet this depends on the hosting machine & on your architecture.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top