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


Java RingBuffer.next方法代码示例

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


在下文中一共展示了RingBuffer.next方法的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 * BATCH_SIZE;
    handler.reset(latch, expectedCount);
    executor.submit(batchEventProcessor);
    long start = System.currentTimeMillis();

    final RingBuffer<ValueEvent> rb = ringBuffer;

    for (long i = 0; i < ITERATIONS; i++)
    {
        long hi = rb.next(BATCH_SIZE);
        long lo = hi - (BATCH_SIZE - 1);
        for (long l = lo; l <= hi; l++)
        {
            rb.get(l).setValue(i);
        }
        rb.publish(lo, hi);
    }

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

    failIfNot(expectedResult, handler.getValue());

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

示例7: runDisruptorPass

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

    final RingBuffer<ValueEvent> rb = ringBuffer;

    for (long i = 0; i < ITERATIONS; i++)
    {
        long next = rb.next();
        rb.get(next).setValue(i);
        rb.publish(next);
    }

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

    failIfNot(expectedResult, pollRunnable.getValue());

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

示例8: 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, expectedCount);
    executor.submit(batchEventProcessor);
    long start = System.currentTimeMillis();

    final RingBuffer<ValueEvent> rb = ringBuffer;

    for (long i = 0; i < ITERATIONS; i++)
    {
        long next = rb.next();
        rb.get(next).setValue(i);
        rb.publish(next);
    }

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

    failIfNot(expectedResult, handler.getValue());

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

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

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

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

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

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

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

示例15: process

import com.lmax.disruptor.RingBuffer; //导入方法依赖的package包/类
public void process() throws IOException {
    try (FastBufferedInputStream stream = new FastBufferedInputStream(inputStreamFactory.get())) {
        Preconditions.checkArgument(phaser.getRegisteredParties() == 0);
        phaser.register();
        disruptor.start();
        RingBuffer<? extends TwoPhaseEvent> ringBuffer = disruptor.getRingBuffer();
        long cursor = ringBuffer.next();
        LineBytesBuffer buffer = ringBuffer.get(cursor).input();
        long lineNo = 0;
        ringBuffer.get(cursor).lineNo(lineNo);
        boolean needToSkipNext = skipFirst;
        while (buffer.readLineFrom(stream)) {
            if (needToSkipNext) {
                needToSkipNext = false;
                continue;
            }
            lineNo++;
            ringBuffer.publish(cursor);
            cursor = ringBuffer.next();
            buffer = ringBuffer.get(cursor).input();
            ringBuffer.get(cursor).lineNo(lineNo);
        }
        disruptor.shutdown();
        phaser.arriveAndAwaitAdvance();
        phaser.arriveAndDeregister();
    } finally {
        afterDisruptorProcessed();
    }
}
 
开发者ID:scaled-ml,项目名称:Scaled-ML,代码行数:30,代码来源:BaseDisruptorRunner.java


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