@Setup public void setup() { executor = Executors.newSingleThreadExecutor(); disruptor = new Disruptor<LongEvent>(LongEvent.EVENT_FACTORY, executor, new SingleThreadedClaimStrategy(Run.QUEUE_SIZE), new BusySpinWaitStrategy()); eventCount = new AtomicInteger(); handler = (event, sequence, endOfBatch) -> { if(Run.LONGVAL == event.getValue()) { eventCount.incrementAndGet(); } else { throw new RuntimeException("Failed."); } }; disruptor.handleEventsWith(handler); ringBuffer = disruptor.start(); }
public DisruptorQueue(ClaimStrategy claim, WaitStrategy wait) { _buffer = new RingBuffer<MutableObject>(new ObjectEventFactory(), claim, wait); _consumer = new Sequence(); _barrier = _buffer.newBarrier(); _buffer.setGatingSequences(_consumer); if(claim instanceof SingleThreadedClaimStrategy) { consumerStartedFlag = true; } }