本文整理汇总了Java中reactor.util.concurrent.Queues.unbounded方法的典型用法代码示例。如果您正苦于以下问题:Java Queues.unbounded方法的具体用法?Java Queues.unbounded怎么用?Java Queues.unbounded使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类reactor.util.concurrent.Queues
的用法示例。
在下文中一共展示了Queues.unbounded方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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();
}
示例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: scanSubscriber
import reactor.util.concurrent.Queues; //导入方法依赖的package包/类
@Test
public void scanSubscriber() {
CoreSubscriber<Integer> actual = new LambdaSubscriber<>(null, e -> {}, null, null);
FluxPublishOn.PublishOnSubscriber<Integer> test = new FluxPublishOn.PublishOnSubscriber<>(actual,
Schedulers.single(), Schedulers.single().createWorker(), true, 123, 123, Queues.unbounded());
Subscription parent = Operators.emptySubscription();
test.onSubscribe(parent);
Assertions.assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(parent);
Assertions.assertThat(test.scan(Scannable.Attr.ACTUAL)).isSameAs(actual);
Assertions.assertThat(test.scan(Scannable.Attr.DELAY_ERROR)).isTrue();
Assertions.assertThat(test.scan(Scannable.Attr.PREFETCH)).isEqualTo(123);
test.requested = 35;
Assertions.assertThat(test.scan(Scannable.Attr.REQUESTED_FROM_DOWNSTREAM)).isEqualTo(35L);
test.queue.add(1);
Assertions.assertThat(test.scan(Scannable.Attr.BUFFERED)).isEqualTo(1);
Assertions.assertThat(test.scan(Scannable.Attr.TERMINATED)).isFalse();
test.onError(new IllegalStateException("boom"));
Assertions.assertThat(test.scan(Scannable.Attr.ERROR)).hasMessage("boom");
Assertions.assertThat(test.scan(Scannable.Attr.TERMINATED)).isTrue();
Assertions.assertThat(test.scan(Scannable.Attr.CANCELLED)).isFalse();
test.cancel();
Assertions.assertThat(test.scan(Scannable.Attr.CANCELLED)).isTrue();
}
示例4: scanOverlapSubscriber
import reactor.util.concurrent.Queues; //导入方法依赖的package包/类
@Test
public void scanOverlapSubscriber() {
CoreSubscriber<Flux<Integer>> actual = new LambdaSubscriber<>(null, e -> {}, null, null);
FluxWindow.WindowOverlapSubscriber<Integer> test = new FluxWindow.WindowOverlapSubscriber<Integer>(actual,
123, 3, Queues.unbounded(), Queues.<UnicastProcessor<Integer>>unbounded().get());
Subscription parent = Operators.emptySubscription();
test.onSubscribe(parent);
Assertions.assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(parent);
Assertions.assertThat(test.scan(Scannable.Attr.ACTUAL)).isSameAs(actual);
Assertions.assertThat(test.scan(Scannable.Attr.CAPACITY)).isEqualTo(123);
test.requested = 35;
Assertions.assertThat(test.scan(Scannable.Attr.REQUESTED_FROM_DOWNSTREAM)).isEqualTo(35);
test.onNext(2);
Assertions.assertThat(test.scan(Scannable.Attr.BUFFERED)).isEqualTo(1);
Assertions.assertThat(test.scan(Scannable.Attr.TERMINATED)).isFalse();
Assertions.assertThat(test.scan(Scannable.Attr.ERROR)).isNull();
test.onError(new IllegalStateException("boom"));
Assertions.assertThat(test.scan(Scannable.Attr.ERROR)).hasMessage("boom");
Assertions.assertThat(test.scan(Scannable.Attr.TERMINATED)).isTrue();
Assertions.assertThat(test.scan(Scannable.Attr.CANCELLED)).isFalse();
test.cancel();
Assertions.assertThat(test.scan(Scannable.Attr.CANCELLED)).isTrue();
}
示例5: scanMulticaster
import reactor.util.concurrent.Queues; //导入方法依赖的package包/类
@Test
public void scanMulticaster() {
FluxPublishMulticast.FluxPublishMulticaster<Integer> test =
new FluxPublishMulticast.FluxPublishMulticaster<>(123, Queues.<Integer>unbounded(), Context.empty());
Subscription parent = Operators.emptySubscription();
test.onSubscribe(parent);
assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(parent);
assertThat(test.scan(Scannable.Attr.PREFETCH)).isEqualTo(123);
assertThat(test.scan(Scannable.Attr.BUFFERED)).isEqualTo(0);
test.queue.add(1);
assertThat(test.scan(Scannable.Attr.BUFFERED)).isEqualTo(1);
assertThat(test.scan(Scannable.Attr.TERMINATED)).isFalse();
assertThat(test.scan(Scannable.Attr.ERROR)).isNull();
test.error = new IllegalArgumentException("boom");
assertThat(test.scan(Scannable.Attr.ERROR)).isSameAs(test.error);
test.onComplete();
assertThat(test.scan(Scannable.Attr.TERMINATED)).isTrue();
assertThat(test.scan(Scannable.Attr.CANCELLED)).isFalse();
test.terminate();
assertThat(test.scan(Scannable.Attr.CANCELLED)).isTrue();
}
示例6: scanOverlapSubscriberLargeBuffered
import reactor.util.concurrent.Queues; //导入方法依赖的package包/类
@Test
public void scanOverlapSubscriberLargeBuffered() {
@SuppressWarnings("unchecked")
Queue<UnicastProcessor<Integer>> mockQueue = Mockito.mock(Queue.class);
CoreSubscriber<Flux<Integer>> actual = new LambdaSubscriber<>(null, e -> {}, null, null);
FluxWindow.WindowOverlapSubscriber<Integer> test = new FluxWindow.WindowOverlapSubscriber<Integer>(actual,
3, 3, Queues.unbounded(), mockQueue);
when(mockQueue.size()).thenReturn(Integer.MAX_VALUE);
//size() is 5
test.offer(UnicastProcessor.create());
test.offer(UnicastProcessor.create());
test.offer(UnicastProcessor.create());
test.offer(UnicastProcessor.create());
test.offer(UnicastProcessor.create());
assertThat(test.scan(Scannable.Attr.BUFFERED)).isEqualTo(Integer.MIN_VALUE);
assertThat(test.scan(Scannable.Attr.LARGE_BUFFERED)).isEqualTo(Integer.MAX_VALUE + 5L);
}
示例7: scanCoordinator
import reactor.util.concurrent.Queues; //导入方法依赖的package包/类
@Test
public void scanCoordinator() {
CoreSubscriber<Integer> actual = new LambdaSubscriber<>(null, e -> {}, null, null);
FluxZip.ZipCoordinator<Integer, Integer> test = new FluxZip.ZipCoordinator<Integer, Integer>(actual,
i -> 5, 123, Queues.unbounded(), 345);
Assertions.assertThat(test.scan(Scannable.Attr.ACTUAL)).isSameAs(actual);
test.requested = 35;
Assertions.assertThat(test.scan(Scannable.Attr.REQUESTED_FROM_DOWNSTREAM)).isEqualTo(35);
Assertions.assertThat(test.scan(Scannable.Attr.ERROR)).isNull();
test.error = new IllegalStateException("boom");
Assertions.assertThat(test.scan(Scannable.Attr.ERROR)).hasMessage("boom");
Assertions.assertThat(test.scan(Scannable.Attr.CANCELLED)).isFalse();
test.cancel();
Assertions.assertThat(test.scan(Scannable.Attr.CANCELLED)).isTrue();
}
示例8: scanInner
import reactor.util.concurrent.Queues; //导入方法依赖的package包/类
@Test
public void scanInner() {
FluxPublish<Integer> main = new FluxPublish<>(Flux.just(1), 123, Queues.unbounded());
FluxPublish.PublishSubscriber<Integer> parent = new FluxPublish.PublishSubscriber<>(789, main);
Subscription sub = Operators.emptySubscription();
parent.onSubscribe(sub);
FluxPublish.PublishInner<Integer> test = new FluxPublish.PublishInner<>(parent);
assertThat(test.scan(Scannable.Attr.ACTUAL)).isSameAs(parent);
test.parent = parent;
assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(parent);
test.request(35);
assertThat(test.scan(Scannable.Attr.REQUESTED_FROM_DOWNSTREAM)).isEqualTo(35);
assertThat(test.scan(Scannable.Attr.TERMINATED)).isFalse();
parent.terminate();
assertThat(test.scan(Scannable.Attr.TERMINATED)).isTrue();
assertThat(test.scan(Scannable.Attr.CANCELLED)).isFalse();
test.cancel();
assertThat(test.scan(Scannable.Attr.CANCELLED)).isTrue();
}
示例9: scanMulticastInner
import reactor.util.concurrent.Queues; //导入方法依赖的package包/类
@Test
public void scanMulticastInner() {
CoreSubscriber<Integer> actual = new LambdaSubscriber<>(null, e -> {}, null, null);
FluxPublishMulticast.FluxPublishMulticaster<Integer> parent =
new FluxPublishMulticast.FluxPublishMulticaster<>(123, Queues.<Integer>unbounded(), Context.empty());
FluxPublishMulticast.PublishMulticastInner<Integer> test =
new FluxPublishMulticast.PublishMulticastInner<>(parent, actual);
assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(parent);
assertThat(test.scan(Scannable.Attr.ACTUAL)).isSameAs(actual);
test.request(789);
assertThat(test.scan(Scannable.Attr.REQUESTED_FROM_DOWNSTREAM)).isEqualTo(789);
assertThat(test.scan(Scannable.Attr.CANCELLED)).isFalse();
test.cancel();
assertThat(test.scan(Scannable.Attr.CANCELLED)).isTrue();
}
示例10: mainErrorWhileIsPropagatedToBothWindowAndMain
import reactor.util.concurrent.Queues; //导入方法依赖的package包/类
@Test
public void mainErrorWhileIsPropagatedToBothWindowAndMain() {
DirectProcessor<Integer> sp1 = DirectProcessor.create();
FluxWindowPredicate<Integer> windowWhile = new FluxWindowPredicate<>(
sp1, Queues.small(), Queues.unbounded(), Queues.SMALL_BUFFER_SIZE,
i -> i % 3 == 0, Mode.WHILE);
StepVerifier.create(windowWhile.flatMap(Flux::materialize))
.expectSubscription()
.then(() -> sp1.onNext(1))
.expectNext(Signal.complete())
.then(() -> sp1.onNext(2))
.expectNext(Signal.complete())
.then(() -> sp1.onNext(3)) //at this point, new window, need another data to close it
.then(() -> sp1.onNext(4))
.expectNext(Signal.next(3), Signal.complete())
.then(() -> sp1.onError(new RuntimeException("forced failure")))
//this is the error in the window:
.expectNextMatches(signalErrorMessage("forced failure"))
//this is the error in the main:
.expectErrorMessage("forced failure")
.verify(Duration.ofMillis(100));
assertThat(sp1.hasDownstreams()).isFalse();
}
示例11: scanConditionalSubscriber
import reactor.util.concurrent.Queues; //导入方法依赖的package包/类
@Test
public void scanConditionalSubscriber() {
@SuppressWarnings("unchecked")
Fuseable.ConditionalSubscriber<Integer> actual = Mockito.mock(MockUtils.TestScannableConditionalSubscriber.class);
FluxPublishOn.PublishOnConditionalSubscriber<Integer> test =
new FluxPublishOn.PublishOnConditionalSubscriber<>(actual, Schedulers.single(),
Schedulers.single().createWorker(), true, 123, 123, Queues.unbounded());
Subscription parent = Operators.emptySubscription();
test.onSubscribe(parent);
Assertions.assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(parent);
Assertions.assertThat(test.scan(Scannable.Attr.ACTUAL)).isSameAs(actual);
Assertions.assertThat(test.scan(Scannable.Attr.DELAY_ERROR)).isTrue();
Assertions.assertThat(test.scan(Scannable.Attr.PREFETCH)).isEqualTo(123);
test.requested = 35;
Assertions.assertThat(test.scan(Scannable.Attr.REQUESTED_FROM_DOWNSTREAM)).isEqualTo(35L);
test.queue.add(1);
Assertions.assertThat(test.scan(Scannable.Attr.BUFFERED)).isEqualTo(1);
Assertions.assertThat(test.scan(Scannable.Attr.ERROR)).isNull();
Assertions.assertThat(test.scan(Scannable.Attr.TERMINATED)).isFalse();
test.onError(new IllegalStateException("boom"));
Assertions.assertThat(test.scan(Scannable.Attr.ERROR)).hasMessage("boom");
Assertions.assertThat(test.scan(Scannable.Attr.TERMINATED)).isTrue();
Assertions.assertThat(test.scan(Scannable.Attr.CANCELLED)).isFalse();
test.cancel();
Assertions.assertThat(test.scan(Scannable.Attr.CANCELLED)).isTrue();
}
示例12: predicateErrorWhile
import reactor.util.concurrent.Queues; //导入方法依赖的package包/类
@Test
public void predicateErrorWhile() {
DirectProcessor<Integer> sp1 = DirectProcessor.create();
FluxWindowPredicate<Integer> windowWhile = new FluxWindowPredicate<>(
sp1, Queues.small(), Queues.unbounded(), Queues.SMALL_BUFFER_SIZE,
i -> {
if (i == 3) return true;
if (i == 5) throw new IllegalStateException("predicate failure");
return false;
}, Mode.WHILE);
StepVerifier.create(windowWhile.flatMap(Flux::materialize))
.expectSubscription()
.then(() -> sp1.onNext(1)) //empty window
.expectNext(Signal.complete())
.then(() -> sp1.onNext(2)) //empty window
.expectNext(Signal.complete())
.then(() -> sp1.onNext(3)) //window opens
.expectNext(Signal.next(3))
.then(() -> sp1.onNext(4)) //previous window closes, new (empty) window
.expectNext(Signal.complete())
.then(() -> sp1.onNext(5)) //fails, the empty window receives onError
//error in the window:
.expectNextMatches(signalErrorMessage("predicate failure"))
.expectErrorMessage("predicate failure")
.verify(Duration.ofMillis(100));
assertThat(sp1.hasDownstreams()).isFalse();
}
示例13: scanInner
import reactor.util.concurrent.Queues; //导入方法依赖的package包/类
@Test
public void scanInner() {
CoreSubscriber<Integer> actual = new LambdaSubscriber<>(null, e -> {}, null, null);
FluxMergeSequential.MergeSequentialMain<Integer, Integer> main =
new FluxMergeSequential.MergeSequentialMain<Integer, Integer>(actual, i -> Mono.just(i),
5, 123, ErrorMode.IMMEDIATE, Queues.unbounded());
FluxMergeSequential.MergeSequentialInner<Integer> inner =
new FluxMergeSequential.MergeSequentialInner<>(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(1);
assertThat(inner.scan(Scannable.Attr.BUFFERED)).isEqualTo(1);
assertThat(inner.scan(Scannable.Attr.ERROR)).isNull();
assertThat(inner.scan(Scannable.Attr.TERMINATED)).isFalse();
inner.queue.clear();
inner.setDone();
assertThat(inner.scan(Scannable.Attr.TERMINATED)).isTrue();
assertThat(inner.scan(Scannable.Attr.CANCELLED)).isFalse();
inner.cancel();
assertThat(inner.scan(Scannable.Attr.CANCELLED)).isTrue();
}
示例14: scanMainSubscriber
import reactor.util.concurrent.Queues; //导入方法依赖的package包/类
@Test
public void scanMainSubscriber() {
CoreSubscriber<Flux<Integer>> actual = new LambdaSubscriber<>(null, e -> {}, null,
sub -> sub.request(1));
FluxWindowWhen.WindowWhenMainSubscriber<Integer, Integer, Integer> test =
new FluxWindowWhen.WindowWhenMainSubscriber<>(actual,
Flux.never(), Flux::just,
Queues.unbounded());
Subscription parent = Operators.emptySubscription();
test.onSubscribe(parent);
Assertions.assertThat(test.scan(Scannable.Attr.ACTUAL)).isSameAs(actual);
Assertions.assertThat(test.scan(Scannable.Attr.TERMINATED)).isFalse();
test.onComplete();
Assertions.assertThat(test.scan(Scannable.Attr.TERMINATED)).isTrue();
Assertions.assertThat(test.scan(Scannable.Attr.CANCELLED)).isFalse();
test.cancel();
Assertions.assertThat(test.scan(Scannable.Attr.CANCELLED)).isTrue();
Assertions.assertThat(test.scan(Scannable.Attr.REQUESTED_FROM_DOWNSTREAM))
.isEqualTo(0);
test.request(123L);
Assertions.assertThat(test.scan(Scannable.Attr.REQUESTED_FROM_DOWNSTREAM))
.isEqualTo(123L);
}
示例15: predicateErrorUntil
import reactor.util.concurrent.Queues; //导入方法依赖的package包/类
@Test
public void predicateErrorUntil() {
DirectProcessor<Integer> sp1 = DirectProcessor.create();
FluxWindowPredicate<Integer> windowUntil = new FluxWindowPredicate<>(
sp1, Queues.small(), Queues.unbounded(), Queues.SMALL_BUFFER_SIZE,
i -> {
if (i == 5) throw new IllegalStateException("predicate failure");
return i % 3 == 0;
}, Mode.UNTIL);
StepVerifier.create(windowUntil.flatMap(Flux::materialize))
.expectSubscription()
.then(() -> sp1.onNext(1))
.expectNext(Signal.next(1))
.then(() -> sp1.onNext(2))
.expectNext(Signal.next(2))
.then(() -> sp1.onNext(3))
.expectNext(Signal.next(3), Signal.complete())
.then(() -> sp1.onNext(4))
.expectNext(Signal.next(4))
.then(() -> sp1.onNext(5))
//error in the window:
.expectNextMatches(signalErrorMessage("predicate failure"))
.expectErrorMessage("predicate failure")
.verify();
assertThat(sp1.hasDownstreams()).isFalse();
}