本文整理汇总了C#中RingBuffer.setGatingSequences方法的典型用法代码示例。如果您正苦于以下问题:C# RingBuffer.setGatingSequences方法的具体用法?C# RingBuffer.setGatingSequences怎么用?C# RingBuffer.setGatingSequences使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RingBuffer
的用法示例。
在下文中一共展示了RingBuffer.setGatingSequences方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: setup
void setup()
{
ringBuffer = new RingBuffer<StubEvent>(StubEvent.EVENT_FACTORY, 32);
ringBuffer.setGatingSequences(new NoOpEventProcessor(ringBuffer).getSequence());
sequenceBarrier = ringBuffer.newBarrier();
EXECUTOR = Executors.newSingleThreadExecutor(new DaemonThreadFactory());
}
示例2: shouldPreventPublishersOvertakingEventProcessorWrapPoint
public void shouldPreventPublishersOvertakingEventProcessorWrapPoint()
{
int ringBufferSize = 4;
CountDownLatch latch = new CountDownLatch(ringBufferSize);
AtomicBoolean publisherComplete = new AtomicBoolean(false);
RingBuffer<StubEvent> ringBuffer = new RingBuffer<StubEvent>(StubEvent.EVENT_FACTORY, ringBufferSize);
TestEventProcessor processor = new TestEventProcessor(ringBuffer.newBarrier());
ringBuffer.setGatingSequences(processor.getSequence());
Thread thread = new Thread(() =>
{
{
for (int i = 0; i <= ringBufferSize; i++)
{
long sequence = ringBuffer.next();
StubEvent @event = ringBuffer.get(sequence);
@event.setValue(i);
ringBuffer.publish(sequence);
latch.countDown();
}
publisherComplete.set(true);
}
});
thread.Start();
latch.await();
assertEquals(ringBuffer.getCursor(), ringBufferSize - 1);
Assert.IsFalse(publisherComplete.get());
processor.run();
thread.Join();
Assert.IsTrue(publisherComplete.get());
}