• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Cancellation类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中reactor.core.Cancellation的典型用法代码示例。如果您正苦于以下问题:Java Cancellation类的具体用法?Java Cancellation怎么用?Java Cancellation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Cancellation类属于reactor.core包,在下文中一共展示了Cancellation类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: shouldStreamDataWithTailableCursor

import reactor.core.Cancellation; //导入依赖的package包/类
/**
 * A tailable cursor streams data using {@link Flux} as it arrives inside the capped collection.
 */
@Test
public void shouldStreamDataWithTailableCursor() throws Exception {

	Cancellation cancellation = repository.findWithTailableCursorBy() //
			.doOnNext(System.out::println) //
			.doOnComplete(() -> System.out.println("Complete")) //
			.doOnTerminate(() -> System.out.println("Terminated")) //
			.subscribe();

	Thread.sleep(100);

	repository.save(new Person("Tuco", "Salamanca", 33)).subscribe();
	Thread.sleep(100);

	repository.save(new Person("Mike", "Ehrmantraut", 62)).subscribe();
	Thread.sleep(100);

	cancellation.dispose();

	repository.save(new Person("Gus", "Fring", 53)).subscribe();
	Thread.sleep(100);
}
 
开发者ID:callistaenterprise,项目名称:spring-react-one,代码行数:26,代码来源:ReactivePersonRepositoryIntegrationTest.java


示例2: internalStreamLogs

import reactor.core.Cancellation; //导入依赖的package包/类
private CFStreamingLogToken internalStreamLogs(String appName, CFApplicationLogListener listener,
		boolean recentLogs) throws CoreException {
	CloudFoundryOperations operations = getV2Operations();
	V2LogListener v2Listener = asV2LogListener(listener);
	Flux<LogMessage> stream = operations.applications()
			.logs(LogsRequest.builder().name(appName).recent(recentLogs).build());
	final Cancellation cancellation = stream.subscribe(v2Listener::onMessage, v2Listener::onError);
	return new CFStreamingLogToken() {

		@Override
		public void cancel() {
			cancellation.dispose();
		}
	};
}
 
开发者ID:eclipse,项目名称:cft,代码行数:16,代码来源:V2Client.java


示例3: scheduleAtFixedRate

import reactor.core.Cancellation; //导入依赖的package包/类
@Override
public ScheduledFuture<?> scheduleAtFixedRate(final Runnable command,
                                              long initialDelay,
                                              long period,
                                              TimeUnit unit) {
	long initialDelayInMs = convertToMillis(initialDelay, unit);
	long periodInMs = convertToMillis(period, unit);
	final AtomicReference<Cancellation> registration = new AtomicReference<>();

	final Runnable task = () -> {
		try {
			command.run();
		} catch (Throwable t) {
			log.error(t.getMessage(), t);
			Cancellation reg;
			if (null != (reg = registration.get())) {
				reg.dispose();
			}
		}
	};

	final Runnable consumer = () -> execute(task);

	final ScheduledFutureTask<?> future = new ScheduledFutureTask<Object>(task, null, initialDelay);
	registration.set(timer.schedulePeriodically(consumer, initialDelayInMs, periodInMs, TimeUnit.MILLISECONDS));
	return future;
}
 
开发者ID:reactor,项目名称:reactor-spring,代码行数:28,代码来源:AbstractAsyncTaskExecutor.java


示例4: scheduleWithFixedDelay

import reactor.core.Cancellation; //导入依赖的package包/类
@Override
public ScheduledFuture<?> scheduleWithFixedDelay(final Runnable command,
                                                 long initialDelay,
                                                 long delay,
                                                 TimeUnit unit) {
	final long initialDelayInMs = convertToMillis(initialDelay, unit);
	final long delayInMs = convertToMillis(initialDelay, unit);
	final ScheduledFutureTask<?> future = new ScheduledFutureTask<Object>(command, null, initialDelayInMs);

	final AtomicReference<Cancellation> registration = new AtomicReference<>();

	final Runnable consumer = new Runnable() {
		final Runnable self = this;

		@Override
		public void run() {
			execute(() -> {
				try {
					future.run();
					timer.schedule(self, delayInMs, TimeUnit.MILLISECONDS);
				} catch (Throwable t) {
					log.error(t.getMessage(), t);
					Cancellation reg;
					if (null != (reg = registration.get())) {
						reg.dispose();
					}
				}
			});
		}
	};

	registration.set(timer.schedule(consumer, initialDelayInMs, TimeUnit.MILLISECONDS));
	return future;
}
 
开发者ID:reactor,项目名称:reactor-spring,代码行数:35,代码来源:AbstractAsyncTaskExecutor.java


示例5: subscribe

import reactor.core.Cancellation; //导入依赖的package包/类
@Override
public boolean subscribe(final MessageHandler handler) {
	Consumer<Message<?>> consumer = handler::handleMessage;
	Cancellation c = Flux.from(processor).subscribe(consumer);
	messageHandlerConsumers.put(handler, c);

	return true;
}
 
开发者ID:reactor,项目名称:reactor-spring,代码行数:9,代码来源:ReactorSubscribableChannel.java


示例6: unsubscribe

import reactor.core.Cancellation; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public boolean unsubscribe(MessageHandler handler) {
	Cancellation control = messageHandlerConsumers.remove(handler);
	if (null == control) {
		return false;
	}
	control.dispose();
	return true;
}
 
开发者ID:reactor,项目名称:reactor-spring,代码行数:11,代码来源:ReactorSubscribableChannel.java


示例7: subscribe

import reactor.core.Cancellation; //导入依赖的package包/类
/**
 * @param consumer
 * @return
 * @see reactor.core.publisher.Mono#subscribe(java.util.function.Consumer)
 */
public final Cancellation subscribe(Consumer<? super T> consumer) {
    return boxed.subscribe(consumer);
}
 
开发者ID:aol,项目名称:cyclops,代码行数:9,代码来源:MonoKind.java


示例8: subscribe

import reactor.core.Cancellation; //导入依赖的package包/类
/**
 * @return
 * @see reactor.core.publisher.Flux#subscribe()
 */
public final Cancellation subscribe() {
    return boxed.subscribe();
}
 
开发者ID:aol,项目名称:cyclops,代码行数:8,代码来源:FluxKind.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java LocationHelper类代码示例发布时间:2022-05-23
下一篇:
Java ServletContainerInitializerInfo类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap