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


Java Schedulers.parallel方法代码示例

本文整理汇总了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();
}
 
开发者ID:reactor,项目名称:reactor-core,代码行数:24,代码来源:FluxProcessorTest.java

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

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

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

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

示例6: defaultSchedulerForDelay

import reactor.core.scheduler.Schedulers; //导入方法依赖的package包/类
private Scheduler defaultSchedulerForDelay() {
	return Schedulers.parallel(); //reflects the default used in Mono.delay(duration)
}
 
开发者ID:reactor,项目名称:reactor-core,代码行数:4,代码来源:MonoDelayElementTest.java


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