executing CompletableFuture.supplyAsync on event loop?

265 views
Skip to first unread message

Igor Spasić

unread,
Oct 3, 2016, 5:03:29 PM10/3/16
to vert.x
What are the issues of executing  CompletableFuture.supplyAsync() on event loop?

Clement Escoffier

unread,
Oct 3, 2016, 6:09:47 PM10/3/16
to ve...@googlegroups.com
Hi,

The issue is that other callbacks are not necessary called on the same thread (event loop thread). For instance, you have a CompletableFuture, but then you do something like: future.acceptAsync(x -> {
// Called using a thread from a fork/join executor
});


If you look at https://github.com/cescoffier/vertx-completable-future it gets the current context and ensure that all callbacks are called using the same thread, so:

future.acceptAsync(x -> {
// Called on the event loop
});

Clement





On 3 oct. 2016, at 16:03, Igor Spasić <igor....@gmail.com> wrote:

What are the issues of executing  CompletableFuture.supplyAsync() on event loop?

--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
Visit this group at https://groups.google.com/group/vertx.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/2e0208e4-e105-4820-9f21-38e88aa04b03%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages