本文整理汇总了Java中reactor.core.scheduler.Schedulers.parallel方法的典型用法代码示例。如果您正苦于以下问题:Java Schedulers.parallel方法的具体用法?Java Schedulers.parallel怎么用?Java Schedulers.parallel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类reactor.core.scheduler.Schedulers
的用法示例。
在下文中一共展示了Schedulers.parallel方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSubmitSession
import reactor.core.scheduler.Schedulers; //导入方法依赖的package包/类
@Test
public void testSubmitSession() throws Exception {
FluxProcessor<Integer, Integer> processor = EmitterProcessor.create();
AtomicInteger count = new AtomicInteger();
CountDownLatch latch = new CountDownLatch(1);
Scheduler scheduler = Schedulers.parallel();
processor.publishOn(scheduler)
.delaySubscription(Duration.ofMillis(1000))
.limitRate(1)
.subscribe(d -> {
count.incrementAndGet();
latch.countDown();
});
FluxSink<Integer> session = processor.sink();
session.next(1);
//System.out.println(emission);
session.complete();
latch.await(5, TimeUnit.SECONDS);
Assert.assertTrue("latch : " + count, count.get() == 1);
scheduler.dispose();
}
示例2: coordinatorReachableThroughCacheInnerSubscriptionsOnly
import reactor.core.scheduler.Schedulers; //导入方法依赖的package包/类
@Test
public void coordinatorReachableThroughCacheInnerSubscriptionsOnly() throws InterruptedException {
TestPublisher<Integer> source = TestPublisher.create();
MonoCacheTime<Integer> cached = new MonoCacheTime<>(source.mono(),
Duration.ofMillis(100), //short cache TTL should trigger state change if source is not never
Schedulers.parallel());
Disposable d1 = cached.subscribe();
cached.subscribe();
WeakReference<Signal<Integer>> refCoordinator = new WeakReference<>(cached.state);
assertThat(refCoordinator.get()).isInstanceOf(MonoCacheTime.CoordinatorSubscriber.class);
Thread.sleep(150);
source = null;
cached = null;
System.gc();
assertThat(refCoordinator.get()).isInstanceOf(MonoCacheTime.CoordinatorSubscriber.class);
}
示例3: coordinatorCacheInnerDisposedOrNoReferenceNoLeak
import reactor.core.scheduler.Schedulers; //导入方法依赖的package包/类
@Test
public void coordinatorCacheInnerDisposedOrNoReferenceNoLeak() throws InterruptedException {
TestPublisher<Integer> source = TestPublisher.create();
MonoCacheTime<Integer> cached = new MonoCacheTime<>(source.mono(),
Duration.ofMillis(100), //short cache TTL should trigger state change if source is not never
Schedulers.parallel());
Disposable d1 = cached.subscribe();
cached.subscribe();
WeakReference<Signal<Integer>> refCoordinator = new WeakReference<>(cached.state);
assertThat(refCoordinator.get()).isInstanceOf(MonoCacheTime.CoordinatorSubscriber.class);
Thread.sleep(150);
source = null;
cached = null;
d1.dispose();
System.gc();
assertThat(refCoordinator.get()).isNull();
}
示例4: coordinatorNoReferenceNoLeak
import reactor.core.scheduler.Schedulers; //导入方法依赖的package包/类
@Test
public void coordinatorNoReferenceNoLeak() throws InterruptedException {
TestPublisher<Integer> source = TestPublisher.create();
MonoCacheTime<Integer> cached = new MonoCacheTime<>(source.mono(),
Duration.ofMillis(100), //short cache TTL should trigger state change if source is not never
Schedulers.parallel());
cached.subscribe();
cached.subscribe();
WeakReference<Signal<Integer>> refCoordinator = new WeakReference<>(cached.state);
assertThat(refCoordinator.get()).isInstanceOf(MonoCacheTime.CoordinatorSubscriber.class);
Thread.sleep(150);
source = null;
cached = null;
System.gc();
assertThat(refCoordinator.get()).isNull();
}
示例5: sourceCachedNoCoordinatorLeak
import reactor.core.scheduler.Schedulers; //导入方法依赖的package包/类
@Test
public void sourceCachedNoCoordinatorLeak() {
TestPublisher<Integer> source = TestPublisher.create();
MonoCacheTime<Integer> cached = new MonoCacheTime<>(source.mono(), Duration.ofSeconds(2),
Schedulers.parallel());
cached.subscribe();
WeakReference<Signal<Integer>> refCoordinator = new WeakReference<>(cached.state);
assertThat(refCoordinator.get()).isInstanceOf(MonoCacheTime.CoordinatorSubscriber.class);
source.emit(100);
System.gc();
assertThat(refCoordinator.get()).isNull();
}
示例6: defaultSchedulerForDelay
import reactor.core.scheduler.Schedulers; //导入方法依赖的package包/类
private Scheduler defaultSchedulerForDelay() {
return Schedulers.parallel(); //reflects the default used in Mono.delay(duration)
}