当前位置: 首页>>代码示例>>Java>>正文


Java Flowable.onBackpressureBuffer方法代码示例

本文整理汇总了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;
}
 
开发者ID:MFlisar,项目名称:RxBus2,代码行数:26,代码来源:RxBusBuilder.java

示例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);
}
 
开发者ID:streamingpool,项目名称:streamingpool-core,代码行数:27,代码来源:TrackKeepingDiscoveryService.java

示例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);
  }
}
 
开发者ID:tramchamploo,项目名称:buffer-slayer,代码行数:20,代码来源:RxReporter.java


注:本文中的io.reactivex.Flowable.onBackpressureBuffer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。