java.lang.Object
cn.wjybxx.disruptor.BlockingWaitStrategy
- 所有已实现的接口:
WaitStrategy
阻塞等待策略 - 可以达到较低的cpu开销。
1. 通过lock等待【生产者】发布数据。
2. 通过sleep等待前置消费者消费数据。
3. 当吞吐量和低延迟不如CPU资源重要时,可以使用此策略。
第二阶段未沿用Disruptor的的BusySpin模式,因为: 如果前置消费者消费较慢,而后置消费者速度较快,自旋等待可能消耗较多的CPU, 而Blocking策略的目的是为了降低CPU。
- 作者:
- wjybxx date - 2024/1/17
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明longwaitFor(long sequence, ProducerBarrier producerBarrier, ConsumerBarrier barrier) 等待给定的序号可用 实现类通过SequenceBarrier.sequence()}和SequenceBarrier.dependentSequence()进行等待。
-
构造器详细资料
-
BlockingWaitStrategy
public BlockingWaitStrategy()
-
-
方法详细资料
-
waitFor
public long waitFor(long sequence, ProducerBarrier producerBarrier, ConsumerBarrier barrier) throws TimeoutException, AlertException, InterruptedException 从接口复制的说明:WaitStrategy等待给定的序号可用 实现类通过SequenceBarrier.sequence()}和SequenceBarrier.dependentSequence()进行等待。- 指定者:
waitFor在接口中WaitStrategy- 参数:
sequence- 期望生产或消费的序号producerBarrier- 用于条件等待策略依赖策略感知生产者进度barrier- 序号屏障 - 用于检测终止信号和查询依赖等。- 返回:
- 当前可用的序号
- 抛出:
TimeoutException- if a timeout occurs while waiting for the supplied sequence.AlertException- if a status change has occurred for the DisruptorInterruptedException- if the thread needs awaking on a condition variable.
-