java.lang.Object
cn.wjybxx.disruptor.BusySpinWaitStrategy
- 所有已实现的接口:
WaitStrategy
自旋等待策略
特征:极低的延迟,极高的吞吐量,以及极高的CPU占用。
1. 该策略通过占用CPU资源去比避免系统调用带来的延迟抖动。最好在线程能绑定到特定的CPU核心时使用。 2. 会持续占用CPU资源,基本不会让出CPU资源。 3. 如果你要使用该等待策略,确保有足够的CPU资源,且你能接受它带来的CPU使用率。
- 作者:
- wjybxx date - 2024/1/17
-
字段概要
字段 -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明longwaitFor(long sequence, ProducerBarrier producerBarrier, ConsumerBarrier barrier) 等待给定的序号可用 实现类通过SequenceBarrier.sequence()}和SequenceBarrier.dependentSequence()进行等待。
-
字段详细资料
-
INSTANCE
-
-
构造器详细资料
-
BusySpinWaitStrategy
public BusySpinWaitStrategy()
-
-
方法详细资料
-
waitFor
public long waitFor(long sequence, ProducerBarrier producerBarrier, ConsumerBarrier barrier) throws AlertException, InterruptedException 从接口复制的说明:WaitStrategy等待给定的序号可用 实现类通过SequenceBarrier.sequence()}和SequenceBarrier.dependentSequence()进行等待。- 指定者:
waitFor在接口中WaitStrategy- 参数:
sequence- 期望消费的序号producerBarrier- 用于条件等待策略依赖策略感知生产者进度barrier- 消费者屏障 - 用于检测终止信号和查询依赖等。- 返回:
- 当前可用的序号,
sequence-1表示等待超时,返回值不可以比sequence -1更小。 - 抛出:
AlertException- if a status change has occurred for the DisruptorInterruptedException- if the thread needs awaking on a condition variable.
-