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


Java RingBuffer.get方法代码示例

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


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

示例1: channelRead0

import com.lmax.disruptor.RingBuffer; //导入方法依赖的package包/类
@Override
protected void channelRead0(ChannelHandlerContext ctx, O msg) throws Exception {
    UUID uuid = CHANNEL_UUID.get(ctx.channel());
    if (null != uuid) {
        NetSession session = SESSIONS.get(uuid);
        if (null != session) {
            RingBuffer<ConcurrentEvent> ringBuffer = THREAD_LOCAL.get().getRingBuffer();
            long next = ringBuffer.next();
            try {
                ConcurrentEvent commandEvent = ringBuffer.get(next);
                commandEvent.setValues(newExecutor(session, msg));
            } finally {
                ringBuffer.publish(next);
            }
        }
    }
}
 
开发者ID:ogcs,项目名称:Okra-Ax,代码行数:18,代码来源:DisruptorAdapterHandler.java

示例2: channelRead0

import com.lmax.disruptor.RingBuffer; //导入方法依赖的package包/类
@Override
protected void channelRead0(ChannelHandlerContext ctx, O msg) throws Exception {
    UUID uuid = CHANNEL_UUID.get(ctx.channel());
    if (null != uuid) {
        Session session = SESSIONS.get(uuid);
        if (null != session) {
            RingBuffer<ConcurrentEvent> ringBuffer = THREAD_LOCAL.get().getRingBuffer();
            long next = ringBuffer.next();
            try {
                ConcurrentEvent commandEvent = ringBuffer.get(next);
                commandEvent.setValues(newExecutor(session, msg));
            } finally {
                ringBuffer.publish(next);
            }
        }
    }
}
 
开发者ID:ogcs,项目名称:Okra,代码行数:18,代码来源:DisruptorAdapterHandler.java

示例3: synchronousFire

import com.lmax.disruptor.RingBuffer; //导入方法依赖的package包/类
@Override
public void synchronousFire( final Object event ) {
    eventCount.increment();
    CountDownLatch latch = new CountDownLatch( handlers.size() );
    try {
        RingBuffer<StatisticEventHolder> ringBuffer = disruptor.getRingBuffer();
        long sequence = ringBuffer.next();
        try {
            StatisticEventHolder holder = ringBuffer.get( sequence );
            holder.set( event );
            holder.setLatch( latch );
        } finally {
            ringBuffer.publish( sequence );
        }
        latch.await();
    } catch ( InterruptedException e ) {
        return;
    }
}
 
开发者ID:Tetha,项目名称:bifroest,代码行数:20,代码来源:DisruptorEventBus.java

示例4: channelRead0

import com.lmax.disruptor.RingBuffer; //导入方法依赖的package包/类
@Override
protected void channelRead0(ChannelHandlerContext ctx, GpcCall msg) throws Exception {
    NetSession session = NET_SESSION_MAP.get(ctx.channel().id());
    if (null == session)
        return;
    RingBuffer<ConcurrentEvent> ringBuffer = THREAD_LOCAL.get().getRingBuffer();
    long next = ringBuffer.next();
    try {
        ConcurrentEvent commandEvent = ringBuffer.get(next);
        commandEvent.setValues(newExecutor(session, msg));
    } finally {
        ringBuffer.publish(next);
    }
}
 
开发者ID:ogcs,项目名称:Okra-Ax,代码行数:15,代码来源:GpcEventDispatcher.java

示例5: channelRead0

import com.lmax.disruptor.RingBuffer; //导入方法依赖的package包/类
@Override
protected void channelRead0(ChannelHandlerContext ctx, O msg) throws Exception {
    NetSession session = SESSIONS.get(ctx.channel().id());
    if (null == session) {
        return;
    }
    RingBuffer<ConcurrentEvent> ringBuffer = THREAD_LOCAL.get().getRingBuffer();
    long next = ringBuffer.next();
    try {
        ConcurrentEvent commandEvent = ringBuffer.get(next);
        commandEvent.setValues(newExecutor(session, msg));
    } finally {
        ringBuffer.publish(next);
    }
}
 
