本文整理匯總了Java中io.reactivex.BackpressureStrategy.BUFFER屬性的典型用法代碼示例。如果您正苦於以下問題:Java BackpressureStrategy.BUFFER屬性的具體用法?Java BackpressureStrategy.BUFFER怎麽用?Java BackpressureStrategy.BUFFER使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類io.reactivex.BackpressureStrategy
的用法示例。
在下文中一共展示了BackpressureStrategy.BUFFER屬性的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: run
private static void run(BackpressureStrategy backpressureStrategy) {
System.out.println("-- RUNNING WITH [" + backpressureStrategy + "] --");
Flowable<Long> fastProducer = FastProducerSlowConsumer.createFastProducer(backpressureStrategy, 1000);
Consumer<Long> onNextSlowConsumer = FastProducerSlowConsumer.createOnNextSlowConsumer(5);
fastProducer.observeOn(Schedulers.io()).subscribe(onNextSlowConsumer::accept,
e -> System.out.println(backpressureStrategy + " " + e),
() -> System.out.println(backpressureStrategy + " complete")
);
if(backpressureStrategy== BackpressureStrategy.BUFFER)DSUtil.sleep(5000);
DSUtil.sleep(1000);
}
示例2: getBackpressureStrategy
@Override
public BackpressureStrategy getBackpressureStrategy(SensorType sensorType) {
return BackpressureStrategy.BUFFER;
}
示例3: getBackpressureStrategy
@Override
public BackpressureStrategy getBackpressureStrategy(SensorType sensorType) {
sensorConfigCalled = true;
return BackpressureStrategy.BUFFER;
}
示例4: RxEventBus
private RxEventBus() {
rxBus = PublishSubject.create();
backpressureStrategy = BackpressureStrategy.BUFFER;
}
示例5: createResourceSubscriptionObserver
/**
* Creates an observer for resource subscriptions.
* <p>
* Note: for more information about observers @see <a href="http://reactivex.io/">Reactive X</a> or
* <a href="https://github.com/ReactiveX/RxJava">RxJava</a> *
* <p>
* Example:
*
* <pre>
* {
* {@code String resourcePath = "/3200/0/5501";
* String deviceId = "015f4ac587f500000000000100100249";
* Resource resource = new Resource(deviceId, path);
* connectApi.createResourceSubscriptionObserver(resource, BackpressureStrategy.BUFFER)
* .subscribe(System.out::println);
* connectApi.addResourceSubscription(resource);
* }
* </pre>
*
* @param resource
* resource to subscribe to.
* @param strategy
* backpressure strategy to apply @see {@link BackpressureStrategy}
* @return Observable which can be subscribed to. @see {@link Flowable}
* @throws MbedCloudException
* if an error occurred in the process.
*/
@API
public @Nullable Flowable<Object> createResourceSubscriptionObserver(@NonNull Resource resource,
@Nullable @DefaultValue("BUFFER") BackpressureStrategy strategy) throws MbedCloudException {
checkNotNull(resource, TAG_RESOURCE);
checkModelValidity(resource, TAG_RESOURCE);
final BackpressureStrategy finalStrategy = (strategy == null) ? BackpressureStrategy.BUFFER : strategy;
return cache.createResourceSubscriptionObserver(resource, finalStrategy);
}