Blocking a Vertx Future

187 views
Skip to first unread message

augus...@gmail.com

unread,
Jun 3, 2021, 2:49:09 PM6/3/21
to vert.x
Is there a faster/better way to block Vertx Futures then

myFuture.toCompletionStage().toCompletableFuture().get() ?


Thomas SEGISMONT

unread,
Jun 3, 2021, 3:45:42 PM6/3/21
to vert.x
Le jeu. 3 juin 2021 à 20:49, augus...@gmail.com <augus...@gmail.com> a écrit :
Is there a faster/better way to block Vertx Futures then

myFuture.toCompletionStage().toCompletableFuture().get() ?

None that I'm aware of.
 


--
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.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/0b2daf4d-cca8-4a7c-aa48-34cad59534e4n%40googlegroups.com.

August Nagro

unread,
Jun 4, 2021, 12:48:40 AM6/4/21
to ve...@googlegroups.com
Ok, thanks.

I should benchmark if it matters or not, although I do not like that CompletableFuture::get spawns ForkJoin ManagedBlockers.

I wonder if a blocking `get` or `await` would be helpful in the future? Netty and the JDK's Future class have it. The goal here is not to block on the event loop, but on an external thread.

If adding directly to Future is a foot-gun, it could be a static utility hidden somewhere.

You received this message because you are subscribed to a topic in the Google Groups "vert.x" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/vertx/rxOGruL-Arg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to vertx+un...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/CACiEr_QNgKz6os0rkUHkfJKQdAVByado8Ju2E_CfaXrnoB0yRA%40mail.gmail.com.

Thomas SEGISMONT

unread,
Jun 4, 2021, 3:30:51 AM6/4/21
to vert.x
It is definitely a foot-gun, but indeed it's something that could be useful (lots of use cases, beyond testing).

We could have something like Future.awaitBlocking that does the conversion to CompletableFuture and invokes get on it.

I'm not sure what you mean with blocking on an external thread though.

Julien Viet

unread,
Jun 6, 2021, 6:19:12 PM6/6/21
to vert.x
we don't really want to encourage people using it.

using such mechanism is exceptional and when it happens then the
effort to use a CompletableFuture is totally worth.

besides it also add noise to the future API that focus on composition
and onXXX methods.
> To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/CAHNb0ZO_PZHm%2BC-NT_0f95TqrPoQgNnQxrFrrMOYVeSeCg%3DR%2Bg%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages