当前位置: 首页>>代码示例>>Java>>正文


Java RingBuffer.addGatingSequences方法代码示例

本文整理汇总了Java中com.lmax.disruptor.RingBuffer.addGatingSequences方法的典型用法代码示例。如果您正苦于以下问题:Java RingBuffer.addGatingSequences方法的具体用法?Java RingBuffer.addGatingSequences怎么用?Java RingBuffer.addGatingSequences使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.lmax.disruptor.RingBuffer的用法示例。


在下文中一共展示了RingBuffer.addGatingSequences方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: startup

import com.lmax.disruptor.RingBuffer; //导入方法依赖的package包/类
@Override
    public void startup() {
        EventBus eventBus = disruptorDispatchThread.getEventBus();
        executorService = new NonOrderedQueuePoolExecutor(poolName, excutorSize);
        cycleEventHandler = new CycleEventHandler[excutorSize];
        for(int i = 0; i < excutorSize; i++){
            cycleEventHandler[i] = new CycleEventHandler(eventBus);
        }

        RingBuffer ringBuffer = disruptorDispatchThread.getRingBuffer();
        workerPool = new WorkerPool(ringBuffer, ringBuffer.newBarrier(), new FatalExceptionHandler(), cycleEventHandler);
        ringBuffer.addGatingSequences(workerPool.getWorkerSequences());

        workerPool.start(executorService);

//        BatchEventProcessor<CycleEvent>[] batchEventProcessors = new BatchEventProcessor[excutorSize];
//        for(int i = 0; i < excutorSize; i++){
//            batchEventProcessors[i] = new BatchEventProcessor<>(ringBuffer, sequenceBarrier, cycleEventHandler[i]);
//            ringBuffer.addGatingSequences(batchEventProcessors[i].getSequence());
////            executorService.submit(batchEventProcessors[i]);
//        }
    }
 
开发者ID:jwpttcg66,项目名称:game-executor,代码行数:23,代码来源:DisruptorExecutorService.java

示例2: RingBufferConsumer

import com.lmax.disruptor.RingBuffer; //导入方法依赖的package包/类
RingBufferConsumer(@Nonnull final RingBuffer<T> buffer, @Nonnull final Object[] attachments) {
	if (buffer == null) {
		throw new NullPointerException("buffer == null");
	}
	if (attachments == null) {
		throw new NullPointerException("attachments == null");
	}
	if (buffer.getBufferSize() != attachments.length) {
		throw new IllegalArgumentException("buffer.getBufferSize() != attachments.length");
	}
	this.buffer = buffer;
	this.attachments = attachments;
	this.barrier = buffer.newBarrier();
	this.sequence = new Sequence();
	buffer.addGatingSequences(sequence);
	this.cursor = sequence.get();
	this.available = sequence.get();
}
 
开发者ID:ricardopadilha,项目名称:dsys-snio,代码行数:19,代码来源:RingBufferConsumer.java

示例3: BatchedPoller

import com.lmax.disruptor.RingBuffer; //导入方法依赖的package包/类
public BatchedPoller(RingBuffer<BatchedPoller.DataEvent<T>> ringBuffer, int batchSize)
{
    this.poller = ringBuffer.newPoller();
    ringBuffer.addGatingSequences(poller.getSequence());

    if (batchSize < 1)
    {
        batchSize = 20;
    }
    this.maxBatchSize = batchSize;
    this.polledData = new BatchedData<T>(this.maxBatchSize);
}
 
开发者ID:winwill2012,项目名称:disruptor-code-analysis,代码行数:13,代码来源:PullWithBatchedPoller.java

示例4: main

import com.lmax.disruptor.RingBuffer; //导入方法依赖的package包/类
public static void main(String[] args) {
	
	final List<ValueEventHandler1PMC> handlers = new ArrayList<>(NUMBER_CONSUMERS);
			
	RingBuffer<ValueEvent> ringBuffer = RingBuffer.createSingleProducer(
			ValueEvent.EVENT_FACTORY, RING_SIZE, new SleepingWaitStrategy());

	start = System.nanoTime();

	//Create consumers
	for(int i = 0;  i < NUMBER_CONSUMERS; i++) {
		ValueEventHandler1PMC handler = new ValueEventHandler1PMC(start, handlers);
		handlers.add(handler);
		SequenceBarrier barrier = ringBuffer.newBarrier();
		BatchEventProcessor<ValueEvent> eventProcessor = new BatchEventProcessor<ValueEvent>(
				ringBuffer,	barrier, handler);
		ringBuffer.addGatingSequences(eventProcessor.getSequence());

		// Each EventProcessor can run on a separate thread
		EXECUTOR.submit(eventProcessor);
	}
	
	for(int i = 0;  i  < SAMPLES_SIZE; i++) {
		// Publishers claim events in sequence
		long sequence = ringBuffer.next();
		ValueEvent event = ringBuffer.get(sequence);

		event.setValue(i); // this could be more complex with multiple fields
		
		// make the event available to EventProcessors
		ringBuffer.publish(sequence);   
	}

}
 
开发者ID:iproduct,项目名称:low-latency-high-throughput,代码行数:35,代码来源:Demo1PMC.java

示例5: main

import com.lmax.disruptor.RingBuffer; //导入方法依赖的package包/类
public static void main(String[] args) {
				
		RingBuffer<ValueEvent> ringBuffer = RingBuffer.createSingleProducer(
				ValueEvent.EVENT_FACTORY, RING_SIZE, new SleepingWaitStrategy());

		start = System.nanoTime();

		//Create first consumer
		ValueEventHandler1PMCSequenceFirst handler = new ValueEventHandler1PMCSequenceFirst(start);
		SequenceBarrier barrier;
		barrier = ringBuffer.newBarrier();
		BatchEventProcessor<ValueEvent> firstEventProcessor = new BatchEventProcessor<ValueEvent>(
				ringBuffer,	barrier, handler);
//		ringBuffer.addGatingSequences(firstEventProcessor.getSequence());
		
		// Each EventProcessor can run on a separate thread
		EXECUTOR.submit(firstEventProcessor);

		//Create second consumer
		ValueEventHandler1PMCSequenceSecond handler2 = new ValueEventHandler1PMCSequenceSecond(start);
		SequenceBarrier barrier2 = ringBuffer.newBarrier(firstEventProcessor.getSequence());
		BatchEventProcessor<ValueEvent> secondEventProcessor = new BatchEventProcessor<ValueEvent>(
				ringBuffer,	barrier2, handler2);
		ringBuffer.addGatingSequences(secondEventProcessor.getSequence());
		
		// Each EventProcessor can run on a separate thread
		EXECUTOR.submit(secondEventProcessor);

		
		for(int i = 0;  i  < SAMPLES_SIZE; i++) {
			// Publishers claim events in sequence
			long sequence = ringBuffer.next();
			ValueEvent event = ringBuffer.get(sequence);

			event.setValue(i); // this could be more complex with multiple fields
			
			// make the event available to EventProcessors
			ringBuffer.publish(sequence);   
		}

	}
 
开发者ID:iproduct,项目名称:low-latency-high-throughput,代码行数:42,代码来源:Demo1PMCSequence.java


注:本文中的com.lmax.disruptor.RingBuffer.addGatingSequences方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。