类 MpUnboundedEventSequencer<T>

java.lang.Object
cn.wjybxx.disruptor.MpUnboundedEventSequencer<T>
所有已实现的接口:
DataProvider<T>, EventSequencer<T>

public class MpUnboundedEventSequencer<T> extends Object implements EventSequencer<T>
作者:
wjybxx date - 2024/1/20
  • 方法详细资料

    • getBuffer

      public MpUnboundedBuffer<T> getBuffer()
      buffer
    • inSameChunk

      public boolean inSameChunk(long seq1, long seq2)
      判断两个序号是否在同一个块
    • tryMoveHeadToNext

      public boolean tryMoveHeadToNext()
      手动触发回收 -- 该方法可安全调用
    • tryMoveHeadToNext

      public boolean tryMoveHeadToNext(long gatingSequence)
      手动触发回收,慎重调用该方法,序号错误将导致严重bug
    • get

      public final T get(long sequence)
      从接口复制的说明: DataProvider
      根据指定序号获取data 该接口可用于生产者和消费者获取数据,但对于非固定大小的数据结构而言,可能有较长的查询路径。
      指定者:
      get 在接口中 DataProvider<T>
    • producerGet

      public final T producerGet(long sequence)
      从接口复制的说明: DataProvider
      该接口用于优化生产者查询数据
      指定者:
      producerGet 在接口中 DataProvider<T>
    • consumerGet

      public final T consumerGet(long sequence)
      从接口复制的说明: DataProvider
      该接口用于优化消费者查询数据
      指定者:
      consumerGet 在接口中 DataProvider<T>
    • producerSet

      public void producerSet(long sequence, T data)
      从接口复制的说明: DataProvider
      该接口用于生产者填充数据 1. 当拷贝既有数据成本较高时可替换既有对象 2. set不提供特殊的内存语义,因此只应该生产者调用
      指定者:
      producerSet 在接口中 DataProvider<T>
    • consumerSet

      public void consumerSet(long sequence, T data)
      从接口复制的说明: DataProvider
      该接口用于消费者覆盖数据(通常用于删除数据) 1.当使用无界队列需要即时清理内存时使用。 2.set不提供特殊的内存语义,因此只应该由末尾的消费者调用
      指定者:
      consumerSet 在接口中 DataProvider<T>
    • capacity

      public int capacity()
      从接口复制的说明: EventSequencer
      数据结构大小 1.如果为【无界】数据结构,则返回-1; 2.如果为【有界】数据结构,则返回真实值。

      The capacity of the data structure to hold entries.

      指定者:
      capacity 在接口中 EventSequencer<T>
      返回:
      the size of the RingBuffer.
    • remainingCapacity

      public long remainingCapacity()
      从接口复制的说明: EventSequencer
      当前剩余容量 1.并不一定具有价值,因为多线程模型下查询容器的当前大小时,它反映的总是一个旧值。 2.如果为【无界】数据结构,可能返回任意值(大于0),但建议返回Integer.MAX_VALUE。 3.如果为【有界】数据结构,则返回真实的值。

      Get the remaining capacity for this sequencer.

      指定者:
      remainingCapacity 在接口中 EventSequencer<T>
      返回:
      The number of slots remaining.
    • sequencer

      public Sequencer sequencer()
      从接口复制的说明: EventSequencer
      获取序号生成器 -- 用于特殊需求
      指定者:
      sequencer 在接口中 EventSequencer<T>
    • producerBarrier

      public ProducerBarrier producerBarrier()
      从接口复制的说明: EventSequencer
      获取生产者屏障 -- 生产者发布数据
      指定者:
      producerBarrier 在接口中 EventSequencer<T>
    • dataProvider

      public DataProvider<T> dataProvider()
      从接口复制的说明: EventSequencer
      数据提供者
      指定者:
      dataProvider 在接口中 EventSequencer<T>
    • hasAvailableCapacity

      public boolean hasAvailableCapacity(int requiredCapacity)
      指定者:
      hasAvailableCapacity 在接口中 EventSequencer<T>
    • next

      public long next()
      指定者:
      next 在接口中 EventSequencer<T>
    • next

      public long next(int n)
      指定者:
      next 在接口中 EventSequencer<T>
    • tryNext

      public long tryNext()
      指定者:
      tryNext 在接口中 EventSequencer<T>
    • tryNext

      public long tryNext(int n)
      指定者:
      tryNext 在接口中 EventSequencer<T>
    • nextInterruptibly

      public long nextInterruptibly() throws InterruptedException
      指定者:
      nextInterruptibly 在接口中 EventSequencer<T>
      抛出:
      InterruptedException
    • nextInterruptibly

      public long nextInterruptibly(int n) throws InterruptedException
      指定者:
      nextInterruptibly 在接口中 EventSequencer<T>
      抛出:
      InterruptedException
    • tryNext

      public long tryNext(int n, long timeout, TimeUnit unit)
      指定者:
      tryNext 在接口中 EventSequencer<T>
    • publish

      public void publish(long sequence)
      指定者:
      publish 在接口中 EventSequencer<T>
    • publish

      public void publish(long lo, long hi)
      指定者:
      publish 在接口中 EventSequencer<T>
    • newBuilder

      public static <T> MpUnboundedEventSequencer.Builder<T> newBuilder(EventFactory<? extends T> factory)