本文整理汇总了Java中reactor.util.concurrent.Queues.get方法的典型用法代码示例。如果您正苦于以下问题:Java Queues.get方法的具体用法?Java Queues.get怎么用?Java Queues.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类reactor.util.concurrent.Queues
的用法示例。
在下文中一共展示了Queues.get方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: noOuterScalarReordering
import reactor.util.concurrent.Queues; //导入方法依赖的package包/类
@Test
public void noOuterScalarReordering() {
AssertSubscriber<Integer> ts = AssertSubscriber.create(0);
FluxFlatMap.FlatMapMain<Publisher<Integer>, Integer> fmm =
new FluxFlatMap.FlatMapMain<>(ts,
Function.identity(),
false,
128,
Queues.get(128),
128,
Queues.get(128));
fmm.onSubscribe(Operators.emptySubscription());
fmm.onNext(Flux.just(1));
Operators.addCap(FluxFlatMap.FlatMapMain.REQUESTED, fmm, 2L);
fmm.onNext(Flux.just(2));
fmm.drain();
ts.assertValues(1, 2);
}
示例2: scanMainLargeBuffered
import reactor.util.concurrent.Queues; //导入方法依赖的package包/类
@Test
public void scanMainLargeBuffered() {
CoreSubscriber<Integer> actual = new LambdaSubscriber<>(null, e -> {}, null, null);
FluxFlatMap.FlatMapMain<Integer, Integer> test = new FluxFlatMap.FlatMapMain<>(actual,
i -> Mono.just(i), true, 5, Queues.<Integer>unbounded(), 789, Queues.<Integer>get(789));
test.scalarQueue = new ConcurrentLinkedQueue<>();
test.scalarQueue.add(1);
test.scalarQueue.add(2);
test.scalarQueue.add(3);
test.size = Integer.MAX_VALUE;
assertThat(test.scan(Scannable.Attr.BUFFERED)).isEqualTo(Integer.MIN_VALUE);
assertThat(test.scan(Scannable.Attr.LARGE_BUFFERED)).isEqualTo(Integer.MAX_VALUE + 3L);
}
示例3: scanInner
import reactor.util.concurrent.Queues; //导入方法依赖的package包/类
@Test
public void scanInner() {
CoreSubscriber<Integer> actual = new LambdaSubscriber<>(null, e -> {}, null, null);
FluxFlatMap.FlatMapMain<Integer, Integer> main = new FluxFlatMap.FlatMapMain<>(actual,
i -> Mono.just(i), true, 5, Queues.<Integer>unbounded(), 789, Queues.<Integer>get(789));
FluxFlatMap.FlatMapInner<Integer> inner = new FluxFlatMap.FlatMapInner<>(main, 123);
Subscription parent = Operators.emptySubscription();
inner.onSubscribe(parent);
assertThat(inner.scan(Scannable.Attr.ACTUAL)).isSameAs(main);
assertThat(inner.scan(Scannable.Attr.PARENT)).isSameAs(parent);
assertThat(inner.scan(Scannable.Attr.PREFETCH)).isEqualTo(123);
inner.queue = new ConcurrentLinkedQueue<>();
inner.queue.add(5);
assertThat(inner.scan(Scannable.Attr.BUFFERED)).isEqualTo(1);
assertThat(inner.scan(Scannable.Attr.TERMINATED)).isFalse();
inner.onError(new IllegalStateException("boom"));
assertThat(main.scan(Scannable.Attr.ERROR)).hasMessage("boom");
inner.queue.clear();
assertThat(inner.scan(Scannable.Attr.TERMINATED)).isTrue();
assertThat(inner.scan(Scannable.Attr.CANCELLED)).isFalse();
inner.cancel();
assertThat(inner.scan(Scannable.Attr.CANCELLED)).isTrue();
}
示例4: mergeSequentialLargeBadQueueSize
import reactor.util.concurrent.Queues; //导入方法依赖的package包/类
@Test
public void mergeSequentialLargeBadQueueSize() {
int prefetch = 32;
int maxConcurrency = 256;
Supplier<Queue<FluxMergeSequential.MergeSequentialInner<Integer>>> badQueueSupplier =
Queues.get(Math.min(prefetch, maxConcurrency));
FluxMergeSequential<Integer, Integer> fluxMergeSequential =
new FluxMergeSequential<>(Flux.range(0, 500),
Mono::just,
maxConcurrency, prefetch, FluxConcatMap.ErrorMode.IMMEDIATE,
badQueueSupplier);
StepVerifier.create(fluxMergeSequential.zipWith(Flux.range(0, Integer.MAX_VALUE)))
.expectErrorMatches(e -> e instanceof IllegalStateException &&
e.getMessage().startsWith("Too many subscribers for fluxMergeSequential on item: ") &&
e.getMessage().endsWith("; subscribers: 32"))
.verify();
}
示例5: noInnerReordering
import reactor.util.concurrent.Queues; //导入方法依赖的package包/类
@Test
public void noInnerReordering() {
AssertSubscriber<Integer> ts = AssertSubscriber.create(0);
FluxFlatMap.FlatMapMain<Publisher<Integer>, Integer> fmm =
new FluxFlatMap.FlatMapMain<>(ts,
Function.identity(),
false,
128,
Queues.get(128),
128,
Queues.get(128));
fmm.onSubscribe(Operators.emptySubscription());
EmitterProcessor<Integer> ps = EmitterProcessor.create();
fmm.onNext(ps);
ps.onNext(1);
Operators.addCap(FluxFlatMap.FlatMapMain.REQUESTED, fmm, 2L);
ps.onNext(2);
fmm.drain();
ts.assertValues(1, 2);
}
示例6: scanMain
import reactor.util.concurrent.Queues; //导入方法依赖的package包/类
@Test
public void scanMain() {
CoreSubscriber<Integer> actual = new LambdaSubscriber<>(null, e -> {}, null, null);
FluxFlatMap.FlatMapMain<Integer, Integer> test = new FluxFlatMap.FlatMapMain<>(actual,
i -> Mono.just(i), true, 5, Queues.<Integer>unbounded(), 789, Queues.<Integer>get(789));
Subscription parent = Operators.emptySubscription();
test.onSubscribe(parent);
assertThat(test.scan(Scannable.Attr.ACTUAL)).isSameAs(actual);
assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(parent);
assertThat(test.scan(Scannable.Attr.DELAY_ERROR)).isTrue();
test.requested = 35;
assertThat(test.scan(Scannable.Attr.REQUESTED_FROM_DOWNSTREAM)).isEqualTo(35);
assertThat(test.scan(Scannable.Attr.PREFETCH)).isEqualTo(5);
test.scalarQueue = new ConcurrentLinkedQueue<>();
test.scalarQueue.add(1);
assertThat(test.scan(Scannable.Attr.BUFFERED)).isEqualTo(1);
assertThat(test.scan(Scannable.Attr.LARGE_BUFFERED)).isEqualTo(1L);
assertThat(test.scan(Scannable.Attr.ERROR)).isNull();
assertThat(test.scan(Scannable.Attr.TERMINATED)).isFalse();
test.onError(new IllegalStateException("boom"));
assertThat(test.scan(Scannable.Attr.ERROR)).isSameAs(test.error);
test.scalarQueue.clear();
assertThat(test.scan(Scannable.Attr.TERMINATED)).isTrue();
assertThat(test.scan(Scannable.Attr.CANCELLED)).isFalse();
test.cancel();
assertThat(test.scan(Scannable.Attr.CANCELLED)).isTrue();
}
示例7: FluxMergeSequential
import reactor.util.concurrent.Queues; //导入方法依赖的package包/类
FluxMergeSequential(Flux<? extends T> source,
Function<? super T, ? extends Publisher<? extends R>> mapper,
int maxConcurrency, int prefetch, ErrorMode errorMode) {
this(source, mapper, maxConcurrency, prefetch, errorMode,
Queues.get(Math.max(prefetch, maxConcurrency)));
}
示例8: toIterable
import reactor.util.concurrent.Queues; //导入方法依赖的package包/类
/**
* Transform this {@link Flux} into a lazy {@link Iterable} blocking on
* {@link Iterator#next()} calls.
*
* <p>
* <img class="marble" src="https://raw.githubusercontent.com/reactor/reactor-core/v3.1.3.RELEASE/src/docs/marble/toiterablen.png" alt="">
*
* @param batchSize the bounded capacity to prefetch from this {@link Flux} or
* {@code Integer.MAX_VALUE} for unbounded demand
* @param queueProvider the supplier of the queue implementation to be used for storing
* elements emitted faster than the iteration
*
* @return a blocking {@link Iterable}
*/
public final Iterable<T> toIterable(int batchSize, @Nullable Supplier<Queue<T>>
queueProvider) {
final Supplier<Queue<T>> provider;
if(queueProvider == null){
provider = Queues.get(batchSize);
}
else{
provider = queueProvider;
}
return new BlockingIterable<>(this, batchSize, provider);
}
示例9: toStream
import reactor.util.concurrent.Queues; //导入方法依赖的package包/类
/**
* Transform this {@link Flux} into a lazy {@link Stream} blocking for each source
* {@link Subscriber#onNext(Object) onNext} call.
*
* @param batchSize the bounded capacity to prefetch from this {@link Flux} or
* {@code Integer.MAX_VALUE} for unbounded demand
* <p>
* <img class="marble" src="https://raw.githubusercontent.com/reactor/reactor-core/v3.1.3.RELEASE/src/docs/marble/tostream.png" alt="">
*
* @return a {@link Stream} of unknown size with onClose attached to {@link Subscription#cancel()}
*/
public final Stream<T> toStream(int batchSize) {
final Supplier<Queue<T>> provider;
provider = Queues.get(batchSize);
return new BlockingIterable<>(this, batchSize, provider).stream();
}