Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class FutureToMono {
- final ExecutorService executor = Executors.newSingleThreadExecutor();
- <S> Mono<S> mono(final Future<? extends S> future) {
- final MonoProcessor<S> processor = MonoProcessor.create();
- executor.submit(() -> {
- try {
- final S stat = future.get();
- processor.onNext(stat);
- processor.onComplete();
- } catch (InterruptedException | ExecutionException e) {
- processor.onError(e);
- }
- });
- return processor;
- }
- }
Add Comment
Please, Sign In to add comment