Guest User

Untitled

a guest
Mar 20th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. class FutureToMono {
  2.  
  3. final ExecutorService executor = Executors.newSingleThreadExecutor();
  4.  
  5. <S> Mono<S> mono(final Future<? extends S> future) {
  6. final MonoProcessor<S> processor = MonoProcessor.create();
  7. executor.submit(() -> {
  8. try {
  9. final S stat = future.get();
  10. processor.onNext(stat);
  11. processor.onComplete();
  12. } catch (InterruptedException | ExecutionException e) {
  13. processor.onError(e);
  14. }
  15. });
  16. return processor;
  17. }
  18. }
Add Comment
Please, Sign In to add comment