开发者ID:ogcs,项目名称:Okra-Ax,代码行数:16,代码来源:DisruptorAdapterBy41xHandler.java

示例6: runDisruptorPass

import com.lmax.disruptor.RingBuffer; //导入方法依赖的package包/类
@Override
protected long runDisruptorPass() throws InterruptedException
{
    final CountDownLatch latch = new CountDownLatch(1);
    long expectedCount = batchEventProcessor.getSequence().get() + ITERATIONS;
    handler.reset(latch, ITERATIONS);
    executor.submit(batchEventProcessor);
    long start = System.currentTimeMillis();

    final RingBuffer<long[]> rb = ringBuffer;

    for (long i = 0; i < ITERATIONS; i++)
    {
        long next = rb.next();
        long[] event = rb.get(next);
        for (int j = 0; j < event.length; j++)
        {
            event[j] = i;
        }
        rb.publish(next);
    }

    latch.await();
    long opsPerSecond = (ITERATIONS * ARRAY_SIZE * 1000L) / (System.currentTimeMillis() - start);
    waitForEventProcessorSequence(expectedCount);
    batchEventProcessor.halt();

    PerfTestUtil.failIf(0, handler.getValue());

    return opsPerSecond;
}
 
开发者ID:winwill2012,项目名称:disruptor-code-analysis,代码行数:32,代码来源:OneToOneSequencedLongArrayThroughputTest.java

示例7: runDisruptorPass

import com.lmax.disruptor.RingBuffer; //导入方法依赖的package包/类
@Override
protected long runDisruptorPass() throws Exception
{
    byte[] data = this.data;

    final CountDownLatch latch = new CountDownLatch(1);
    long expectedCount = processor.getSequence().get() + ITERATIONS;
    handler.reset(latch, ITERATIONS);
    executor.execute(processor);
    long start = System.currentTimeMillis();

    final RingBuffer<ByteBuffer> rb = buffer;

    for (long i = 0; i < ITERATIONS; i++)
    {
        long next = rb.next();
        ByteBuffer event = rb.get(next);
        event.clear();
        event.put(data);
        event.flip();
        rb.publish(next);
    }

    latch.await();
    long opsPerSecond = (ITERATIONS * 1000L) / (System.currentTimeMillis() - start);
    waitForEventProcessorSequence(expectedCount);
    processor.halt();

    return opsPerSecond;
}
 
开发者ID:winwill2012,项目名称:disruptor-code-analysis,代码行数:31,代码来源:OneToOneOnHeapThroughputTest.java

示例8: publish

import com.lmax.disruptor.RingBuffer; //导入方法依赖的package包/类
/**
 * Publish record task to record special table's log.
 *
 * @param struct The table struct.
 * @param list   The log data list.
 */
public void publish(Struct struct, List<String[]> list) {
    RingBuffer<LogRecordTask> rb = disruptor.getRingBuffer();
    long next = rb.next();
    try {
        LogRecordTask event = rb.get(next);
        event.setValues(struct, list);
    } finally {
        rb.publish(next);
    }
}
 
开发者ID:ogcs,项目名称:Okra-LOG,代码行数:17,代码来源:MissionBoard.java

示例9: onNext

import com.lmax.disruptor.RingBuffer; //导入方法依赖的package包/类
public static <E> void onNext(E value, RingBuffer<MutableSignal<E>> ringBuffer) {
  if (value == null) {
    throw SpecificationExceptions.spec_2_13_exception();
  }

  final long seqId = ringBuffer.next();
  final MutableSignal<E> signal = ringBuffer.get(seqId);
  signal.type = MutableSignal.Type.NEXT;
  signal.value = value;

  ringBuffer.publish(seqId);
}
 
开发者ID:camunda,项目名称:camunda-bpm-reactor,代码行数:13,代码来源:RingBufferSubscriberUtils.java

示例10: onError

