java.lang.Object
cn.wjybxx.disruptor.SleepingWaitStrategy
- 所有已实现的接口:
WaitStrategy
睡眠等待策略。
表现:延迟不均匀,吞吐量较低,但是cpu占有率也较低。
算是CPU与性能之间的一个折中,当CPU资源紧张时可以考虑使用该策略。
1. 先尝试自旋等待一定次数。 2. 然后尝试yield方式自旋一定次数。 3. 然后sleep等待。
- 作者:
- wjybxx date - 2024/1/17
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明longwaitFor(long sequence, ProducerBarrier producerBarrier, ConsumerBarrier barrier) 等待给定的序号可用 实现类通过SequenceBarrier.sequence()}和SequenceBarrier.dependentSequence()进行等待。
-
构造器详细资料
-
SleepingWaitStrategy
public SleepingWaitStrategy() -
SleepingWaitStrategy
-
-
方法详细资料
-
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.
-