guolei
guolei

Reputation: 99

How to set disruptor's ClaimStrategy buffersize

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?

Upvotes: 1

Views: 452

Answers (1)

Evan P
Evan P

Reputation: 1817

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.

Upvotes: 1

Related Questions