Java 类com.lmax.disruptor.SingleThreadedClaimStrategy 实例源码

项目:disruptor_benchmark    文件:LMAXDisruptorPushPullBenchmark.java   
@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();
}
项目:incubator-storm    文件:DisruptorQueue.java   
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;
    }
}
项目:storm-resa    文件:DisruptorQueue.java   
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;
    }
}