java.lang.Object
cn.wjybxx.disruptor.YieldingWaitStrategy
- 所有已实现的接口:
WaitStrategy
该策略在尝试一定次数的自旋等待(空循环)之后使用尝试让出cpu。
该策略将会占用大量的CPU资源(100%),但是比
BusySpinWaitStrategy策略更容易在其他线程需要CPU时让出CPU。
它有着较低的延迟、较高的吞吐量,以及较高CPU占用率。当CPU数量足够时,可以使用该策略。
- 作者:
- wjybxx date - 2024/1/17
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明longwaitFor(long sequence, ProducerBarrier producerBarrier, ConsumerBarrier barrier) 等待给定的序号可用 实现类通过SequenceBarrier.sequence()}和SequenceBarrier.dependentSequence()进行等待。
-
构造器详细资料
-
YieldingWaitStrategy
public YieldingWaitStrategy() -
YieldingWaitStrategy
public YieldingWaitStrategy(int spinTries) - 参数:
spinTries- 自旋等待尝试次数
-
-
方法详细资料
-
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.
-