import com.lmax.disruptor.RingBuffer; //导入方法依赖的package包/类
public static <E> void onError(Throwable error, RingBuffer<MutableSignal<E>> ringBuffer) {
  if (error == null) {
    throw SpecificationExceptions.spec_2_13_exception();
  }

  final long seqId = ringBuffer.next();
  final MutableSignal<E> signal = ringBuffer.get(seqId);

  signal.type = MutableSignal.Type.ERROR;
  signal.value = null;
  signal.error = error;

  ringBuffer.publish(seqId);
}
 
开发者ID:camunda,项目名称:camunda-bpm-reactor,代码行数:15,代码来源:RingBufferSubscriberUtils.java

示例11: onComplete

import com.lmax.disruptor.RingBuffer; //导入方法依赖的package包/类
public static <E> void onComplete(RingBuffer<MutableSignal<E>> ringBuffer) {
  final long seqId = ringBuffer.next();
  final MutableSignal<E> signal = ringBuffer.get(seqId);

  signal.type = MutableSignal.Type.COMPLETE;
  signal.value = null;
  signal.error = null;

  ringBuffer.publish(seqId);
}
 
开发者ID:camunda,项目名称:camunda-bpm-reactor,代码行数:11,代码来源:RingBufferSubscriberUtils.java

示例12: 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

示例13: channelRead0

import com.lmax.disruptor.RingBuffer; //导入方法依赖的package包/类
@Override
protected void channelRead0(ChannelHandlerContext ctx, O msg) throws Exception {
    Session session = SESSIONS.get(ctx.channel().id());
    if (null == session) {
        return;
    }
    RingBuffer<ConcurrentEvent> ringBuffer = THREAD_LOCAL.get().getRingBuffer();
    long next = ringBuffer.next();
    try {
        ConcurrentEvent commandEvent = ringBuffer.get(next);
        commandEvent.setValues(newExecutor(session, msg));
    } finally {
        ringBuffer.publish(next);
    }
}
 
开发者ID:ogcs,项目名称:Okra,代码行数:16,代码来源:DisruptorAdapterBy41xHandler.java

示例14: fire

import com.lmax.disruptor.RingBuffer; //导入方法依赖的package包/类
@Override
public void fire( final Object event ) {
    eventCount.increment();
    RingBuffer<StatisticEventHolder> ringBuffer = disruptor.getRingBuffer();
    long sequence = ringBuffer.next();
    try {
        StatisticEventHolder holder = ringBuffer.get( sequence );
        holder.set( event );
        holder.setLatch( null );
    } finally {
        ringBuffer.publish( sequence );
    }
}
 
开发者ID:Tetha,项目名称:bifroest,代码行数:14,代码来源:DisruptorEventBus.java

示例15: run

import com.lmax.disruptor.RingBuffer; //导入方法依赖的package包/类
@Override
public void run(){
    _logger.info("Node run starting...");
    Executor executor = Executors.newCachedThreadPool();
    Disruptor<SurfEvent> disruptor = new Disruptor<>(SurfEvent.EVENT_FACTORY, 128, executor);
    disruptor.handleEventsWith(this);
    RingBuffer<SurfEvent> buffer = disruptor.start();


    VDSEventListImpl events = null;
    while(!_shutdown){
        try{
            events = _eventListPool.borrowObject(0);
            while(events.getEventsList().isEmpty()) {
                _source.read(events);
            }
            if(_needsAck){
                Object obj = _acksource.getInputObject();
                // Hacking this in for now
                // Need to actually ack the object after Kinesis consumes it: TODO
                _acksource.updateInputObject(obj);
            }
            long seq = buffer.next();
            SurfEvent event = buffer.get(seq);
            event.setEventlist(events);
            buffer.publish(seq);
        }
        catch(Exception ex){
            _logger.error("Exception while reading data:", ex);
            ex.printStackTrace();
        }
    }
}
 
开发者ID:InformaticaCorp,项目名称:Surf,代码行数:34,代码来源:Node.java


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