Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between future and promise in vertx?

I usually see the use of either promise and future in the start of a vert.x verticle. Is there any specific difference between both? I have read about their differences in Scala language, is it the same in case of Vert.x too? Also when should I know when to use promise or a future?

like image 401
Shrreya Behll Avatar asked Nov 19 '19 06:11

Shrreya Behll


People also ask

What is the difference between a future and a promise?

Futures and promises are pretty similar concepts, the difference is that a future is a read-only container for a result that does not yet exist, while a promise can be written (normally only once).

Is Completablefuture same as Promise?

In Java 8, the Future<T> interface has methods to check if the computation is complete, to wait for its completion, and to retrieve the result of the computation when it is complete. CompletableFutures can be thought of as a promise, since their value can be explicitly set.

What is a future in programming?

Programming Languages of the Future Learning and using programming languages is an essential part of a software developer's job. The programming languages of the future are Go, Kotlin, Python, TypeScript, R, Scala, Swift, Rust, Ruby, and Haskell,as reported by TechRepublic.

What is Handler in Vertx?

This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference. @FunctionalInterface public interface Handler<E> A generic event handler. This interface is used heavily throughout Vert. x as a handler for all types of asynchronous occurrences.


1 Answers

The best I've read about:

think on Promise as producer (used by producer on one side of async operation) and Future as consumer (used by consumer on the other side).

Futures vs. Promises

like image 143
Rogelio Triviño Avatar answered Sep 21 '22 18:09

Rogelio Triviño