Java Code Examples for reactor.core.publisher.Mono#when()

The following examples show how to use reactor.core.publisher.Mono#when() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ServerTransport.java    From reactor-netty with Apache License 2.0 5 votes vote down vote up
@Override
public void disposeNow(Duration timeout) {
	if (isDisposed()) {
		return;
	}
	dispose();
	Mono<Void> terminateSignals = Mono.empty();
	if (config.channelGroup != null) {
		List<Mono<Void>> channels = new ArrayList<>();
		// Wait for the running requests to finish
		config.channelGroup.forEach(channel -> {
			ChannelOperations<?, ?> ops = ChannelOperations.get(channel);
			if (ops != null) {
				channels.add(ops.onTerminate());
			}
		});
		if (!channels.isEmpty()) {
			terminateSignals = Mono.when(channels);
		}
	}

	try {
		onDispose().then(terminateSignals)
		           .block(timeout);
	}
	catch (Exception e) {
		throw new IllegalStateException("Socket couldn't be stopped within " + timeout.toMillis() + "ms");
	}
}
 
Example 2
Source File: CompositeHttpHeadersWriter.java    From spring-security-reactive with Apache License 2.0 4 votes vote down vote up
@Override
public Mono<Void> writeHttpHeaders(ServerWebExchange exchange) {
	Stream<Mono<Void>> results = writers.stream().map( writer -> writer.writeHttpHeaders(exchange));
	return Mono.when(results.collect(Collectors.toList()));
}
 
Example 3
Source File: CompositeHttpHeadersWriter.java    From spring-security-reactive with Apache License 2.0 4 votes vote down vote up
@Override
public Mono<Void> writeHttpHeaders(ServerWebExchange exchange) {
	Stream<Mono<Void>> results = writers.stream().map( writer -> writer.writeHttpHeaders(exchange));
	return Mono.when(results.collect(Collectors.toList()));
}
 
Example 4
Source File: BotSupport.java    From Discord4J with GNU Lesser General Public License v3.0 4 votes vote down vote up
public Mono<Void> eventHandlers() {
    return Mono.when(readyHandler(client), commandHandler(client));
}
 
Example 5
Source File: TcpResources.java    From reactor-netty with Apache License 2.0 2 votes vote down vote up
/**
 * Dispose underlying resources in a listenable fashion.
 * It is guaranteed that the disposal of the underlying LoopResources will not happen before
 * {@code quietPeriod} is over. If a task is submitted during the {@code quietPeriod},
 * it is guaranteed to be accepted and the {@code quietPeriod} will start over.
 *
 * @param quietPeriod the quiet period as described above
 * @param timeout the maximum amount of time to wait until the disposal of the underlying
 * LoopResources regardless if a task was submitted during the quiet period
 * @return the Mono that represents the end of disposal
 */
protected Mono<Void> _disposeLater(Duration quietPeriod, Duration timeout) {
	return Mono.when(defaultLoops.disposeLater(quietPeriod, timeout), defaultProvider.disposeLater());
}