本文整理汇总了Java中io.reactivex.Flowable.onBackpressureBuffer方法的典型用法代码示例。如果您正苦于以下问题:Java Flowable.onBackpressureBuffer方法的具体用法?Java Flowable.onBackpressureBuffer怎么用?Java Flowable.onBackpressureBuffer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.reactivex.Flowable
的用法示例。
在下文中一共展示了Flowable.onBackpressureBuffer方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: build
import io.reactivex.Flowable; //导入方法依赖的package包/类
public Flowable<T> build(boolean applySchedular)
{
Flowable<T> flowable = null;
if (mKeys != null)
{
for (int i = 0; i < mKeys.size(); i++)
{
if (i == 0)
flowable = RxBus.getInstance().observeEvent(mKeys.get(i));
else
flowable = flowable.mergeWith(RxBus.getInstance().observeEvent(mKeys.get(i)));
}
}
else
flowable = RxBus.getInstance().observeEvent(mEventClass);
if (mBackpressureBeforeValve)
flowable = flowable.onBackpressureBuffer();
if (mQueuer != null)
flowable = flowable.compose(FlowableTransformers.valve(mQueuer.getResumeObservable(), mQueuer.isBusResumed(), mValvePrefetch));
if (applySchedular)
flowable = applySchedular(flowable);
return flowable;
}
示例2: applyBackpressureStrategy
import io.reactivex.Flowable; //导入方法依赖的package包/类
private <T> Flowable<T> applyBackpressureStrategy(Flowable<T> source, BackpressureStrategy backpressureStrategy) {
if(backpressureStrategy == null){
return source;
}
if (backpressureStrategy instanceof BackpressureLatestStrategy) {
return source.onBackpressureLatest();
}
if (backpressureStrategy instanceof BackpressureDropStrategy) {
return source.onBackpressureDrop(i -> {});
}
if (backpressureStrategy instanceof BackpressureBufferStrategy) {
BackpressureBufferStrategy bufferStrategy = (BackpressureBufferStrategy) backpressureStrategy;
if (bufferStrategy.overflowStrategy() == BackpressureBufferStrategy.BackpressureBufferOverflowStrategy.DROP_LATEST) {
return source.onBackpressureBuffer(bufferStrategy.bufferSize(), NOOP, BackpressureOverflowStrategy.DROP_LATEST);
}
if (bufferStrategy.overflowStrategy() == BackpressureBufferStrategy.BackpressureBufferOverflowStrategy.DROP_OLDEST) {
return source.onBackpressureBuffer(bufferStrategy.bufferSize(), NOOP, BackpressureOverflowStrategy.DROP_OLDEST);
}
throw new IllegalArgumentException("Cannot determine the specified buffer overflow strategy: " + bufferStrategy);
}
if (backpressureStrategy instanceof BackpressureNoneStrategy) {
return source;
}
throw new IllegalArgumentException("Cannot determine the specified backpressure strategy: " + backpressureStrategy);
}
示例3: initBackpressurePolicy
import io.reactivex.Flowable; //导入方法依赖的package包/类
private Flowable<SendingTask<M>> initBackpressurePolicy(Flowable<SendingTask<M>> flowable) {
Strategy strategy = this.overflowStrategy;
if (strategy == Strategy.DropNew) {
return flowable.onBackpressureDrop(new Consumer<SendingTask<M>>() {
@Override
public void accept(SendingTask<M> task) throws Exception {
metricsCallback(1);
}
});
} else {
BackpressureOverflowStrategy rxStrategy = RxOverflowStrategyBridge.toRxStrategy(strategy);
return flowable.onBackpressureBuffer(pendingMaxMessages, new Action() {
@Override
public void run() throws Exception {
metricsCallback(1);
}
}, rxStrategy);
}
}